Silverlight Hack

Silverlight & related .NET technologies

About Me

Welcome to  This is a site where you can find many articles on Silverlight, Windows Phone 7 and .NET related technologies.  

My name is Bart Czernicki.  I have been working with computers since 1988 and have over 12 professional years in the IT field focusing on architecture, technology strategy and product management.  I currently work as a Sr. Software Architect at a large software development company.

Below is the cover of my new book that shows how Silverlight's unique RIA features can be applied to create next-generation business intelligence (BI 2.0) applications.

Silverlight 4 Business Intelligence Soft 


View Bart Czernickis profile on LinkedIn

NONE of the comments or opinions expressed here should be considered ofmy past or current employer(s).  The code provided is as-is without anyguarantees or warranties.

Step by step instructions to deploy ASP.NET MVC 3 to Windows Azure

Abstract:  This article will show you the steps to overcome the lack of  Visual Studio 2010/Azure SDK tooling to deploy ASP.NET MVC 3 as a web role to the Azure cloud.  As of the time this article was written, there are many articles out there that overcomplicate the steps and some are even outdated with the new Azure 1.4 SDK release.  This article will allow you to work with the full ASP.NET MVC 3 tooling.  This article will be relevant until Microsoft releases an update to the Visual Studio 2010 tooling for Azure (probably not until the Azure 1.5 SDK).  The Visual Studio 2010 project/source code is included below.

10/01/2011 Update: The latest Windows Azure SDK (September 2011 Update) now includes ASP.NET MVC 3 by default.  However, if you are interested in including ASP.NET MVC4 in Azure, these steps can be followed below (with some changes).

For example, this week a Microsoft employee Avkash Chauhan posted an article called "ASP.NET MVC3 Web Role Deployment in Windows Azure (SDK 1.4) - Detailed steps and Full Sample".  While the article is correct and the process outlined will work, it overcomplicates the steps necessary and there are some bugs in his solution (i.e. you do not get the MVC 3 tooling support, since it is a ASP.NET MVC 2 web role).

Deploying ASP.NET MVC 3 to Azure 1.4 should not include so many steps.


Steps to Deploy an ASP.NET MVC 3 web role to the Azure Cloud

The list below are the high level steps that that this article will follow.

  1. Create a new ASP.NET MVC 3 project
    • this can be an Internet or Empty application (or an existing ASP.NET MVC 3 project)
  2. Add a Windows Azure Cloud project
  3. Add the Azure Web Role components to the ASP.NET MVC 3 Project
  4. Add the ASP.NET MVC 3 Assemblies to the bin Folder
    • Deploying via the new Azure 1.4 start up tasks is another method
  5. Publish to Windows Azure
Note: You will need to have some experience with Windows Azure, since I do not cover publishing to the Azure cloud (creating certificates, management console, remote desktop etc.).  You will also need:
  • Visual Studio 2010 SP1
  • ASP.NET MVC 3 with tools update (Released in May 2011:
    • NuGet Package Manager
  • Azure 1.4 SDK installed
  • Active Windows Azure hosted service account (there is a promotion going on to receive Windows Azure for FREE until September 30th 2011, much better than the FREE 30 day trial if you just want to test things out or run a small blog:

1) Create a new ASP.NET MVC 3 Project

  1. Open Visual Studio 2010 (as an Administrator)
    • The Azure Cloud emulator needs to run in elevated privaledges
  2. Inside Visual Studio 2010, go to File -> New Project
    • Select "ASP.NET MVC 3 Web Application"
    • I named the project "AspNetMVC3DeployToAzure" *you can call it whatever you like)
    • Select "Internet Application" from the next dialog windo
      • Note that we will not be deploying the ASP.NET membership provider to SQL Azure (that will be for another time)
      • Just as long as you do not click Log On the application will function correctly
  3. If you build the application and debug it, you should see the generic ASP.NET MVC 3 startup screen

2) Add a Windows Azure Cloud Project

  1. In the Visual Studio 2010 Solution Explorer, right-click on the AspNetMvc4DeployToAzure solution and select Add -> New Project... 
  2. In the New Project Dialog, 
    • select "Cloud" from the Installed Templates
    • select the "Windows Azure Project"
    • I named the project "WindowsAzureAspNetMvc3Deploy" (you can name it whatever you prefer)
  3. In the next dialog, do NOT select any Windows Azure roles.  Leave it empy and click OK.


3) Add the Azure Web Role components to the ASP.NET MVC 3 Project

  1. In the Solution Explorer, highlight the ASP.NET MVC 3 project by clicking on it (this will tell Visual Studio the context you are in(
  2. In Visual Studio 2010 (this step will only work if the ASP.NET MVC 3 project is highlighted) go to Tools -> "Library Package Manager" -> "Add Library Package Reference..."
  3. Click "Online" to search the available packages Online
  4. Type in "windowsazure" all one word NO spaces
  5. Select the WindowsAzure.WebRole package and click Install.  Close the dialog after you are done (VS 2010 will ask you to reload the OK) The following changes will be made to the ASP.NET MVC 3 Project:
    • The package will add the necesary Windows Azure SDK 1.4 assemblies
    • The package will make changes necessary in the web.config for Windows Azure
    • The package will add a class that facilitates the new Azure SDK 1.4 change for performign a task when the role is deployed
  6. In the Solution Explorer, right-click on the Roles folder of the Windows Azure project. (this will tell our Windows Azure cloud project that we want to associate to the ASP.NET MVC 3 web role)
    • Select Add -> "Web Role Project in Solution..."
      • In the previous step, we ran the NuGet package that "converted" our traditional ASP.NET MVC 3 application to a web role by adding all the necessary assemblies.  Therefore, this step is telling Azure that we want to add an existing Web Role from our current solution.
  7. In the "Associate with Web Role" dialog, click OK (as we only have one available project)
  8. Your solution should now look like the screen shot below.
    • Note that we have additional Azure assemblies referenced in the ASP.NET MVC 3 project, we have a new class WebRole.cs, the web.config has Azure elements in it and inside the Azure cloud project we have a new web role added
  • You can now buiild and debug the solution.  If you did everything properly, this will launch the Windows Azure emulator and run the application.

4) Add the ASP.NET MVC 3 assemblies to the bin folder

Note: the emulator is just an emulator, so it is still utilizing resources on your workstation (i.e. ASP.NET MVC 3, Web Matrix assemblies).  In a real Azure Virtual Machine, you will ONLY have the basic .NET 4.0 assemblies (Microsoft only keeps the VMs to a bare minimum).  Therefore, we need to add those assemblies as part of the deployment into Azure VM.  

Note:  An alternative approach is to utilize the ASP.NET MVC 3 installer as a Azure  start up task (each time the VM is restarted or re-provisioned in case of an error or recovery process) or manually set each assembly to "Copy Local" to True.


  1. In the ASP.NET MVC 3 Tools Update Microsoft provides a very easy way to add all the required ASP.NET MVC 3 assemblies automatically for bin deployment. (thanks to Mike Brown from for pointing this out).
  2. Right-click on the ASPNetMvc3DeployToAzure MVC 3 project and select "Add Deployable Dependencies..."
  3. Select ASP.NET MVC checkbox and click OK
    • This will add the necessary ASP.NET MVC 3 dependency assemblies.
  4. You Solution Explorer in Visual Studio should look like this after adding the ASP.NET MVC 3 Dependency assemblies.
  5. :

5) Publish to Windows Azure


  1. Now you are ready to publish to Windows Azure.  Right-click on the Windows Azure project and select Publish.  Select your Azure credentials and storage information.
  • Note: If you do not have the Azure hosted service, storage or credentials set up you will have to create it.  Step by step instructions can be found here (Microsoft has better instructions than I will write on this)
    • I highly recommed you also select the "Enable Intellitrace for .NET 4 Roles".  This will show you any errors that you get if you don't have the proper ASP.NET MVC 3 assemblies installed.  Here is a good article on how you can view the IntelliTrace logs:  For exampe, if you forget to enable "Copy Local" to true for the System.Web.Mvc.dll the Azure publish process will cycle and you will not know why.
  • If you forget a certain assembly, you will also get an error like this (if you turn off custom errors in the web.config)

Visual Studio 2010 Source Code For Project

This source code for this project includes some minor changes unrelated to the steps above: (13.85 mb)

  • in the web.config I turned custom errors off, so you can see the errors if you receive any in deploying
  • I changed the Windows Azure instance to be "Extra Small", this way you get charged less playing with this and it is covered under the FREE Windows Azure trial
  • I changed the OS family to 2 in the Windows Azure configuration, so that we receive a Windows Server 2008 R2 VM...not sure why that is not the default (?) 
In this article, I hope you learned how to deploy an ASP.NET MVC 3 application to the Azure cloud easily.  The key things to remember are:
  • using the WindowsAzure.WebRole NuGet package to convert your ASP.NET MVC 3 application to a web role
  • Associating the ASP.NET MVC 3 project with the Windows Azure Cloud project
  • Using the new "Add Deployment Dependencies.." feature in the ASP.NET MVC 3 Tools Update to deploy all the required ASP.NET MVC 3 assemblies
In the future, Microsoft will no doubt make this process easier and include ASP.NET MVC 3 tooling for Azure deployment.
Posted: May 15 2011, 09:06 by Bart Czernicki | Comments (3) RSS comment feed |
  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: ASP.NET MVC | ASP.NET MVC | Azure | Azure
Social Bookmarks: E-mail | Kick it! | DZone it! |
blog comments powered by Disqus