With the release of Windows Azure only a few weeks away, it is likely that more and more developers are going to want to move their existing Web applications into the cloud. Fortunately, Microsoft has made it very easy to do so and a big part of that is the decision to make Azure Web Roles look (and behave) so much like ASP.NET Web Applications.
Really, a Web Role project and a Web Application project are identical, with one very minor exception: by default, Web Role projects contain a reference to the Microsoft.ServiceHosting.ServiceRuntime assembly and Web Application projects do not:

The ONLY difference between a Web Role project and a Web Application project
Because Web Roles and Web Applications are architecturally identical, you can easily add an existing Web application to a Windows Azure application… It’s a two step process; first, add the Web Application project to your cloud solution:

Adding a new Web Application project to an existing Cloud Service
Second, add the project as a Web Role by right-clicking “Roles” in Solution Explorer and selecting Add > Web Role Project in solution…

Adding an existing Web Role project in solutions
Your original Web Application project is now part of your Windows Azure application! To make it identical to a Web Role created “from scratch,” simply add a reference to Microsoft.ServiceHosting.ServiceRuntime, which you can find in the Windows Azure SDK (the default location in most cases will be C:\Program Files\Windows Azure SDK\v1.0\ref\Microsoft.ServiceHosting.ServiceRuntime.dll.)
One more thing – when you add an existing application to a Visual Studio solution, it just creates a pointer to the original .csproj/.vbproj file from your solution – in other words, make sure you create a backup copy of your original Web Application before you move it into the cloud!
That’s the easy part of migration – however, it can get more complicated and more challenging if your application relies on data storage, services, client-side code or 3rd party libraries. I’ll be posting some short articles on how to deal with these various scenarios in the coming days and weeks.
#1 by Sonald Duclair on November 2, 2009 - 12:35 pm
The lack of a true filesystem means that most applications that ever reference the System.IO class library for file and directory manupulations will need major modifications. Don’t get me wrong, Azure is going to be a very scallable, available and probably reliable service. I just don’t like the idea of building an ASP.NET application for a specific hosting environment. That way I won’t be tied or married to it. In other words, choosing Microsoft Azure is a lifetime commitment that I am not quiet ready to make.
#2 by Sonald Duclair on November 4, 2009 - 1:39 pm
Is it possible to use a virtual path provider for Windows Azure storage. I think this would go a long way if the goal is to make it easy for others to migrate to Windows Azure.
#3 by bill on November 4, 2009 - 2:01 pm
Yes, you could use a VirtualPathProvider to provide a layer of abstraction between your app and Windows Azure storage. At this point there is nothing built-in, but you could create your own as Maarten Balliauw has described here:
http://blog.maartenballiauw.be/post/2009/06/09/A-view-from-the-cloud-(or-locate-your-ASPNET-MVC-views-on-Windows-Azure-Blob-Storage).aspx
#4 by Dima on December 1, 2009 - 10:14 am
Sonald: well, you are going to create the app for traditional platform right? so you are married to it?
Time will show, that now we have two hosting platforms and both have equal rights to exist. You will have to write an app and make that choice.
#5 by Cory 'SyntaxC4' Fowler on February 9, 2010 - 5:04 pm
Microsoft.ServiceHosting.ServiceRuntime has been changed to Microsoft.WindowsAzure.ServiceRuntime
#6 by Conrad Rowlands on February 12, 2010 - 4:06 am
When exactly will you be “posting some short articles on how to deal with these various scenarios ( data storage, services)” It has been some time since this article was written. Or have I missed it out in the ether….
#7 by bill on February 19, 2010 - 9:55 am
Hi Conrad,
I am still hoping to spend some time exploring other migration scenarios, but unfortunately I’ve had to focus on some non-Azure topics lately (WPF 4, Silverlight 4, Windows 7, etc – you’ll notice recent posts about new videos on these topics!)
Thanks for the reminder, though!