共用方式為


Getting Started with Azure #1

Windows Azure is Microsoft’s cloud computing platform allowing deployment of .NET applications with flexible scaling. My colleague Paolo recently wrote a great introductory article for our Faculty Connection newsletter which outlines the fundamentals.

Over the coming months I will be writing a series of posts focussed on getting you started developing with Azure. In this first post I will walk you through setting up the development environment.

The development environment for Azure consists of Visual Studio and the Azure SDK. You can user either the free Visual Studio 2008 Web Developer Express Edition or a full version of Visual Studio 2008 (such as those available through MSDNAA and DreamSpark). For this article I will be using Windows 7 as my operating system but you can also use Vista SP1 and Windows Server 2008.

Once you have installed Visual Studio please update it to download SP1 which includes .NET 3.5 SP1 both of which are requirements for the Azure SDK. Finally, before installing the SDK you need to enable ASP.NET and WCF HTTP Activation. To do this on Windows Vista or 7 follow these steps:

1. From the Start menu, choose Control Panel | Programs | Programs and Features.

2. Click Turn Windows Features On or Off.

3. Under Microsoft .NET Framework 3.5.1, select Windows Communication Foundation HTTP Activation.

4. Under Internet Information Services, expand World Wide Web Services.

5. Under Application Development Features, select ASP.NET.

6. Under Common HTTP Features, choose Static Content.

7. Click OK to install the selected features.

You can now download and install the Azure SDK and the Azure Tools for Visual Studio. The Azure SDK provides a simulation of the cloud on your desktop so you can test applications locally and the Tools for Visual Studio include the Windows Azure project types.

We’re now set to develop our Azure web application, for this example we will build a simple ‘Hello World’ application but using the twist is that rather than running it as a single instance as you traditionally would we will fire it up with 5 instances.

First open Visual Studio, select ‘File>New>Project...’ From the ‘Project types’ box select Cloud Service and from the ‘Templates’ box select ‘Web Cloud Service’, enter a name for the project and click OK.

When the template loads you will notice in the ‘Solution Explorer’ we have a solution with two projects. The first project contains the cloud service which features two XML files containing the service configuration (.cscfg) and the service definition (.csdef). The second project is the web application itself where you will find a blank default.aspx file which is familiar in traditional ASP.NET development. For the purposes of this tutorial we will make a small change to the default.aspx file so double click it and in the left hand pane add the text ‘Hello World’ between the ‘<div>’ tags. You can now press F5 to setup the development fabric and deploy your application for local test.

Your application should then launch in your web browser and display ‘Hello World’. If you look in your system tray you should notice an icon displaying two gears, this represents the Azure Development Fabric. Right click the icon and select ‘Show Development Fabric UI’. In the interface you can expand the application we have just built and you will see that there is one instance running. A single instance is the default configuration for a cloud application but if we want to scale our application and run multiple instances it is a simple matter of changing the XML configuration file I mentioned earlier. To do this go back to Visual Studio, stop debugging and open the .cscfg file. In the left hand pane you should be able to see a tag containing ‘Instances count="1" ’, change the 1 to 5 and press F5 to rebuild your application. If you reopen the Development Fabric UI you will now see that there are 5 instances of our application running.

As you can see it is very easy to run up multiple instances of our application and this works exactly the same when you deploy your application to the cloud which I will cover in my next post on Azure.

Technorati Tags: Windows Azure,Visual Studio,Cloud Computing,.NET

Comments