For more recent information on using ASP.NET MVC with Windows Azure please see this post.
If you’ve been following along, you’ll remember my post about using an existing ASP.NET Web Application as a Web Role. We’re now a little smarter in the tools and can allow you to associate any ASP.NET Web Application in the Cloud Service as a Web Role.
For example, I can create a Cloud Service with just a Worker role, right click on the Solution in Solution Explorer and select Add | New Project and select an ASP.NET Web Application from the Web folder.
This could be *any* ASP.NET Web Application, including derivatives of it like an MVC project, Dynamic Data etc.
For the sake of this demo, I’ll add an ASP.NET MVC Web Application:
I then right click on the Roles node in the Cloud Service project and select Add | Web Role Project in solution…
Now instead of just “Web Roles”, you will get a list of all ASP.NET Web Application project types. In this case, I select the MVC Web Application I created:
And there you have it, you are using a new or existing ASP.NET Web Application as a Web Role.
(Note that if you want to use the Service Hosting runtime APIs, you’ll have to add a reference to Microsoft.ServiceHosting.ServiceRuntime.dll yourself.)
When I hit F5, I get the behavior I expect, the MVC Application running on the Windows Azure Development Fabric.
One additional note: in order for the MVC assemblies to be included in your service package that you will upload to the cloud, make sure you set the copy local property to true for the MVC DLLs (More information here):
We hope this will make using different application types (like MVC, Dynamic Data and others) as well as using your existing ASP.NET applications easier. Let me know what you think!