So the first question is can I run an ASP.Net MVC3 WebRole on Windows Azure? The short answer is yes. The long answer is, well long. First off the tooling in Visual Studio 2010 does not directly support creating an ASP.Net MVC3 Webrole (pre SP1 at least, I haven’t beenable to install the SP yet so I can’t comment on the support with that installed, but I hear it will get better), so you have to do it manually.
To get things set up was pretty straight forward, just create your new ASP.Net MVC3 web application,
and then add a new Windows Azure Project to the solution.
Now you will have to wire up the web role in your Azure Project. To do this right-click on the Roles folder under your Azure Project and select Add | Web Role Project In Solution and select your project.
Assuming that you have done some work in your ASP.Net MVC3 Project and it is working and ready to deploy there is one more item you’ll need to address. The Window Azure Hosted Services will not by default have all the assemblies you need to run your site. To get around this you have a couple of options. The way I did it was to make sure I had references to these assemblies (you may not since MVC apparently dynamically loads some of them at run time), and then for each one I went to properties and set CopyLocal to True.
Here is the list of assemblies I had to add.
- System.Web.Mvc
- Microsoft.Web.Infrastructure
- System.Web.Razor
- System.Web.WebPages
- System.Web.WebPages.Razor
- System.Web.Helpers
- System.Web.WebPages.Deployment
Your list may be slightly different. If you miss one you will get a “Yellow Screen of Death” .
Just add that assembly to your list and try again…
Good Luck!