Saturday, May 7, 2011

Create and Deploy Windows Azure Application.

Well we have lots of Blog post which gives us how to deploy our .NET apps on Azure, but I just tried to describe it in my way using more Images which will give much clear understanding(a picture speaks thousand words!!!).

Ok, so to start with first you need to have Windows Azure Access, you can request for Trial licence here. Then for .NET developers will have to download the Azure SDK 1.4 (April 2011) using this link. And of course you need Visual Studio 2010 SP1, you can download it from here. Please note Windows Azure SDK is not compatible with Express editions of VS2010 IDE.

Now run the Visual Studio 2010 in elevated mode, i.e. you have to right click the Visual Studio 2010 icon in Program Files and Select “Run as Administrator”. Once you got the IDE you have to Select New Project and Select Cloud from the left menu, and Select Windows Azure Project from the right Selection menu. I am selecting this as C# project but you can select VB.NET too.


Name you application as you like, I named it as FirstWindowsAzure, and selected Ok button.


Once you say Ok, this will show another window providing you with different options to select from. I am not going into very depth of each and every Roles, just to give you brief idea,

A Windows Azure role is an individually scalable component running in the cloud where each instance of a role corresponds to a virtual machine (VM) instance.

There are two types of role:

  • A Web role is a Web application running on IIS. It is accessible via an HTTP or HTTPS endpoint.
  • A Worker role is a background processing application that runs arbitrary .NET code. It also has the ability to expose Internet-facing and internal endpoints.

We also have a special type of Role called as VM Role. You can get more details on MSDN Link about Architecture of Windows Azure Roles.

To keep it simple and focussed I have created a WebRole and named it as MyFirstApp. Once I say Ok my Solution looks something like as below.


It is easy to add or remove roles in the cloud service after project creation has completed. To add other roles to this cloud service, right-click on the Roles node in the cloud service and select Add -> New Web Role Project or Add -> New Worker Role Project. Selecting either of these options brings up the Add New Role dialog where you can choose which project template to use when adding the role.

You can add any ASP.NET Web Role project to the solution by right-clicking on the Roles node, selecting Add -> Web Role Project in the solution, and selecting the project to associate as a Web role.

To delete, simply select the role to delete and hit the Delete key. The project can then be removed.

Now coming back to my application. I am keeping all the default codes which was created by the designer and hit F5. Visual Studio will build your project, start the Development Fabric, initialize the Development Storage (if run for the first time), package the deployment, attach to all role instances, and then launch the browser pointing to the Web role.


You can see the notifications area of the taskbar shows the Development Fabric has started. The Development Fabric is a simulation environment that runs role instances on your machine in much the way they run in the real cloud.


Right-click on the Windows Azure notification icon in the taskbar and click on Show Compute Emulator UI. This will launch the Windows Azure Compute Emulator itself, which allows you to perform various operations on your deployments, such as viewing logs and restarting and deleting deployments. Notice that the Development Fabric contains a new deployment that hosts one Web role instance and one Worker role instance.


I hope up to this point you have not encountered any exceptions/errors. Now your sample  application is ready for deployment. If you have already got access to then you can open the site using your credentials. Once you logged in successfully you will get nice UI build on Silverlight 4.0 interface. This is the new UI, you can switch back the old one too if you like.


To start the deployment process first you have to Publish the FirstWindowsAzure using the following options (Create Service Package Only). This will create the Package and Service Configuration named named FirstWindowsAzure.cspkg and ServiceConfiguration.cscfg respectively in \bin\Debug\Publish directory.



Now in the Web Interface of Windows Azure Platform, Select New Hosted Service from the Top Menu Ribbon


This will Popup the menu as below.

You have to choose the Desired Subscription, Provide Name, URL Prefix, Region, Deployment options, Deployment Name, Package location and configuration file location.

Since the domain and is common for all the users prefix with the URL Prefix provided by you, so your prefix has to be unique and not taken by any other users. Select the Staging environment for testing purpose, Keep the Start after successful deployment checked. This will start your Service as soon as its get created. For Package location and Configuration files you have to Browse locally for the files FirstWindowsAzure.cspkg and ServiceConfiguration.cscfg respectively in \bin\Debug\Publish directory. If you enter the URL Prefix which is already taken then it will give you the following error.


Once you enter all the required information you can Click Ok in the popup. This will validate your information's which you have entered and may give you a warning, you can simply ignore this warning.


This will start creating your application. Once it finishes, your application is ready to browse and hosted in Cloud. Remember this process may take a while during this time don't refresh your browser.



Once your hosted service is hosted and started, the Azure service will generate a random id for staging environment, which can be used to browse your application remotely, as given below.



This is just the basics which I wanted to share in this Post, you can also refer to MSDN article Code Quick Start: Create and deploy an ASP.NET application in Windows Azure. Both post are very much similar. I just tried to give more pictorial representation of the same for much better understanding for those who are starting from scratch.

Note: For evaluation licence of Windows Azure you one limitation is you can create only one hosted services. So before winding up just to let you know how to delete the already created hosted services.

First you have to stop the Service you have created if any, once it stopped, you can see the Delete button gets enabled. Then you can comfortably delete the created service and create the new service.


Other very useful link :

Hope this helps.


Anonymous said...

Can we deploy our application using VS2010 IDE?

Brij Mohan said...

You can refer my POST : for the same.

Amit said...

Hello Brij,

We have an application made in VS 2008.Can we Deploy it on Windows Azure?
Can we install Windows Azure on XP sp3?

Brij Mohan said...

1. You can check this link : on the right hand menu, you can download the previous versions of SDK, may be 1.1 or before.
2. The Development Storage has no dependency on OS. The tools for building cloud apps have no dependency on the OS either but you have to use the newer OS to simulate the execution on Development Fabric for the preceeding reason.
Because the App Fabric Simulation environment is based on IIS 7 which comes only with Vista OS or later, so unfortunately you cannot do this on XP. You can check the System requirement here :
Alternatively theres a workaround to this is available, you can try this at your own risk :

Dot Net Developers said...

Its a good blog. Thanks for sharing these information.

Amol said...

Respected Sir,

I am getting "unable to connect to dfservice after running an mvc application. It shows "Compute Emulator is shutdown", "Storage Emulator is started".

Please help me to resolve this.

Thank You.

Post a Comment