Converting Existing Web Applications for use in Azure

Creating Azure Web Roles in Visual Studio when converting an existing web application for Azure as offered by New Signature

When creating new Azure Web Roles, Visual Studio will automatically create a new project for your actual ASP.NET web application. While this is perfect for demos and short projects, most users will want to use an existing web application for Azure. However, if you try and add your existing web application as a web role, the cloud service project will not pick up your web application. You can see that in the image below:

image

The fix for this is pretty trivial. Right click on your web application project (in this case ExistingWebApplication), and choose the Unload Project option. Now right click on it again and choose “Edit <ProjectNameHere>.csproj”. This will load the csproj file into the XML viewer and allow you to edit it. To add the ability to use our application in the cloud, navigate to the first <PropertyGroup> element you find and add a <RoleType> element containing “Web”:

image1

Right click on the project in Solution Explorer again and choose “Reload Project”. Once this has completed, the Cloud Service project will allow you to add the existing web project as an Azure WebRole. One final step is to add Microsoft.ServiceHosting.ServiceRuntime as a reference in the web project.

image2