Wednesday, 11 July 2012

MOVING Web Applications to the CLOUD

This post discusses about preparing the Web application to run in CLOUD (Windows Azure) Environment. We will create a new windows azure project in VS 2010 to move the existing ASP.NET web application. Process described below works for both ASP.NET Web and MVC applications. image

You need to download and install the following tools from here to move the applications to windows azure environment.


1. Open the Visual Studio 2010 as administrator
2. Open your existing ASP.NET Web application
3. Create a new cloud project and add to the solution as shown below.

Select the Windows Azure Project template from the dialogue box and say ok
image

4.Do not add any roles as we add the existing application as a role and just say ok.


image

5. Add the ASP.NET project to the cloud project. In Solution Explorer, right-click the Roles node in the Azure project then Add and select Web Role Project in solution.

image


6. In the project association dialogue box select the existing project
image


When you said Ok in above dialogue, Visual Studio updates the ServiceDefinition.csdef and the ServiceConfiguration.cscfg files


7. Add the following assemblies to existing asp.net project as these are required to run in Azure environment.

Microsoft.WindowsAzure.Diagnostics
Microsoft.WindowsAzure.ServiceRuntime
Microsoft.WindowsAzure.StorageClient

image


8.To enable the diagnostics logging, add the following lines to Web.Config file in asp.net project
image

9. Add the following piece of code to Global.asax file in Application start event
   1: Microsoft.WindowsAzure.CloudStorageAccount.SetConfigurationSettingPublisher
   2:  ((configName, configSetter) =>
   3: {
   4:        configSetter(RoleEnvironment.GetConfigurationSettingValue(configName));
   5: );


10. As we are moving the ASP.NET MVC application make sure that System.Web.MVC is copied to local as shown below
image


11. Publishing the project to client is simple, just right click on the Azure project and say publish Supply the credentials and hosted service details
image
Post a Comment