Associating an ASP.NET Web Application (including MVC) as a Web Role

Associating an ASP.NET Web Application (including MVC) as a Web Role

Rate This
  • Comments 1

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. 

image

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:

image 

I then right click on the Roles node in the Cloud Service project and select Add | Web Role Project in solution…

image

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:

image

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.)

image

When I hit F5, I get the behavior I expect, the MVC Application running on the Windows Azure Development Fabric.

image

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):

  • System.Web.Abstractions
  • System.Web.Mvc
  • System.Web.Routing

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!

Leave a Comment
  • Please add 7 and 8 and type the answer here:
  • Post
  • That's great...the trick I was doing before was manually editing the project file to add the <RoleType> element. I think the new way is better.

Page 1 of 1 (1 items)