Many of you may not even know this, but as part of the Windows Azure Tools for Microsoft Visual Studio, we ship a Role template called “CGI Web Role”.
Today, it’s a little hard to find (yes, I’m foreshadowing that this is about to change!) as you have to create a Cloud Service project first, then add/replace the Web Role with a CGI Web Role.
For example you could create a Blank Cloud Service project:
In Solution Explorer, right click on the Roles node in the Cloud Service project Add | New Web Role Project…
Select CGI Web Role:
Which adds an ASP.NET Web Application project tailored to be the configuration and files conduit for a FastCGI Application to your Cloud Service:
What is the purpose of the CGI Web Role?
Even though Visual Studio doesn’t support languages like PHP, there are reasons for you to be interested in using Visual Studio when building a FastCGI application that runs on Windows Azure:
Not to mention that Visual Studio really has a first class source editor and a lot of other features you’ll be able to make use of.
(Please see the Windows Azure SDK documentation and the FastCGI sample for more information on hosting a FastCGI application on Windows Azure.)
After you install the July 2009 CTP and create a new project via File | New Project | Cloud Service, you now have a single template “Cloud Service” instead of the 4 you had in the past.
Clicking on that brings up our new project creation dialog.
There are a couple of reasons we have this dialog:
You can add Web and Worker Roles to the Cloud Service solution, rename the projects and hit OK to create the Cloud Service. Try adding 2 Web Roles and 2 Worker Roles.
You’ll have a solution that matches:
Note that you’ll want to setup the port numbers for your input endpoints in the ServiceDefinition.csdef.
We auto-generate what we hope to be safe numbers but don’t know what your intention is for each of the Web Roles – at this point in time, a second or third Web Role cannot be assigned to a sub domain, they can only be differentiated by port.
When you hit F5, we’ll bring up a web browser instance for each of the Web Roles.
If you don’t want us to bring up a Web Browser instance for a given web role, right click on the associated Role under the Roles node and deselect “Launch Browser”.
Also note that when you close one web browser, your debugging session will end.
For more recent information on using ASP.NET MVC with Windows Azure please see this post.
If you’ve been following along, you’ll remember my post about using an existing ASP.NET Web Application as a Web Role. We’re now a little smarter in the tools and can allow you to associate any ASP.NET Web Application in the Cloud Service as a Web Role.
For example, I can create a Cloud Service with just a Worker role, right click on the Solution in Solution Explorer and select Add | New Project and select an ASP.NET Web Application from the Web folder.
This could be *any* ASP.NET Web Application, including derivatives of it like an MVC project, Dynamic Data etc.
For the sake of this demo, I’ll add an ASP.NET MVC Web Application:
I then right click on the Roles node in the Cloud Service project and select Add | Web Role Project in solution…
Now instead of just “Web Roles”, you will get a list of all ASP.NET Web Application project types. In this case, I select the MVC Web Application I created:
And there you have it, you are using a new or existing ASP.NET Web Application as a Web Role.
(Note that if you want to use the Service Hosting runtime APIs, you’ll have to add a reference to Microsoft.ServiceHosting.ServiceRuntime.dll yourself.)
When I hit F5, I get the behavior I expect, the MVC Application running on the Windows Azure Development Fabric.
One additional note: in order for the MVC assemblies to be included in your service package that you will upload to the cloud, make sure you set the copy local property to true for the MVC DLLs (More information here):
We hope this will make using different application types (like MVC, Dynamic Data and others) as well as using your existing ASP.NET applications easier. Let me know what you think!
I’m pleased to announce that we have released a new version of the Windows Azure Tools and SDK! (will take time to propogate, try the direct link to the download)
What’s New for the July 2009 CTP?
“Enhanced robustness and stability” means that we fixed some issues we’ve heard from customer feedback:
For more information on using the new features, please see the following posts:
Working with Multiple Web and Worker Roles
Associating an ASP.NET Web Application (including MVC) as a Web Role