Why does it take so long to deploy an MVC project to Windows Azure?

While deploying an ASP.NET MVC application to Windows Azure, you may find out that it takes a very long time and it seems that it is cycling between starting/stopping/recycling and back again for several times.

If you have this problem, make sure that the MVC assembly references (DLLs) are part of the output of the project. The Windows Azure environment doesn't have MVC installed and there may be more missing references. When the role first starts, it immediately fails because it misses these dll's.

To resolve this, you need to add a couple of references and make sure that the following assemblies are set to "Copy Local = True":

  • Microsoft.Web.Infrastructure (I had to add this in my case)

  • Microsoft.IdentityModel (I had to add this in my case since I'm using Appfabric Access Control Service ACS)

  • System.Web.Helpers

  • System.Web.Mvc

  • System.Web.WebPages

  • System.Web.WebPages.Deployment

  • System.Web.Abstractions

  • System.Web.Razor

  • System.Web.WebPages.Razor

Redeploy the solution to Windows Azure and everything should work. If it doesn't work, try to remote desktop in the web role (and see if you can find entries in the event viewer) or enable customErrors in the web.config file.

 <system.web>
    <customErrors mode="Off" />

</system.web>