Building your first Azure Application (Part 1)

It's been a year now since the Windows Azure Platform, the cloud platform offered by Microsoft, became commercially available.  If you develop software and you still don't know how to build an application for Windows Azure, perhaps it's the right time to learn how to do it.  In this article, I will show you how to create a simple ASP.NET application that will run on Azure.


To develop Azure applications, your computer must be running either Windows Vista SP2, Windows 7 Home Premium, Windows Server 2008 SP2, or higher editions.  You also need to have Visual Studio 2008/2010 and Windows Azure Tools and SDK 1.3 installed on your system.  The Windows Azure Tools and SDK provides project templates for creating Azure applications.  It also provides tools that let you simulate the cloud environment on your local machine.

If you don't have Visual Studio, you can just use the free Visual Web Developer Express Edition.  You can get the Windows Azure Tools and SDK for free from the Windows Azure website.

Creating the cloud project

After you have installed the necessary tools on your system, just follow the steps listed below to create a hello-world type project.

1. Start Visual Studio as an administrator.  This is usually done by right-clicking on the program shortcut or program exe file and selecting "Run as administrator" from the context menu.


2. Create a new project in Visual Studio.  Use the Cloud service template in creating the project and name it as HelloAzure.

When you use the cloud service template, Visual Studio will add a Cloud service project to your solution.  The cloud service project serves as a wrapper that enables other projects to run in Azure.  These other projects are called hosted role projects and you will have to add them to the cloud service project.

3. Add roles to the project.  There are many role projects that you can add to the cloud service, but for our purpose, we will just add a webrole project which is essentially an ASP.NET application running on the cloud.  To add a webrole to the cloud service, just select from the left list and add to the right list by clicking the right arrow button.  The default name for the webrole is WebRole1 but you can change this to whatever you want. 

Pressing the OK button will create a solution containing two projects - the cloud service project named HelloAzure and the webrole project named WebRole1.

The webrole project

As I mentioned earlier, the webrole project is essentially an ASP.NET application.  Aside from the ASPX pages shown in the above screenshot, it can also include HTML pages, ASMX or WCF services, images and other resource files. The difference with on-premise or non-Azure ASP.NET application is that it holds reference to the Windows Azure runtime assembly and its web.config file is configured for Azure.  By default, it also contains a WebRole.cs that holds a class that inherits from the RoleEntryPoint - an Azure runtime class that provides callbacks to initialize, run, and stop instances of the role.

The cloud service project

In the above screenshot of the solution explorer, you will see that the HelloAzure cloud service project includes WebRole1 in its list of Roles.  Additional roles can be added to cloud service projects but we will cover that in future articles.  The cloud service project includes two files (ServiceConfiguration.cscfg, ServiceDefinition.csdef) that contain information on how the roles are hosted in the cloud.   This configuration information may also include connection strings that are used in accessing tables and blobs stored on Azure Storage accounts.

That's it for now.  In part two of this article, I will show you how to debug the application on your local machine and how to use the tools included with Windows Azure Tools and SDK.



Add new comment