Tuesday, November 22, 2011

Hosting MVC 4 Mobile Application on Windows Azure - Package and Deploy.

The package and deploy option in Windows Azure is useful if you are working in a team where different people are responsible for 'development' and 'deployment'.

Let me walkthrough the package and deployment of a MVC 4 mobile application in Windows Azure. 
First select a MVC 4 Web application in the New Project dialog box in Visual Studio.


Select the Mobile Application.


Select the ASP.Net MVC 4 Web Role and give a name. Say "MVC4MobileWebRole".



The Solution comes up with default Home page.


Compile and run the application locally.


You could customize the application as per requirement and once it is ready for deployment follow these steps.

  • Right click on the project and select "Package...".





  • Select the build configuration as "Release" and click on "Package".



Once the package is created Visual Studio will open up the app.publish folder.   



Developers could share this package with deployment team. In the Windows Azure management portal under your subscriptions create a new "Staging Deployment". Give a deployment name "WebRoleApp" of your choice.



Use the browse locally option to select the package file as well the configuration file. These files will be present inside the app.publish folder.

Click Yes on the warning dialog.



We can see that the deployment process has been started and the status is "Intializing..."



Once the status is "Ready", we can browse the application and test.



We can find the DNS name in the prortal and browse the application with the full URL.



We can see that the application is successfully deployment on windows azure.



Deployment to production results in a DNS name based on the URL of your choice, instead of a GUID as used for staging. The web service URL for a MVC 4 mobile application deployed to the production environment will be of the form http://"the_name_you_specified".cloudapp.net/.


Also checkout Visual Studio Enhancements in Windows Azure SDK 1.6 for Publishing Apps and Startup Tasks for Windows Azure Roles.