Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Technical Articles
 Deploying a Hosted Service on Windo...
Deploying a Service on Windows Azure

Author: Jim Nakashima

Prerequisites

This walkthrough assumes you have done the Quick Lap Around the Windows Azure Tools for Microsoft Visual Studio and have a Cloud Service project working locally on the Developer Fabric and Developer Storage running from Visual Studio.

It also assumes that you have access (a token to redeem) to create both Storage Accounts and Hosted Services. See the Azure Services Platform site for more information.

Workflow

A good process to follow when moving a locally development Cloud Service to run on Windows Azure is to:

  • Get your service running locally
  • Run your service locally in the Development Fabric using a Windows Azure Storage Account
  • Run your service on Windows Azure using a Windows Azure Storage Account.

Workflow

Moving from Developer Storage to a Windows Azure Storage Account

While running your application on your local machine in the Development Fabric, change your Cloud Service to work against a Windows Azure Storage account.  This involves two steps:

  • Get a storage account
  • Make the configuration changes to run your Cloud Service against your storage account.

This is a great way to ensure that your Cloud Service will run when hosted on Windows Azure.

Creating a Storage Account

Navigate to the Azure Services Developer Portal and sign in with your Live ID.

From the Portal page, you can select “New Project” and click on “Storage Account”.

Create project

Fill in a friendly name for the storage account (this is not the Service/Domain Name – you will be prompted for that on the next page).  Optionally enter a project description.

Project properties

Then fill in the service/domain name on the next page. 

Storage account

You’ll get a summary for your storage account:

Storage account summary 

Configuration Changes to use Windows Azure Storage

When using the StorageAccountInfo type from the StorageClient sample in the Windows Azure SDK, you will have settings in one of your configuration files (Service Configuration cscfg or web.config) that you will want to update to run against Windows Azure.

From the summary page for you Cloud Storage, you can find the end point and access key that you use to modify those configuration files.

 Update the AccountName to the Service/Domain Name you entered.  This is the first part of your domain, tablesamplestorage (all lower case) in the example above.

Update the AccountSharedKey to be the Primary Access Key that you got back on your summary page.

Note: The Secondary Access Key provides the same access to your storage account as the Primary Access Key and is generated as a backup should your Primary Access Key get compromised.  You can also regenerate the keys if necessary.

Note: The Endpoints listed on the summary screen are not the URLs that you will use to access the storage services if you are using the StorageAccountInfo type in the StorageClient library in the Windows Azure SDK samples.  Please see the table below.

Here’s an example of the update Service Configuration file:

      <Setting name="AccountName" value="tablesamplestorage"/>

      <Setting name="AccountSharedKey" value="9OrFugcDnR1vbzzcIgrjJE3MsWzr/z2xZrf/6yhEQHF7c53KFJzfvRmbHv2vUF9hAliOmJWAoDFNu7nkv+RuJw=="/>

      <Setting name="TableStorageEndpoint" value="http:// table.core.windows.net"/>

End Point

Local Development Storage

Using the Windows Azure storage via StorageAccountInfo sample type

Using the Windows Azure Rest interfaces directly

Blob Storage

http://127.0.0.1:10000/

http://blob.core.windows.net

http://tablesamplestorage.blob.core.windows.net

Queue

http://127.0.0.1:10001/

http://queue.core.windows.net

http://tablesamplestorage.queue.core.windows.net

Table Storage

http://127.0.0.1:10002/

http://table.core.windows.net

http://tablesamplestorage.table.core.windows.net

Debug your Cloud Service Locally Running against Windows Azure Storage

Hit F5 to debug your Cloud Service and ensure that everything works correctly against Windows Azure Storage.

Once you have everything working in that configuration, you are ready to deploy to the Windows Azure!

Create a Hosted Service

Navigate to the Azure Services Developer Portal and sign in with your Live ID.

Click on “New Project” in the upper left hand corner, click on “Hosted Services”:

Create Hosted

This will take you to a page where you can specify the project name and description.  Note that on this screen, the project name is a friendly name used by the Developer Portal.

Hosted properties

After clicking next, you will be prompted to select a domain name for your Hosted Service project.

Hosted domain

After the project is created, you will be taken to a summary page for your project.  On this page, you will see the Application ID, Domain, Return URL, Secret Key, buttons to deploy your project and the status of your deployment.

Hosted summary

Setting the API Key in Visual Studio

Copy the Application ID and enter it in the Cloud Service Project Properties of your Cloud Service project:

Apikey

Portal properties

When you use the Publish command (Build -> Publish or Right click on the Cloud Service Project and select Publish) in Visual Studio, having the Application ID set will result in VS bringing up the Developer Portal page specific to your Cloud Service Project.   Otherwise, it will bring up the summary page.

Hit “Save” to save the project file.

Deploying the Package from Visual Studio

Right click on the Cloud Service Project in Solution Explorer and select “Publish…”.

Publish

This will build your package, open Windows Explorer up to the location where the package was built and use Internet Explorer to browse to the Developer Portal. 

From this Portal page, select “Deploy”.

Deploy

This will take you to a page where you can specify the package and the configuration file to upload. 

You can copy the path from the Windows Explorer window that VS opened into this File Open dialog – which will make it easy for you to select the Service Package (cspkg) and Service Configuration.

Note: The current constraint for the number of instances you can run on Windows Azure as part of the CTP is a maximum of 2 Web Role instances and 2 Worker Role instances.

Upload

The portal will then upload the package and deploy your Cloud Service to staging.

This puts your roles in the “Allocated” state:

Allocated

From Staging, you can test your Cloud Service on a staging URL (the cloudapp.net URL that begins with a Guid) by clicking “Run”.  His will put your Web Role in the Initializing state.

Initializing

When the Web Role is ready, the state will be changed to:

Started

Once your roles have been started, you can test by navigating to the staging URL.

After you are happy with your Cloud Service on staging, you can promote it to production by clicking on the promote button. 

Promote

Your service will now be running at its final URL.  

Production

Also note that you can click “Configure…” to copy your event logs to a storage account or update the Service Configuration (cscfg).  The Service Configuration can be update by using the editor provided or by uploading a new Service Configuration file.

© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker