I am learning Windows Azure so I can present a session at my local .NET User Group. Presenting is a good way to learn a new topic.
As I work my way through the material I am going to present, I have decided to blog about it as I go.
Windows Azure is Microsoft’s answer to Elastic Cloud Computing - the ability to run applications in a hosted Data Center, paying only for what you need, when you need. For example if I have a site that has a steady amount of traffic for most of the week, but one day a week I receive 2-3 times as much traffic, I do not want to have to pay for resources and bandwidth to serve the peak load every day. It would be much more economical to run with the resources I need for the rest of the week and just load extra resources when needed. This is what Elastic Cloud Computing does and Windows Azure is Microsoft’s solution to the problem.
My first topic is all about getting started.
First we need to install the Windows Azure Tools for Visual Studio. This package include both the Visual Studio Tools for working with Azure as well as the SDK (Software Development Kit) which also includes a local implementation of the Azure.
Browse to www.windowsazure.com or www.microsoft.com/windowsazure and you will be presented with the home page for Windows Azure.
Figure 1: The Windows Azure Home Page |
|
To obtain the Development Tools click on the “Get Tools and SDK” link on the right hand side.
Figure 2: The Download Page for Windows Azure Tools |
|
Click download to download the tools to your local machine (see Figure 2)
When you have downloaded, run the executable to install the tools and SDK.
Once installed you will be able to create a new “Windows Azure Cloud Service” project (see Figure 3). For my examples I will be using Visual Studio 2010, but if you are using Visual Studio 2008 the tools work in pretty much the same way.
Figure 3: Creating a new Azure Cloud Service Project in Visual Studio 2010 |
|
Once you have filled in the information for the Name of the Cloud Service Project and Solution and chosen where to save the files, you will be prompted to add Cloud Service projects (see Figure 4)
Figure 4: Adding a Web Role to the Solution |
|
You can add more than one project at once, but for this example we will click OK to add the Hello Cloud Service and ASP.NET Web Role.
Figure 5: The resulting solution in Solution Explorer |
|
The Add Cloud Service Wizard created two Visual Studio projects (see Figure 5).
- HelloCloudService – this project contains configuration information for Windows Azure
- HelloCloud – a standard ASP.NET 3.5 Web Application Project
Even though ASP.NET 4 was released earlier this week (April 12th, 2010), as of the time of writing Windows Azure only supports ASP.NET 3.5 (it is expected that .NET 4 support will come soon).
To complete our first (Hello Cloud) Application lets edit the Default.aspx page to display “Hello Cloud”.
Listing 1: The edited Default.aspx file |
1: <html xmlns="http://www.w3.org/1999/xhtml">
2: <head runat="server">
3: <title>Hello Cloud</title>
4: </head>
5: <body>
6: <form id="form1" runat="server">
7: <div>
8: Hello Cloud
9: </div>
10: </form>
11: </body>
12: </html>
|
Now we are ready to run our first Windows Azure Application. Ensure that the Cloud Service is the Start-Up project and, just like any Visual Studio project click F5 to run.
The Cloud Service will launch the Windows Azure Development Fabric and initialize the Development Storage service. By default, the Windows Azure Development Fabric assumes that the Development Storage should use the default instance of SQL Server Ex press ie .\SQLExpress. If you want to use SQL Server, as I did, there is a command-line tool in the Azure SDK (DSInit.exe) that you can use. Browse to [install disk]:\Program Files\Windows Azure SDK\v1.1\bin\devstore (the version number will vary depending on the version of the Azure SDK) and execute the command line – dsInit /sqlInstance:<NamedInstance> – using “.” for the default instance (Figure 6).
Figure 6: Configuring Development Storage for use on a default instance of SQL Server 2008
|
|
When you click F5, instead of the Visual Studio Web Development Server (aka Cassini) launching and displaying the Default.aspx page, the Windows Azure Development Fabric launches to display the page (Figure 7)
Figure 7: Hello Cloud running on the Windows Azure Development Fabric
|
|
Congratulations you have created your first Windows Azure Application. In the next part of this series we will spend a little time on how this all fits together. We will then look at how we make our applications scale.
714dc498-d613-4f6f-a919-963f2f1d2858|0|.0