Azure Basics - Say 'Hello' to the Cloud
page 3 of 7
by Shaun Eutsey
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 32241/ 92

Coding for Azure

Now, let's break down the solution that was just created. 

The first project in the solution is the HelloAzure project, this is made up of:

·         Roles Directory - Contains a list of the Roles included in the solution.  If there were a worker role another role file would be in the directory called HelloAzure_WorkerRole.

·         Roles\HelloAzure_WebRole - Ties HelloAzure to the HelloAzure_WebRole Project

·         ServiceConfiguration.cscfg - Sets the configuration settings for the project (If you are using table, blog or queue storage)

·         ServiceDefinition.csdef - This file defines the settings used in the .cscfg file.

This project is the main project with the hooks to Azure.  When you publish this project it creates the files that need to be uploaded to Azure for deployment.

The next project in the solution is the HelloAzure_WebRole.  This is where the web user interface will reside. 

Now, we want to actually do something in Azure.  Like I said before, this is going to be very basic; something to just get you acclimated to the Azure environment.

Open up default.asp to get started.  We'll need two controls for the purposes of this demo, a Label and a Button.

<asp:Label id="lblMessage" runat="server" text="" /><br />
<asp:Button id="btnSubmit" runat="server" text="Submit" />

Simple enough, now let us add a little functionality to the example.

First, when you get into the code behind, notice the references at the top, in VB you'll have the following:

Imports Microsoft.ServiceHosting.ServiceRuntime

Now let us take a look at the click subroutine.

Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
   Dim dt as DateTime = Now
   Dim sb As New StringBuilder("Hello, Azure, the Date is ")
   sb.Append(" and the time is ")
   lblMessage.Text = sb.ToString
End Sub

I used a string builder to look cool, but it really is overkill for what I am trying to accomplish.

We can now run this in the development fabric by hitting F5.

After it builds and starts the development fabric you are presented with a button called submit.  Due to the fact that we are all super intuitive and are compelled to click buttons called submit, click the button.

You will then see, something like:

Click it again, it updates, simple.  Looks like a regular, normal ASP.Net website.  That is the goal though, to host applications in the cloud.

The challenges of Azure come into being when you start working with Web Services and the storage mediums.

I'll enumerate some of the issues that my co-workers and I have run into at the end of the article.  What needs to be remembered is that Azure is in CTP.  The issues we've run into this week may not be their next week, so take all criticism for what it is intended, to  expose current issues that need worked on by the Azure team, not bashing of the technology.

View Entire Article

User Comments

Title: cannot see the log in Fabric UI   
Name: Euo
Date: 2009-09-08 1:38:08 AM
I can't see the log in Fabric UI created through 'RoleManager.WriteToLog()' ? What would I need to check?
Title: Azure Basics - Say 'Hello' to the Cloud   
Name: Jow Long
Date: 2009-05-14 4:29:17 AM
Great article

Product Spotlight
Product Spotlight 

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2022  |  Page Processed at 2022-09-27 2:06:56 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search