Creating a Windows Azure Web Site and Deploying ASP.NET MVC 4 Applications There


So, you decided to try what Windows Azure Web Site is and what you can do there. You need to start if you don’t have a Windows Azure subscription, with trial access . We omit this step in the article as a simple one and immediately move on to the main thing - creating a Web Site.

Creating a New Windows Azure Web Site

So, the account has been created, we go to the management portal in the Web Sites section:
click on CREATE WEB SITE - start the creation procedure, the site creation interface appears with the default option selected - quick creation:
If you wish, you can immediately deploy one of the gallery of supported applications to the site :
We will create a website with a database:
Create a habratest website and a new database:
Specify the parameters of the new database:
Including username and password:
Click the checkmark button, start the process of creating the site:
The site is created and launched.


When opened, the following page will be displayed:


So, we have created the Windows Azure Web Site with the SQL Server database linked to it.

Let's look at the control panel of our site.


In addition to various usage statistics on the Dashboard, pay attention to some very useful links on the left:
  • View connection string - connection string from your database (without password);
  • Download publish profile - the ability to download a profile for publication, which can then be imported into WebMatrix and Visual Studio;
  • Reset deployment credentials - reset credentials of access for deployment;
  • Setup TFS / Git publishing - allows you to configure publishing from TFS / Git

Before proceeding to the next steps, you need to prepare a little:
  • download the publish profile in advance (Download publish profile), it will be required when publishing a site from Visual Studio 2012;
  • copy the database connection settings (View connection string).

Creating a new ASP.NET MVC 4 website

Let's create an ASP.NET MVC 4 application with support for the .NET Framework 4.0 (version 4.5 is not supported by Web Sites):
Having left all the default settings in the application wizard, we will wait until the site is created.

All! We are ready to publish our application on Windows Azure Web Sites!

Publishing a Website on Windows Azure Web Sites

Right-click on Solution and select Publish. The publication dialog opens:
Nothing is populated, but we have an Import button. Click it and import the deployment profile that we saved after creating the Web Site. On the next page of the wizard, check the settings - everything is OK:
On the next page of the wizard, we need the copied settings for connecting to the database and know the password for it:
Click Next - everything is ready for publication:
Click the Publish button and after a few minutes we enjoy the site that runs on Windows Azure Web Sites!

What else you need to know to use it in reality

If you use the Code First paradigm, then you will need to update the database on the hosting. This is enough to do. In the console window of the Package Manager Console, you need to enter the following commands sequentially:
enable-migrations
add-migration Initial
update-database
The appropriate code will be generated automatically, the publication wizard will determine its presence and it can be configured in Settings:
Using SQL Server is paid initially. How much Web Sites cost in different versions can be found in the calculator .

If you want to use PHP and MySQL - Web Sites support them.