Sunday, October 24, 2010

How to Migrate an ASP.NET application to Windows Azure

Migrating existing ASP.NET sites to Azure is a process that right now must be performed manually (no sign yet of a migration tool).  The Azure Web Role is very similar to an ASP.NETweb project but has some significant differences which unfortunately mean that a straight copy of the project won’t do the trick.
It is possible to add as Cloud Service project to a solution with an ASP.NET web site but the simplest solution is to create a solution with a Cloud Service and a Web Role and copy the files over, and so I will follow this procedure for this walk-through:
  1. Create a Cloud Service and a Web Role in Visual Studio. Please refer to this this tutorialfor details on doing this. So your solution should look like below:
    ScreenHunter 01 Feb. 23 15.34 Migrating an ASP.NET site to an Azure Web Role
  2. Open the folder of the ASP.NET website to be migrated in the File Explorer and drag the files across to the Web Role (you can just open the standard  Windows File Explorer and place it next to Visual Studio). Do not copy the bin folder and the web.config file.
  3. Manually add the references of the ASP.NET website to the Web Role (Right-click the Web Role in the Solution Explorer and select Add Reference…).
  4. All the .aspx pages in an Azure Web Role have an associated designer.cs or designer.vb page in addition to the code behind page. To manually generate to these files, select the .aspx pages, right-click and select Convert to Web Application.
    ScreenHunter 02 Feb. 23 15.38 Migrating an ASP.NET site to an Azure Web Role
  5. In an ASP.NET web application files in the App_Code folder usually have their build action set to Content. In an Azure Web Role these files need to be set to Compile. To do this, select the files in the App_Code folder, right-click and select Properties. In the Properties window set the Build Action to Compile.
  6. Copy the configuration elements from the web.config  in your ASP.NET site to the web.config in the Azure Web Role. This can be quite tedious but the quick fixes to this often create compilation errors or overwrite some key features of Azure (such as Diagnostics).

1 comment: