Building your application or service for the cloud lets you focus on building the right software using the skills you already have while someone else handles the details of infrastructure, hardware, and service management.

Windows Azure, Microsoft's platform for cloud-based applications, has been available in CTP form for the past year, and Visual Studio has supported the development of Windows Azure applications since the very first CTP release through an add-in known as Windows Azure Tools.  This add-in is available for VS 2008 via the Web Platform Installer.  Visual Studio 2010 Beta 2 has all the features you need to code, debug, and deploy your cloud service.

Windows Azure allows you to build robust production-quality applications that can be deployed, maintained and supported, and Windows Azure is accompanied by the November 2009 release of the add-in for Visual Studio, which lets you take advantage of the platform in the most efficient way.

Getting Started

Developing for Windows Azure is very similar to developing an ASP.NET application for IIS and Windows Server.  However, there are some differences, and Visual Studio makes it much easier to navigate those differences.

One of the first things that you'll notice when developing for the cloud with Visual Studio is the introduction of a top-level Cloud tab on the Get Started section of the redesigned Start Page.  This page offers up a wealth of resources that cover creating your first cloud application and contain resources that will continue to be useful again and again, such as links to the community areas for Windows Azure and regular updates about new features and services offered.

Start Page

You can create your own cloud service using the Cloud Service project template that is part of the Visual Studio 2010 (and Visual Web Developer 2010 Express) installation.  Click on the File | New | Project... menu, browse to either  the Visual Basic and Visual C# nodes, and select the Cloud Service node that contains a project template called "Enable Windows Azure Tools".

New Project

This template, new in Beta 2, makes it very easy to get the latest tools for developing Windows Azure services.  After creating the project, the template will direct you to download the Windows Azure Tools in order to continue.  This guarantees that you'll be using the latest version of the tools that support the latest version of Windows Azure.

Download Tools

After installing the tools, the New Project dialog will provide an option to create a Windows Azure Cloud Service.  Visual Studio now supports creating, editing, building, debugging and deploying these services.

To create a new project, use the File | New | Project... menu item to bring up the New Project Dialog and select "Windows Azure Cloud Service" under the Visual Basic or Visual C# nodes.  This will bring up a dialog that can be used to add Windows Azure Role projects to your cloud service.

New Cloud Service Project

One of the unique aspects of Windows Azure is the ability to individually scale work across any number of instances.  Windows Azure segments "components" into Roles.  A Role is an individually scalable component running in the cloud where each instance of a Role corresponds to a virtual machine instance.  There are two types of Roles:

  • Web Role - a web application running on IIS that is accessible via an HTTP and/or HTTPS endpoint.
  • Worker Role - a background processing application that runs arbitrary .NET code. It also has the ability to expose internet-facing and internal endpoints.

There are multiple template options for each type of Role you wish to add.  For example, ASP.NET Web applications, ASP.NET MVC 2 and WCF Service Application templates are available to create a Web Role.  Add one or more Roles to your cloud service and click OK to create the solution and projects.

Roles

After you've created the service, your solution has several projects in it.  One of these is the Cloud Service project which contains all of the configuration information needed by Windows Azure in order to run your service and also provides the ability to add or remove Roles after project creation.

Right-clicking on the role associations under the Roles node and selecting "Properties..." will bring up a configuration page that makes it easy to set up each Role.

Role configuration

Getting It Just Right

One of the key benefits of using Visual Studio 2010 for developing Windows Azure Cloud Services is the simulation environment on which you can test, debug, and run your service completely locally without requiring a Windows Azure Account.  This simulation includes the development fabric, which will run your cloud service the same way it runs in the cloud, and the development storage, which runs the Windows Azure storage on your machine.  With the development fabric and storage, you can develop, test, and refine your cloud services offline.

When running in the development fabric you can use all of Visual Studio's powerful debugging features, including seamless debugging across different roles and role instances.  Below, a debugging session allows you to step through the execution of a web role.

Debug Azure Projects

Deploying to the Cloud

Once you are ready to move your application to the cloud, Visual Studio provides a publish step that packages your cloud service into a deployable Windows Azure format, then you can deploy your cloud service using the Windows Azure Developer Portal.

To learn more about all of this, please visit the Cloudy in Seattle and Cloud Tools blogs.

Namaste!