Enabling a Pre-existing Project as a WebRole in Azure Solution

November 1, 2008

In trying to use an existing VS2008 Project as a WebRole in a Windows Azure Solution, I discovered that the project did not appear as a candidate for selection from the Roles > Add > Web Role Project in solution menu. All the Azure documentation indicates that there is no special requirement for a web project to be a candidate for Azure, so I found this to be odd. The solution, as it turns out, is pretty simple:

1) Open the existing project’s .csproj file in a text editor.

2) Add the following two lines of code anywhere within the first element:

Web
$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\ServiceHosting\v1.0@InstallPath)

Reload the project and it now becomes available as a WebRole.