Guide to Migrating a .NET Site to Azure

What are the Steps to Migrating .NET Site to Azure?

Microsoft generally does a good job of integrating its products and that is mostly true for .NET and Azure. Migrating a .NET site to Azure is relatively easy with a few details that need to be looked after.

Here is a step by step guide to migrating a .NET site to Azure.

Open the web site project

Before you convert a project, you should verify that it is working correctly. This will prevent errors during conversion.

  1. Open the existing solution.
  2. In the Build menu, click Build Web Site.

Creating a new Web application project

Now we are going to create a new local copy so we can prepare the site for Azure without wrecking our working local copy.

  1. Create a new, blank Web application project in a separate directory.
  2. Create an ASP.NET Empty Web Application.
  3. Type values for Name, Location, and Solution Name, and then clicks OK to create the Web application project.

Copying Files to the Web Application Project

The easiest way to add your existing files is to copy the files from a web site project directory to the web application project directory.

  1. In the Solution Explorer, right-click the web site project and select Open Folder in Windows Explorer.
  2. Select the files of the web site project to copy.
  3. Right-click the selected files and then click Copy.
  4. In the web application project, right-click the web application project and click Open Folder in Windows Explorer.
  5. Paste the Web site project files into the Web application project directory.
  6. In Solution Explorer of the Web application project, click the Show All Files button.
  7. Select the new files in Solution Explorer.
  8. Right-click the selected files and then click Include In Project.

One difference between a web site project and a Web application project is that in a Web site project, ASP.NET dynamically generates partial classes for ASP.NET web forms, pages and user controls.

After you copy the files from the Web site project to the Web application project, you will notice that the code behind files for each page and user-control are still associated with the .aspx, .master, and .ascx files.

Add Class Library Projects in Solution

You may have noticed in the last step that no .designer.cs or .designer.vb files have been generated. Now we will convert these pages to save their partial classes in a .designer.cs or .designer.vb file.

  1. Add Class libraries that are used in the working site  (or that can be used in the Web Application project).
  2. Then build these Project libraries.

Setting Project References

Add references of build class libraries to the web application project.

If the Web site project requires additional project or assembly references, you can add them to the Web application project.

To help prevent errors, before you convert the project files, add references to the web application project for assemblies that are in the Bin folder in the web site project.

To add references to a web application project

  1. In Solution Explorer, right-click References, and then click Add ReferenceThe Add Reference dialog box should display.
  2. Select the reference that you want to add and then click OK.
  3. In Solution Explorer, right-click the Web application and click Build.

To add references for web services to a web application project

  1. In Solution Explorer, right-click References, and then click Add Web ReferenceThe Add Web Reference dialog box should display.
  2. Type the URL for the web service that you want to add and then click OK.
  3. In Solution Explorer, right-click the Web application and click Build.

Converting the Project Files

To convert pages and classes to use partial classes in a Web application project:

  1. In Solution Explorer, right-click the root project folder that contains the pages and classes that you want to convert and then click Convert to Web Application.
  2. Build the project to see whether there are any compilation errors.

If you see errors, the two most likely causes are as follows:

  • An assembly reference is missing and  must be added to your project.
  • There is an issue with a dynamically generated type, such as the Profile object or a typed dataset.

Instead, store class files in any folder of your project other than the App_Code folder. This is done automatically by the Convert to Web Application command, which renames the folder to Old_App_Code.

Running the Web Application Project

You can now compile and run the application. By default, Visual Studio uses the built-in Visual Studio Development Server to run the site. Alternatively, you can configure the project to use Internet Information Services (IIS).

To manage Web application project settings, right-click the project and then click Properties.

Add Windows Azure Project

Add a Windows Azure project with an empty Web Role in the web application project.

  1. In the File menu, click New, and then click Project.
  2. In the Project Types pane, select Cloud from the Visual C# or Visual Basic project template nodes.
  3. In the Templates pane, select Windows Azure Project.
  4. Enter the name and location for your project and a name for the solution. Click OK.
  5. In the New Windows Azure Project dialog, select the empty Web Role node.
  6. Click OK to create your solution in Visual Studio.

Add Role to the Windows Azure project

Finally, add the role to the Windows Azure project.

  1. In the Windows Azure project right click on the Role folder.
  2. Click on Add and then click Web Role project in Solution. The Associate With Role Project dialog box should open.
  3. In the dialog box, select the project dll of the web application.


Contact us to learn more.


(Note: This post has been updated with new information)