Azure – Let’s see what you got

Like I mentioned on begin Daj Się Poznać 2016 competition I want to take a look Azure. I hadn’t had any special plan on that until now!
What is the better way to get to know Azure ? I think there is just one way. I have web application I have access to Azure so why not publish that application ?

Publish site

After watched one tutorial how to publish simple website to Azure I did the same thing. It’s really straightforward. I just clicked publish button on my ASP.NET MVC project and fill inputs with basic settings.

Profile -> Microsoft Azure AppService

azure2

In Connection tab I only changed Site Name. Site name is URL address for SmileTable website. Destination URL label show full URL website.

There is also option which say plesase select Publish option. I wanted to know more about that, and basically for begginers is better to use Web Deploy option. That is because I don’t have to worry about all stuff, about files which I want to publish etc.

Settings tab is also interesting because there is place where we can specify our application connection string. I just leaved it empty despite SmileTable has database so must have connection string.

Last tab Preview is the place where I can see which files goes to the server. For first publish It will be all neccessary files. Next publish will append files which was changed or added.

After click publish button we can see actions in VisualStudio output window, and if all go okay there will be success status.

That is all, REALLY! After that page will avaliable on our URL address 😉 I didn’t believe and type my address in browser and this is the view what i saw.

azure error
There are some error, that’s why whole page is empty and there is only layout. I came to conclusion that there is one thing – database !! which I didn’t added yet.

Connect to SQL Database. The hardest part ?

I was looking for how to add sql database to azure web site in google and of course there were some articles but after read one of them I didn’t find what I am looking for. Then I decided do it myself without any google help. I was already tired by scrolling google but I also thought that for sure will be hard do it without tutorial. I WAS WRONG !

What I did, I moved into my Azure dashboard. There is nice menu on left side and click
adding sql„Bazy danych SQL”. Creating new database is very easy we just need to fill all fields.
There is just one thing. We need to add new server for our databse.

 

 

 

 

 

 

 
It may takes while, but before click create button I have selected pin to desktop, and there was information about createing database status

Azure4
It is detail but it’s nice 😉

Okey so I have created database and now what ?
If I have created new server and database so I should have possibility to connect with that. I decided check it out. I run SQL MS and type my connection data -> server name and my password, and I got error

azure5

but there is nothing to worry about beacuse It is firewall!! and I resolve thar „problem” really quick in Azure dashboard. I move to my server tab and add new rule for my IP address. After that all start work!

SQL MS before update web
I was able to connect with my Azure server but my application still doesn’t work :<
I was no suprised because nothing changed with that 😉

 

 

 
Next I thinked if I have created database so all I have to do I need to swap connection string in SmileTable application to my new Azure database. I was little confused how to do that. But again it was so simple.

I clicked on my webSite in Azure dashboard move to „Połączenia przesyłania danych” and Added new Data Connection.

add connectionstring2
This is the place where I added new connection string to SmileTable. So I had to choose already created database and specify name of my connection string username and password. After that connection string is generated and is visible in Data Connections tab.

If you remember in Publish Web window with settings tab. There was input for connection string, which I just leaved empty. Now I have Azure database and I have generated connection string. Now I can move back to that page and add that connection string.

connectionstring3

After that we have to publish our website and there will be web.config file which was changed to new ApplicationDbContext! That’s cool.
azure3SQL MS after update web

And that is all what I had to do to run SmileTable application. Now SQL MS connected to Azure server show all tables which was in my local database 😉

One thing what’s suprised me. I fear that If I only will publish my ASP.NET MVC application project without any class libraries my website won’t work. I was wrong because even if we have many class libraries and we are publish just our web application, those libraries are included. I think It happens because they are connected with each other by references.

Advertisements

Skomentuj

Wprowadź swoje dane lub kliknij jedną z tych ikon, aby się zalogować:

Logo WordPress.com

Komentujesz korzystając z konta WordPress.com. Log Out / Zmień )

Zdjęcie z Twittera

Komentujesz korzystając z konta Twitter. Log Out / Zmień )

Facebook photo

Komentujesz korzystając z konta Facebook. Log Out / Zmień )

Google+ photo

Komentujesz korzystając z konta Google+. Log Out / Zmień )

Connecting to %s