[For an expanded walkthrough about using an existing ASP.NET Web Application in a Cloud Service and migrating data to SQL Azure, please see this post: http://blogs.msdn.com/jnak/archive/2010/02/08/migrating-an-existing-asp-net-app-to-run-on-windows-azure.aspx. Updated info on using MVC with WIndows Azure in this post.]
One of the things which I’ve kind of covered with my MVC posts here and here is the steps for taking an existing ASP.Net Web Application project and getting it to run on Windows Azure as the Web Role.
Based on some of the forum questions I’ve seen, I figured this could use a post on its own.
I’ll start this off by making a new ASP.Net Web Application – note that there is currently a limitation in that only Web Applications (and not Web Sites) can be associated as Web Roles in the Windows Azure Tools for Visual Studio – if you really need to use a Web Site, you can do so with the Windows Azure SDK. If you have a Web Site and are willing to convert it to a Web Application, Visual Studio provides a conversion tool.
File –> New project brings up the new project dialog:
Where I’ll select an ASP.Net Web Application. (this works the same for all ASP.Net Web Application types)
This creates the Web Application project.
Right-click on the Web Application project and select “Unload project”.
Then edit the csproj file:
This will bring up the csproj (same process for VB) file in the XML editor in Visual Studio. To the top PropertyGroup, you need to add the RoleType element:
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> (. . .)
Save the project file (in this case the csproj).
A note on RoleType – our tools use the RoleType element in the project to filter out projects in the solution that can be associated as either a Web or Worker role. That is, when you right click on the roles node in the Cloud Service project and select to associate either the Web or Worker Role to a project in the solution – we use this element to give you a list of Web Role or Worker Role projects to choose from.
Now, create a new blank Cloud Service
After the Cloud Service project creation completes, in the Solution Explorer, add the Web Application project created above to the solution by right clicking on the solution and selection Add –> Existing Project…
and selecting the Web Application project.
Now add a Web role to the Cloud Service by selecting the Web Application. This is possible because the project property was added to the csproj file.
Select the Web Application:
You now have a Cloud Service that has a Web Role that points to the ASP.Net Web Application that was created above.
One final thing to do is, in the Web Application project, add a reference to the Microsoft.ServiceHosting.ServiceRuntime assembly.
This assembly contains the Fabric runtime APIs that you can call for logging, configuration and local storage.
And that’s it – hit F5 and you get debugging with your service running on the Development Fabric. Publish the Cloud Service and you get a Windows Azure Service Package.
If you are using the ASP.Net providers such as membership, role, profile or session state you can use the sample implementations that are in included in the SDK samples that use Cloud Storage. See this post for more information on how to set those up.
One of the bigger challenge you will have when trying to run an existing ASP.Net Web Application on Windows Azure is data.
Windows Azure provides Blob, Queue and Table storage but doesn’t have a SQL Server story yet (nor does the richer SQL Data Services). This means that you would have to rewrite your data access layer to use one of the Cloud Storage services.
You will also need to make sure that you don’t have assumptions about the state of the machine you are running on – in the Windows Azure world, your service could easily be moved to a new VM. Additionally – Windows Azure Cloud Services only run in a modified version of partial trust. If you make any calls that require Full Trust, those calls won’t work on Windows Azure.
Finally, the scale model on Windows Azure is to increase instances of both the Web role and Worker role. In order to make effective use of that model, it is quite likely that you’ll have to rework some of your code.
That’s the story for the January 2009 CTP. Keep in mind that we’re looking at how we can improve on this story and make it easier to move existing and new assets to and from Windows Azure.
For those of you that have been unfortunate enough to experience the VS crash when using the ASP.Net MVC RC in a Windows Azure Cloud Service project, I have good news!
The CLR team has distributed a hotfix. The KB Article number is 963676 and is posted at http://support.microsoft.com/?kbid=963676
The hotfix isn't specific to the MVC crash, it solves some crashes in the WPF Designer as well.
You can download the hotfix here: https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=16827&wa=wsignin1.0
[update 8/27/2010] - This hotfix has been superceded: http://support.microsoft.com/kb/981574/ and unfortunately it appears we no longer host it on Connect so you'll have to contact Microsoft support, see the KB article for more information.
I've received some comments as well as have been contacted by a couple of customers about an issue they have been seeing when using the MVC RC in a Windows Azure Cloud Service project in Visual Studio.
That is, when you are using the project/following the steps from this post or this post.
The problem is that Visual Studio crashes with a CLR fail fast when doing an operation such as opening or creating a new view using the MVC tools.
We gave a repro to the CLR team and they indicated that the crash is due to a known issue in the CLR that affects more than just this scenario.
A patch (from the CLR team) is in the works and I'll post when it becomes available.
Sorry for the inconvenience.
We just released 9 of 40 "How Do I" videos on using the Azure Services Platform - right now the videos target Windows Azure, .Net Services, and Live Services.
There are 5 videos related to Windows Azure:
I still recommend my Quick Lap Around the Tools video walkthrough for the Getting Started video though :)
Hope these are helpful to you. If they motivate you to download the tools and SDK, as I hope they will, they can be found here:
We recently deployed a new version of the Azure Services Development Portal. For those of you who have been having intermittent problems with the Portal, those problems should now be gone.
That said, to me one of the neatest things that has now been enabled is the ability to deploy a Service Package stored in Windows Azure blob storage.
If you have a large Service Package, you’ll really enjoy the fact that deployment from the Cloud is much faster than uploading from your local store.
We're really starting to get a solid set of resources out there for Windows Azure developers!
Not to mention all of the other resources we know about -- I'm sure there even more out there.
To add to the list, we have some upcoming Webcasts, along with a set of Virtual Labs and Podcasts available.
Explore the Azure Services Platform, an Internet-scale cloud services platform that provides an operating system and a set of developer services. Participate in a webcast, download a podcast, or step into a virtual lab to see how you can use the Azure Services individually or together, either to build new applications or to extend existing ones. The Azure Services Platform supports popular standards and protocols, including REST and SOAP, and provides a range of functionality to build applications that span from consumer Web to enterprise scenarios. Join us to discover more.
MSDN Webcast: Building Cloud Solutions with Microsoft .NET Services and the Azure Services Platform (Level 200)
Wednesday, February 25, 2009 11:00 A.M.–12:00 P.M. Pacific Time
MSDN Webcast: geekSpeak: Windows Azure Storage Services with John Croft (Level 200)
Wednesday, March 25, 2009 12:00 P.M.–1:00 P.M. Pacific Time
The Azure Services Evangelism team just released an update to the Azure Services Training Kit. This training kit was born out of the hands on labs at PDC '08 and is a useful way to ramp up on the Azure Services Platform.
The Azure Services Training Kit February update now includes the following content covering Windows Azure, .NET Services, SQL Services, and Live Services:
All of this content is available as an installable package on the Microsoft Download Center. You can download it here: http://go.microsoft.com/fwlink/?LinkID=130354
Probably a little silly for me to re-blog something that Mary-Jo Foley has posted, but I've had fun reading the Red Dog (internal name for Windows Azure) series she started this week.
She's doing a post a day for the week.
Somehow I got missed on the "Who's Who" list, I'll have to get that corrected :)