Welcome to MSDN Blogs Sign in | Join | Help
ASP.Net MVC Projects running on Windows Azure

[Updated for ASP.Net MVC RC 2]

Before you get started with ASP.Net MVC and Windows Azure – please install this hotfix.

Strictly speaking, ASP.Net MVC projects are not supported on Windows Azure.  That is to say that we haven't spent the time to fully test all of the MVC scenarios when running on Windows Azure. 

That said, for the most part, they do work, just as long as you know what tweaks you need to make in order to get up and running.

I've attached a sample application that Phil and Eilon on the MVC team put together to help make it easier for you to get started.

I’ll walk through the changes:

1. Start by creating a Blank Cloud Service.  File –> New Project –> Visual C# –> Cloud Service –> Blank Cloud Service.  I call it MVCCloudService

image

2. Right click on the solution node in Solution Explorer and select “Add New Project”

image

3. In the Add New Project dialog, navigate to the Web node under Visual C# or Visual Basic and select the ASP.Net MVC Application (I call it MVCWebRole). 

image

4. In Solution Explorer, right click on MVCWebRole and select “Unload Project”

image

5. Right click again on MVCWebRole and select “Edit MVCWebRole.csproj”

image

6. Add <RoleType>Web</RoleType> to the top PropertyGroup in the project file.

<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
{. . .}
    <RoleType>Web</RoleType>

7. Reload the project, be sure to save the project file.

image 

8. If you want to use the Windows Azure runtime library, add a reference to Microsoft.ServiceHosting.ServiceRuntime.dll by right clicking on the References node and selecting “Add reference…”.  Scroll down in the .Net Tab and you’ll find it.

image

9. Right click on the Roles node in the MVCCloudService project and select Add –> Web Role Project in solution…

image

Select the MVCWebRole project.

image

10. Set Copy Local = true on the MVC DLLs:

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

These assemblies are not available when running on Windows Azure and need to be deployed with the Service Package.

Expand the References node in the MVCWebRole and right click on System.Web.Abstractions and select Properties.  Change “Copy Local” to true.  Repeat for the other DLLs

image

With these changes, the edit, build, debug, publish and deploy functionality will all work in Visual Studio with the Windows Azure Tools for Microsoft Visual Studio installed.

That said, it is still "use at your own risk".

Note: The sample has not been modified to use the Windows Azure ASP.Net provider (for example, the membership provider), stayed tuned.

The sample project is attached to this blog post.

Posted: Tuesday, October 28, 2008 9:59 PM by jnak
Attachment(s): MVCCloudService.zip

Comments

Cloud Computing Tools Team said:

Does ASP.Net MVC work on Windows Azure? Have a look at Jim's post: http://blogs.msdn.com/jnak/archive/2008/10/28/asp-net-mvc-projects-running-on-windows-azure.asp

# October 29, 2008 1:51 AM

Cloudy in Seattle said:

In my prior post that talked about the difference between the Cloud Service templates and the Role templates

# October 31, 2008 2:18 PM

Aaron Lerch said:

If you’ve purposefully been ignoring the announcements out of PDC, I don’t blame you one bit. Everybody

# November 1, 2008 1:15 AM

Cloudy in Seattle said:

Recently I posted about the Windows Live Tools Web Role Template that integrates with the Windows Azure

# November 1, 2008 1:32 PM

Brownie Points said:

Well it looks like there is significant buzz about Azure and other tech announced/demoed at PDC. Enabling

# November 3, 2008 8:12 PM

Heard in the Clouds said:

Well it looks like there is significant buzz about Azure and other tech announced/demoed at PDC. Enabling

# November 4, 2008 9:49 PM

Cloudy in Seattle said:

Were you wondering why the sample project I got from Phil attached to my post, ASP.Net MVC on Windows

# November 10, 2008 6:18 PM

DotNetShoutout said:

Thank you for submitting this cool story - Trackback from DotNetShoutout

# January 10, 2009 4:56 PM

mh415 said:

Is this advice still valid now that both Azure and ASP.NET MVC have been updated?  Is your sample project still the one to use for getting started with Azure + MVC?

# February 15, 2009 4:53 PM

mh415 said:

I'm trying out this attachment with the January version of Azure and the RC of MVC.NET.  Opening a view file in the project crashes VS.  Help?

# February 15, 2009 6:55 PM

jnak said:

The crash is due to a known issue in the CLR that affects more than just this scenario -- the CLR team is working on a patch.

The issue presents itself (or not) depending on order in which the MVC, ASP.Net and System.Core assemblies load - taking a different path through the product that loads these assemblies in a different order can resolve the problem.

Sorry for the inconvenience.

# February 15, 2009 7:05 PM

Cloudy in Seattle said:

I've received some comments as well as have been contacted by a couple of customers about an issue they

# February 15, 2009 7:33 PM

mh415 said:

Since MVC is now on RC2, I thought I'd modify a new project rather than use the download attached to this post which is for the pre-beta version of MVC.  Sorry to be dense, but I don't know how to follow your above instructions, probably because I'm new to .NET and VS.  Which file should be modified to add these properties?  I tried searching the pre-beta download for "PropertyGroup" to give me a clue, but the search came up empty.  

Also, should we start the modifications from a blank MVC application, or a blank Web Cloud Service?

# March 8, 2009 5:48 PM

jnak said:

mh415 -- I provided a better set of instructions so that will be a lot easier to follow.  HTH.

I also updated the attached sample for RC2.

# March 8, 2009 10:03 PM

Cloudy in Seattle said:

ASP.Net MVC RC2 released a few days back and I've already gotten a number of requests to update the MVC

# March 8, 2009 11:48 PM

Simpable said:

Jim Nakashima has updated his ASP.Net MVC Projects running on Windows Azure post to support ASP.Net MVC RC 2 .

# March 9, 2009 10:51 AM

DotNetKicks.com said:

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# March 9, 2009 2:21 PM

Cloudy in Seattle : ASP.Net MVC Projects running on Windows Azure - DotNetBurner said:

DotNetBurner.com - news and articles about .net DotNetBurner

# March 16, 2009 7:34 AM

mh415 said:

In step #9, I'm only given the option to add a "New Worker Role in Project".  The option for "Web role project in solution" is grayed out.  Perhaps this means I misunderstood what you did in step #6?

# March 21, 2009 4:07 AM

mh415 said:

Re: my last comments.  It must be because I messed up in step #1 and didn't create a blank cloud service.  I chose "Web Cloud Service".  That's what I get for coding after midnight.

# March 21, 2009 4:10 AM

zzeeshann said:

When I double Click on the View aspx file visual studio closes automatically.

# March 24, 2009 5:38 PM

jnak said:

@zzeeshann, please uninstall the tools, download and install the latest tools.  We did a refresh of the tools that should resolve your problem.  Let me know if it doesn't.

# March 25, 2009 12:41 AM

DiryBoy said:

开头(有点离题了,原谅!)之前我就像某人说的那样,I’mnotquiteacloudguy,但是后来看了各式各样的演示,认识了CloudProject的构成,以及Mix09里面...

# April 20, 2009 1:15 PM

DiryBoy said:

本文叙述了本人怎么将默认的 MVC 应用程序发布到云端,并给出了一些相关的文章和注意事项以及自己的想法。

# April 20, 2009 1:23 PM

DiryBoy said:

本文叙述了本人怎么将默认的 MVC 应用程序发布到云端,并给出了一些相关的文章和注意事项以及自己的想法。

# April 20, 2009 1:26 PM

Anthride said:

You are the greatest.

Now , I Can work wtth ASP.NET MVC on AZURE

Tank you

Anthride

# June 9, 2009 5:51 AM
Anonymous comments are disabled
Page view tracker