Advertisment

Building cloud applications for Windows Azure

author-image
CIOL Bureau
Updated On
New Update
BANGALORE, INDIA: Windows Azure platform is created to help developers write, distribute and manage Web application and Web services on the Internet. Azure provides on-demand computation and storage services that allows Web applications to scale them on Internet simply by changing the configuration parameters. Azure is an operating system for the cloud, using which developers can host and manage their applications as services on Windows Azure platform.
Advertisment
Windows Azure supports both Microsoft and non-Microsoft languages and environments  -developers can use Ruby, PHP, and Python to develop Azure Services. Azure supports a seamless development experience and is well integrated with Visual Studio.
Advertisment
Setting up  development environment in Visual StudioYou can download the Azure SDK and Azure tools and use them in Visual Studio. In order to create an Azure application, the pre-requisite operating systems are Windows Vista with SP1, Windows Server 2008 or Windows 7. You would also need .NET framework 3.5 with SP1 installed. Additionally, the development machine should be configured with IIS 7 (with ASP.NET and WCF HTTP Activation). Also it requires Microsoft SQL Server (or express) 2005 or 2008.
To develop Windows Azure application you would need either of the following: MS Visual Studio 2008 SP1, MS Visual Studio 2010 Beta 1 or MS Visual Web Developer 2008 Express Edition with SP1.
Advertisment
Once you have the required IDE, you will need Azure SDK and Azure tools for Visual Studio to  start developing your first Azure application.
Advertisment
Clicking on 'File->New Project' in Visual Studio will display Project Template for creating Cloud Application.
Windows Azure Tools for MS Visual Studio extends Visual Studio 2008 and Visual Studio 2010 Beta 1 to enable creation, building, debugging, and running of applications on Azure. To obtain this SDK and the tools, go to www.microsoft .com/download and search for 'Windows azure tools'. The file to be downloaded is VSCloudService.exe that will install both Azure SDK as well as Azure tools in your Visual Studio Shell. Once you have installed the tools, you will see that a new project type has been added to your Visual Studio. See the image below.
Advertisment
A Cloud solution consists of two projects. Here, 'forPCQuest' and 'WebRole1' are two projects added to Visual Studio Solution file. Clicking on 'File->New Project' in Visual Studio will display Project Template for creating Cloud Application.
Advertisment
 
Creating Cloud application in Visual StudioCreating a new Cloud Service project in Visual Studio will create two projects for you in the solution (see second image). If you look into the Solution Explorer, the first project is (forPCQuest) where  application configuration setting for Cloud is stored. Other project is a simple ASP.NET web application (WebRole1). Service Definition (.cscdef) file in the first project is used to provision Web application 'as a Service' for cloud. To achieve this, the XML tag used is:
Advertisment
Once the Web Application is added as a service as mentioned above, we can set configuration settings for our Web Application in Service Configuration file (.cscfg). If you open Service Configuration file, you will see the following code:
 
This file describes what setting your web application will use when deployed on the cloud. Checkout the instances count setting, for example, that allows you to configure the scalability requirements. This is interesting to see how you can dynamically increase the load capacity of your web application on-demand. This is one of the promises that Windows Azure delivers.
Now, let's open our Web application (WebRole1) and make some changes in it. If we open Defualt.aspx file and add the line:


Welcome PC Quest Reader

In order to build our application, we can right click and select Build or directly select Publish option that will first build the application and then attempt to publish it (see the above image). If we select the publish option, it creates a 'publish' directory somewhere at the same place where the project source files are stored and creates two files. These files are 1. Service package file which has our Web Application in Cloud deployable format, and 2. Cloud Service Configuration file which consists of configuration settings for Cloud that our Web Application will use. Also, the Visual studio will automatically open browser and point to a URL https://windows. azure.com/Cloud/ Provisioning/Default.aspx where you can provision your small Cloud application that you have just built.
 A cloud application can be hosted on windows.azure.com. The first step is to define a URI on Internet so that your cloud application gets a Unique Internet address.
You may like to test your application locally on your machine before you deploy it to http://windows.azure.com. In order to do that, just select the Cloud project and hit 'Ctrl + F5'.  You will notice two small icons on the right side of your status bar ? these are 'Development Fabric'and 'Development Storage'. These are nothing but a local implement of Windows Azure with all the necessary services to deploy and test a Cloud application locally.
 
Preparing for deployment at windows.azure.comMicrosoft is hosting Windows Azure as a free service for people to host their Cloud applications at http://windows. azure.com . It requires you to first register on the site and thereafter a token for Windows Azure trial is sent to you in your email. Once you receive this token, you can create a blank Azure project on windows. azure. com. After a blank project is created, you need to add a 'Hosting Service' to your Azure project (see image 4)
 A cloud application is first deployed to 'Staging' environment, tested, and then moved on to 'Production' environment.
While creating a 'Hosted Service' you will be required to have a unique name by which your service will be identified on Internet. The full name of the service will be http://yourUniqueName. cloudapp.net
Uploading your Package and Cloud configuration file to Windows AzureIn the Hosted Service you just created, now you can deploy your files that you created using Visual Studio. You have to first deploy them on Staging before you can promote them to production.
Click on the Deploy button and  upload the files from 'update' directory.
 Type the URL of your Cloud Application in any browser and hit Enter. You will be able to see your first Cloud application running.
First your application is deployed to staging environment where you can do testing and verification. In staging environment, it allocates a temporary URL on web to work with. After you are satisfied with your application behavior in Staging, you can promote it to production. While you deploy your application to Staging or Production, please wait for few minutes before it shows a green 'started' icon in front of web role. Only after the 'started' status appears, you will be able to launch your application from the 'Web Site URL' links
You have successfully created and deployed your first Cloud application on Widows Azure. You can visit the URL: http://pcquest. cloudapp.net/ and see the same application deployed there. (See the last image)
Vivek Goyal, Developer Technology Specialist, Microsoft India
tech-news