Install and Create a Windows Azure Application in VS 2010
To install the Windows Azure Tools, on the menu bar,
choose File – New – Project. From Installed Templates choose
either the Visual Basic or Visual C# node, and then choose the Cloud node
that contains a project template named Enable Windows Azure Tools.
To download the tools, choose the OK button.
After the successful installation A
Windows Azure Project tab is displays instead of Enable
Windows Azure Tools.
A windows azure application
consists of roles that perform the actions required by the application. When you
publish your application to Windows Azure, each role is run on a virtual machine
in the cloud.
Create a Windows Azure Application:
Start Visual Studio 2010 as an administrator.
To create a Windows Azure project, on the menu bar, choose
File – New –
Choose the Cloud template from the
Choose Windows Azure project and
enter the name of the project.
To add a web role to the solution, choose ASP.NET Web Role and then
choose the right arrow. You can add multiple web and worker roles to your
Windows Azure solution.
The roles are displayed in the Windows Azure solution pane of the dialog
You now have a solution with the following two projects:
Windows Azure project
Web role that is an ASP.NET web application
The Solution explorer view will look similar to the following
Now to add the code in the Web role project
Open Default.aspx file and choose
View Designer from the context menu.
Open toolbox (Ctrl + Alt + X) and add a new button in the form.
To add a click handler for the button, double click the button that you added in
Add the namespaces given below:
On the click of the button add the following code given below:
// Setup the connection to Windows Azure Storage
var storageAccount = CloudStorageAccount.Parse (
var blobClient =
// Get and create the container
var blobContainer =
// upload a text blob
var blob =
blob.UploadText("Hello Windows Azure");
// log a message that can be viewed in the
diagnostics tables called
System.Diagnostics.Trace.WriteLine("Added blob to Windows Azure Storage");
The above accomplish the tasks given below:
Create a CloudStorageAccount instance from a connection
string in the configuration settings
Create a blob container
Upload a text blob to that container
Add a diagnostics message for a web role
Add code to set up the diagnostics monitor to transfer
the logs every second and start the monitor. The diagnostics monitor uses a
connection string that is added when you create the Windows Azure project. The
following code must be added at the beginning of the
OnStart method in
DiagnosticMonitorConfiguration diagObj =
//Set the service to transfer logs every second to the storage account
diagObj.Logs.ScheduledTransferPeriod = TimeSpan.FromSeconds(1);
//Start Diagnostics Monitor with the new storage account configuration
Build and Debug your application
To build the project, open the shortcut menu for the
Windows Azure project and then choose Build.
To see the build output, open the shortcut menu for the
Windows Azure project and then choose Open Folder in Windows Explorer. Go
to the bin\debug directory to view
the build output.
To modify settings, choose a role under the Roles
node for your Windows Azure project in Solution Explorer, open the shortcut menu
for the role and choose Properties.
This will display the property pages for the web role.
Every role-level element and attribute in the service definition and service
configuration files can be edited using the property pages.
To configure Visual Studio to use the local storage
emulator when you run or debug your Windows Azure application, you must add the
connection string that you used in the button click event handler. Use the
following steps to do this:
On the Settings tab choose the Add Setting
In the Name text box, type MyConnectionString.
In the Type combo box, choose Connection String.
Choose the ellipsis in the Value text box. The
Storage Account Connection String dialog box is displayed. Choose Use the
Windows Azure storage emulator and then choose the OK button.
On the toolbar, choose the Save icon.
To Debug the Windows Azure Project
On the menu bar, choose Debug, Start Debugging
The storage emulator and the compute emulator for Visual
Studio are started. These emulators enable you to run and debug your Windows
Azure application locally before you publish it to Windows Azure.
To manage your local deployments, open the shortcut menu
for the Windows Azure icon in the notification area and then choose Show
Compute Emulator UI.
The Windows Azure Compute Emulator is displayed.
Choose WebRole1 to display the instances of the
web role, as shown in the following illustration. Choose a specific instance to
view only that individual instance.
To view the data that you added to the blob, on the menu
bar choose View, Server Explorer. Open the Windows Azure Storage
node in the tree, and then choose the Development, Blobs node.
Double-click the quicklap node, as displayed in the following
The data in the blob is displayed in the quicklab
are using the storage emulator, open the shortcut menu for the Windows Azure
icon in the notification area and then choose Show Storage Emulator UI to
bring up the following dialog, which will allow you to control the running
storage services as well as reset all data.
After reading this article you
can easily create and build your first windows azure application.