Quick Lap around the Windows Azure Tools for Microsoft Visual Studio Home
Quick Lap around the Windows Azure Tools for Microsoft Visual Studio

Author: Jim Nakashima

Windows Azure Tools for Microsoft Visual Studio extend Visual Studio to enable the creation, configuration, building, debugging, running and packaging of scalable services on Windows Azure.

This walkthrough will guide you through using the Windows Azure Tools to create a new Windows Azure Cloud Service, running and debugging it locally, and preparing a service package to deploy to Windows Azure.

Installing the Windows Azure Tools for Microsoft Visual Studio 2010 Beta 2

Click on the File | New | Project… menu, browse to either  the Visual Basic and Visual C# nodes, and select the Cloud Service node that contains a project template called “Enable Windows Azure Tools”

http://blogs.msdn.com/blogfiles/jnak/WindowsLiveWriter/WindowsAzureToolsforMicrosoftVisualStudi_FB99/image_4.png

After creating the project, the template will direct you to download the Windows Azure Tools in order to continue.  This guarantees that you’ll be using the latest version of the tools and SDK that support the latest version of Windows Azure.

Note: Windows Azure Tools requires IIS7, to install IIS7 use the Microsoft Web Platform Installer.

Installing the Windows Azure Tools for Microsoft Visual Studio 2008

Use the Microsoft Web Platform Installer to install the Windows Azure Tools for Microsoft Visual Studio 2008 and the IIS7 pre-requisite.

Creating a new Cloud Service

Start Visual Studio 2008 or Visual Studio 2010 Beta 2 as an administrator.

Create a new project.  (File | New | Project)

In the C# and VB project templates notice a new group called “Cloud Service” and select the “Windows Azure Cloud Service” project template

Give the project a name and hit OK.

Add a Web Role to the solution by selecting the “ASP.NET Web Role” item and clicking the right arrow.

newproj.jpg

You can add multiple Web and Worker roles to your Cloud Service solution.

Note: ASP.NET MVC 2 Web Roles and Visual F# Worker roles are only available in Visual Studio 2010.

Rename “WebRole1” to “MyWebRole” by clicking on the edit button on the right side of the item (will appear on mouse over) and click “OK”.

You should have a solution with two projects

  • A Cloud Service project
  • A Web Role which is an ASP.NET Web Application

The Solution Explorer will look like this:

solutionexplorer.png

Modify the web role project

Go to Default.aspx and switch to design view.

Add a heading: “Quick Lap around the tools”

Open the Toolbox and double click a Button to add a button to the page.  Double click the Button on the page to add an event handler.

addbuttonandevent.jpg

In the Event Handler, write a trace message using the System.Diagnostics API.  A Windows Azure trace listener is setup in the web.config by default in the project.

protected void Button1_Click(object sender, EventArgs e)
{
System.Diagnostics.Trace.WriteLine("Doing my lap around the tools and clicking the button");
}

Add a breakpoint to the line of code you just added in the Button Click Event Handler.

Building and Debugging the Cloud Service

Build the project by right clicking on  the Cloud Service project and selecting “Build”.

Interested in the build output? Right click the Cloud Service project and select “Open Folder in Windows Explorer”. Drill into the bin\debug directory to see the build output.  The .csx folder is a version of the service package that runs on the Windows Azure Development Fabric.

openfolder.jpg

Modify the number of instances to run.

Select a Role under the Roles node in the Solution Explorer, right click and select “Properties”.

roleproperties.jpg

This will bring up a tab window you can use to edit the service definition and service configuration sections for MyWebRole.

Every role level element and attribute in the service definition and service configuration files can be edited using this tab document window.

SMUI.jpg

Change the instance count from 1 to 2.

Note that the current limitation for the number of instances of each Role on Windows Azure in the Cloud is 2 per Role.

Debug the project

Select Debug -> Start Debugging (F5).

Note that a Windows Azure icon is available in the system tray that allows you to show the Development Fabric UI, Development Storage UI or to Shutdown those services.

showdevfabric.jpg

If you click “Show Development Fabric UI” the following window will be brought up that will give you additional control over your running Deployments and a view of their logging.

The trace message you log in the button push will show up in the log window for the instance that services the request as well as the output window in Visual Studio.

devfabric.jpg

If this is your first time using Development Storage, the Development Storage initialization dialog will come up:

DevStorageInit.jpg

Hit “OK” to dismiss.

IE will start up automatically pointing to your web site. The full address will be similar to http://127.0.0.1:81/default.aspx.

When you click the button, you will hit the breakpoint that you set in the debugger.

Look at the Development Fabric UI to see your message in the trace log.

Note that there are 2 instances because we set the instance count to ‘2’ for the role and any one of the instances could process the request.

log.jpg

If you are using the development storage service, you can right click on the Windows Azure tray icon and select “Show Development Storage UI” to bring up the following dialog which will allow you to control the running storage services as well as reset the data.

devstorage.jpg

Publishing the Cloud Service

Create the Service Package (cspkg) by right clicking on the Cloud Service project node and selecting “Publish”.

publish.jpg

Explorer will open to the folder containing the Service Configuration file and Service Package (.cspkg).  This file along with the Service Configuration file (cscfg) are the files you upload via the Windows Azure Developer Portal to run your application on Windows Azure.

A browser window will open to the Windows Azure Developer Portal where you can upload and deploy your service. (See Deploying a Service on Windows Azure for more information)

This completes the Quick Lap around the Windows Azure Tools for Microsoft Visual Studio.

© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View