25 February 2009 ASP.NET, Azure, Cloud, Cloud Computing, HowTo, Web Role, Windows Azure Robert Muehsig

imageIn my last blogpost I talked about different cloud computing providers, like Google, Amazon and Microsoft.

Today I want to describe Windows Azure more and show you how to use the Windows Azure CTP and how to publish a "Hello World" app in the "cloud".

Azure Service Platform 
The Azure Service Platform use "Windows Azure" as it´s core:

image

Azure offers basic functionality, like resource sharing, monitoring and so on. You can host Web- or- Worker-Processes on it or use it as blob or table storage.
Everything on Azure can be accessed via REST interfaces.

Services on Azure
Microsoft itself build some services on top of Azure:

Information about Windows Azure
To learn more about Azure I recommend you to have a look at these videos:

(Even if this video player destroy the blog design - it´s worth ;))

Let´s start! 
Now have a look at the real Azure system. The whole Azure thing is currently only a CTP, but should be released at the end of the year.
My first application will be a "Hello-World" app (yeah, I know, this example sucks ;) )

Step 1: SDKs + Access Key
You can find the SDKs on the Windows Azure website (www.azure.com) and download it without having an access key. 

  • Windows Azure SDK (help files, concepts)
  • Windows Azure Tools for Microsoft Visual Studio (dev environment)

You need the access key to upload projects to Azure. Register on MS Connect to get an access key.
All services (SQL Data, .NET Services...) needs a specific code.

Step 2: Create Web Cloud Service Project
After the installation of the "Windows Azure Tools for MS VS" you will see a new category "Cloud Services" - we want to create a "Web Cloud Service" project:

image

Visual Studio creates two projects in your solution:

image

  • "WindowsAzureHello":
    • Contains configs for the "Cloud"
  • "WindowsAzureHello_WebRole":
    • A standard ASP.NET project

Step 3: First steps with the cloud-debugging environment / "Development Fabric"
If you hit F5, several processes will start. The development storage creates a SQL server database on your local SQL server (download SQL Express). The development storage simulate the Azure database:

image 

image

A look inside the DevelopmentStorageDb:

image

You should see a new icon in your Windows Tray: image

This is the "Development Fabric", which simulate the hosting environment of Azure:

image

image

Step 4: Add "Hello World" to your ASP.NET page
I add these lines to my default.aspx page:

<form id="form1" runat="server">
    <div>
        Hello World @ Code Inside Blog <br />
        http://code-inside.de
    </div>
    </form>

Step 5: Publish cloud service
In this step we publish your "WindowsAzureHello"-project. Just "publish" it via the context menu and you should get these two files:

image

Now *right click* on your "WindowsAzureHello" project and get the context menu with two additional buttons and go to the portal:

image 

Step 6: Create a Hosted Service on Windows Azure
Now create a "Hosted Service" project on the Azure Service page:

image

Type the name of your project and type a (sub)-domain:

image

After your project is created, you see this website:

image

"Production" is your live app and "Staging" is just to test your app. At first you have to deploy your app on the "Staging" environment.

Step 8: Staging deployment
Select the two files, which we created in step 5 and upload it. After the upload processs is finished, the package will be deployed to the staging environment.

image

image

If this process finished you should see this:

image

Now you can click on the URL and test your app - here is my demo-app:

image

Step 8: Move it to "Production"
If you want to move your app to the "Product"-environment, just click on that button:

image

... and now the app is live under your own subdomain (remember: this is just a CTP) :

image

You can see my demo web page live at: Azure Link

Fast track:
This maybe sounds difficult, but it just takes 3 minutes:

Result:
The Visual Studio tools are great and I´m really interested in the future of Azure (and the pricing ;) ). You can now play with Windows Azure and don´t need to relearn everything from the ground.
But, of course, you have to be careful with session handling, because your application can run on many different maschines and each request goes to another maschine.


Written by Robert Muehsig

Software Developer - from Dresden, Germany, now living & working in Switzerland. Microsoft MVP & Web Geek.
Other Projects: KnowYourStack.com | ExpensiveMeeting | EinKofferVollerReisen.de

If you like the content and want to support me you could buy me a beer or a coffee via Litecoin or Bitcoin - thanks for reading!