Friday, May 22, 2009

Steps for Developing First Cloud Service with Azure


A Step-by-Step Approach for Developing your first Azure hosted service

Once you install the Azure SDK or Developer Tools for Azure, when you launch Visual Studio 2008, you should be able to a new project type called “Cloud Service” and within it the templates for Cloud Projects.

For the current scenario, we will use “Web Cloud Service” template as shown here

In the Solution Explorer, one can find 2 types of projects one is the FirstCloudApp_Webrole which is the standard ASP.Net Project and the other one is Cloud Service Project.

Now, create a standard ASP.Net label control in Default.aspx (design view) Go to the code view, and in the Page_Load event and put some code to display the label text

protected void Page_Load(object sender, EventArgs e)

{

this.Label1.Text = "Hello Azure, I'm on Cloud 9 - Dilip";

}

Go to CloudService Project, Open the ServiceConfiguration.cscfg file (This file defines the roles and also defines the number of instances per role.) Let’s make it to 2.


<Role name="WebRole">


<Instances count="2"/>


<ConfigurationSettings>


</ConfigurationSettings>


</Role>


Now, Let’s start the application in Debug Mode. (F5)

I encountered this error before it could go any further.

Solution -

Azure seems to be configured to SQL Express in CTP. This needs to be changed to SQL server 2005 connection string.
I did a change in DevelopmentStorage.exe.config located at C:\Program Files\Windows Azure SDK\v1.0\bin

connectionString="Data Source=localhost;Initial Catalog=DevelopmentStorageDb;Integrated Security=True"
providerName="System.Data.SqlClient" />

Since, I already have the full version of SQL Server 2005 on my system, I modified the above connection string to point it to the local instance of SQL Server.

Now, again Press F5 and this time the development storage got initialized successfully as shown here -

You will notice the Development Fabric icon on the status bar, shown below, Click on that and Development Fabric window opens


Development Fabric

· Once the devfabric starts, it expand the HelloAzure application in the devfabric and expand the WebRole

· This will cause the ASP.NET project to be compiled into a .NET assembly, just as normal. · However, since we have a Cloud Service project in our solution, this will then start the Windows Azure Development Fabric.

· The Development Fabric, or simple devfabric, is a simulated environment for developing and testing Windows Azure applications on your machine.

1 comment: