Revision #98

You are currently reviewing an older revision of this page.
Go to current version



This tutorial demonstrates the process of creating a Windows Azure application and the process of deploying the application to Windows Azure. In this tutorial, you will create a simple golfer message board application. The application contains one Web role (Web front-end), that allows golfers to view the message board and add new message entries. The application uses the Windows Azure Table service to store messages. Here is a screenshot of the application:

Last reviewed: 9/1/2011

 Note
If you wish to contribute to this page, use the Edit tab at the top (sign-in required). If you wish to provide feedback for this documentation please either send e-mail to azuredocs@microsoft.com or use the Comment field at the bottom of this page (sign-in required).

Note: The tutorial code has been tested on Windows Azure SDK (August 2011).

Note:  For the tutorial in PHP, see Using the Windows Azure Web Role and Windows Azure Table Service with PHP.

Objectives

In this tutorial, you will learn how to:

  • Understand the process of developing a Windows Azure application
  • Understand the process of deploying an application to Windows Azure
  • Create a Web role
  • Use the Table service

Prerequisites

Note the following requirements before you begin this lesson:

How to Use the Tutorial

  • Go through the tutorial at least 2 times.
  • If you are an experienced developer and you don't want to follow the tutorial step-by-step, you can open the solution from the completed folder and skip lesson 1, lesson 2 and lesson 3.
  • Even if you don't have a Windows Azure subscription, you can still learn programming Windows Azure application by going through lesson 1 through lesson 4.

Understanding the Architecture

The following diagram illustrates the development components and the runtime components involved in this tutorial:

Note: The gray out components are the components that are not covered in this tutorial but in other tutorials.

  • There are two environments: the Windows Azure runtime environment and the local development environment.  The runtime environment is hosted in one of the Microsoft data centers.
  • There are two main services within the runtime environment: Compute and Storage.  Compute is the computational part of Windows Azure. Storage consists of three main parts: Table service, Blob service and Queue service.  Other than the Windows Azure Storage Service, you can also use SQL Database to store data. In this tutorial, you will use Windows Azure Table service.  Tutorial 2 covers SQL Database; tutorial 3 covers Blob service; and tutorial 4 covers Queue service. For more information, see Understanding Data Storage Offerings on the Windows Azure Platform.
  • The Compute service is also referred as Hosted Service.  It is the application you deploy on Windows Azure. Every Hosted Service can have Web role and Worker role.  A Web role is an ASP.NET Web application accessible via an HTTP or HTTPS endpoint and is commonly the front-end for an application. A worker role is a role that is useful for generalized development, and may perform background processing for a Web role. In this tutorial, you will create a Web role project. For more information, see Overview of a Windows Azure Application at http://msdn.microsoft.com/en-us/library/gg432976.aspx. Tutorial 4 will introduce Worker role.
  • You can use the portal to administrate Windows Azure platform resources.
  • You develop the Windows Azure application using Visual Studio and Windows Azure SDK.
  • You deploy the application to local Windows Azure Emulator for testing, and to Windows Azure.
  • A Windows Azure project includes two configuration files: ServiceDefinition.csdef and ServiceConfiguration.cscfg. These files are packaged with your Windows Azure application and deployed to Windows Azure.

Understanding the Table Service Object Model

The Windows Azure Table service is structured storage in the cloud. Here is a diagram of the Table service data model:

An application must use a valid account to access Windows Azure Storage service. In ">lesson 5, you will create a new Windows Azure Storage account using Windows Azure Management Portal. An application may create many tables within a storage account.  A table contains a set of entities (rows). Each entity contains a set of properties. An entity can have at most 255 properties including the mandatory system properties - PartitionKey, RowKey, and Timestamp. "PartitionKey" and "RowKey" form the unique key for the entity.

In this Article


Lesson 1: Create a Windows Azure Visual Studio Project

In this lesson, you create a Windows Azure Project with Visual Studio. A Windows Azure application can contain one or more roles.  The application you will develop in this tutorial only contains one Web role talking to Windows Azure Table service.  In [[Windows Azure and SQL Database Tutorials - Tutorial 4: Using Windows Azure Worker Role and Windows Azure Queue Service]], you will add a Worker role to the application for background processing.

Procedures

In this lesson, you will go through the following procedure:

To create a Visual Studio project

  1. Click Start, point to All Programs, point to Microsoft Visual Studio 2010, right-click Microsoft Visual Studio 2010, and then click Run as administrator.
  2. If the User Account Control dialog appears, click Yes.
  3. Click the File menu, point to New, and then click Project.
  4. In the New Project dialog, type or select the following values:
    Name Value
    Installed Templates (In the left pane, expand Visual C# , and then click Cloud.)
    Template Windows Azure Project
    Name MessageBoard
    Location C:\AzureTutorials\Tutorial1
    Solution name GolferMessageBoard
    Create directory for solution (selected)

  5. Click OK.
  6. In the New Windows Azure Project dialog, inside the left pane, double-click ASP.NET Web Role to add it to the Windows Azure Solution list. The default name is WebRole1.
  7. Right-click WebRole1, rename the role to MessageBoard_WebRole, and then click OK. The generated solution contains two projects. MessageBoard is a cloud service project, the MessageBoard_WebRole is an ASP.NET web role project.
  8. From Solution Explorer, expand MessageBoard, and then expand Roles.  There is one role listed there, called MessageBoard_WebRole.  This application only contains one Web role.

    Under the MessageBoard cloud service project, there are also one definition file and two configuration files. The ServiceDefinition.csdef file defines the runtime settings for the application including what roles are required, endpoints, and so on. The ServiceConfiguration.Local.cscfg contains the storage account connection string to use the local Windows Azure Storage emulator; the ServiceConfiguration.Cloud.cscfg contains the settings to use Windows Azure storage service. For more information, see Configuring the Windows Azure Application with Visual Studio at http://msdn.microsoft.com/en-us/library/ee405486.aspx.

    Note: If you only see one .cscfg file, install the latest Windows Azure Tools for Microsoft Visual Studio.

What did I just do?

In this step, you created a Windows Azure project with Visual Studio.

Next Steps

You add a new class library project to the solution for accessing Windows Azure Table service.

Return to Top


Lesson 2: Create a Data Source

The application stores message entries using Windows Azure Table service. The Table service is NOT relational database tables. It is helpful to think of it as object storage.

In this lesson, you first define the entity for golfer message entries. An entity contains a set of properties, for example, golfer name, and message.  Then you create the data source so that the ASP.NET Web role that you will create in the next lesson can use the data source to access the Table service.  The data source has two methods, one for adding messages to the storage, and the other for listing the messages in the storage.

To access the Table service, you can use LINQ.

Procedures

In this lesson, you will go through the following procedures:

  1. Add a new project to the solution
  2. Define the entity
  3. Create a data source
  4. Compile the project

To add a new project

  1. From Solution Explorer, right-click Solution 'GolferMessageBoard', point to Add, and then click New Project.
  2. In the Add New Project dialog, type or select the following values.
    Name Value
    Installed Templates Visual C# , Windows
    Template Class Library
    Name MessageBoard_Data
    Location C:\AzureTutorials\Tutorial1\GolferMessageBoard
  3. Click OK.
  4. In Solution Explorer, delete Class1.cs inside the MessageBoard_Data project. You will add a new class file, instead of using the default one.
  5. In Solution Explorer, right-click the MessageBoard_Data project, and then click Add Reference.
  6. In the Add Reference dialog, switch to the .NET tab (the reference list is not in the alphabetic order by default), select System.Data.Services.Client and Microsoft.WindowsAzure.StorageClient and Microsoft.WindowsAzure.ServiceRuntime, and then click OK. System.Data.Services.Client and Microsoft.Windows.StorageClient are used for utilitzing the Windows Azure storage services.  Microsoft.WindowsAzure.ServiceRuntime is used for retrieving data connection string in the configuration file.

    Note: Hold the CTRL key while selecting multiple references. If you don’t see the component, sort the Component Name column.

Next, define the entity for the message entries. The Table service does not enforce any schema for tables making it possible for two entities in the same table to have different sets of properties. Nevertheless, this message board application uses a fixed schema to store its data.

To define the entity

  1. In Solution Explorer, right-click MessageBoard_Data, point to Add, and then click New Item.
  2. In the Add New Item – MessageBoard_Data dialog, type and select the following values and then click Add.
    Name Value
    Installed Templates Visual C# , Code
    Template Class
    Name MessageBoardEntry.cs
  3. At the top of the MessageBoardEntry.cs file, insert the following namespace declaration.

    using Microsoft.WindowsAzure.StorageClient;

  4. Update the declaration of the MessageBoardEntry class to make it public and derive from the TableServiceEntity class.

    public class MessageBoardEntry : TableServiceEntity
    {
    }

  5. Add a default constructor and properties to the class by inserting the code snippet Tutorial01-Lesson02-Task02_MessageBoardEntry.

        public MessageBoardEntry()
        {
          PartitionKey = DateTime.UtcNow.ToString("MMddyyyy");

          // Row key allows sorting, so we make sure the rows come back in time order.
          RowKey = string.Format("{0:10}_{1}",
                                 DateTime.MaxValue.Ticks - DateTime.Now.Ticks,
                                 Guid.NewGuid());  
        }   

        public string GolferName { get; set; }
        public string GolferMessage { get; set; }

    Note: You can either copy/paste the code or use code snippet. The code snippets have more comments which can help you to review the code in the future. For more information on using the code snippets, see Windows Azure and SQL Database Tutorials (en-US).

    In addition to the properties required by the data model, every entity has two key properties: the PartitionKey and the RowKey. These properties together form the table's primary key and uniquely identify each entity in the table. Entities also have a Timestamp system property, which allows the service to keep track of when an entity was last modified.

    The MessageBoardEntry.cs looks like the following (collapse to definitions) when completed:

  6. Press Ctrl+S to save the MessageBoardEntry.cs file.

Finally, you create a data source that can be bound to data controls in the ASP.NET Web role that you will create in the next lesson.

To create a data source

  1. In Solution Explorer, right-click MessageBoard_Data, point to Add, and then click New Item.
  2. In the Add New Item – MessageBoard_Data dialog, type and select the following values, and then click Add.
    Name Value
    Installed Templates Visual C# , Code
    Template Class
    Name MessageBoardDataSource.cs
  3. At the top of the MessageBoardDataSource.cs file, insert the following namespace declarations.

    using Microsoft.WindowsAzure;
    using Microsoft.WindowsAzure.StorageClient;
    using Microsoft.WindowsAzure.ServiceRuntime;

  4. Make the MessageBoardDataSource class public.

    public class MessageBoardDataSource
    {
    }

  5. Define member fields by inserting the code snippet Tutorial01-Lesson02-Task04_MessageBoardDataSourceFields.

    private const string messageTableName = "MessageTable";
    private const string connectionStringName = "DataConnectionString";
    private static CloudStorageAccount storageAccount;
    private CloudTableClient tableClient;

  6. Add a default constructor to the class by inserting the code snippet Tutorial01-Lesson02-Task04_MessageBoardDataSourceConstructors..

    public MessageBoardDataSource()
    {
       string connectionString = RoleEnvironment.GetConfigurationSettingValue(connectionStringName);

       storageAccount = CloudStorageAccount.Parse(connectionString );
       tableClient = new CloudTableClient(storageAccount.TableEndpoint.AbsoluteUri, storageAccount.Credentials);
       tableClient.RetryPolicy = RetryPolicies.Retry(3, TimeSpan.FromSeconds(1));
       tableClient.CreateTableIfNotExist(messageTableName);
    }

    The constructor initializes the storage account by reading its settings from the configuration files and then uses the CreateTablesIfNotExist method in the CloudTableClient class to create the table used by the application. You will configure DataConnectionString in Lesson 3.

  7. Inside the MessageBoardDataSource class, add some methods by inserting the code snippet Tutorial01-Lesson02-Task04_MessageBoardDataSourceMethods.

    public IEnumerable<MessageBoardEntry> GetEntries()
    {
       TableServiceContext tableServiceContext = tableClient.GetDataServiceContext();
       var results = from g in tableServiceContext.CreateQuery<MessageBoardEntry>(messageTableName)
       where g.PartitionKey == DateTime.UtcNow.ToString("MMddyyyy")
       select g;
       return results;
    }

    public void AddEntry(MessageBoardEntry newItem)
    {
       TableServiceContext tableServiceContext = tableClient.GetDataServiceContext();
       tableServiceContext.AddObject(messageTableName, newItem);
       tableServiceContext.SaveChanges();
    }

    The GetMessageBoardEntries method retrieves today's message board entries by constructing a LINQ statement that filters the retrieved information using the current date as the partition key value. The Web role uses this method to bind to a data grid and display the message board.

    The AddMessageBoardEntry method inserts new entries into the table.

    The MessageBoardDataSource.cs looks like the following (collapse to definitions) when completed:

  8. Press Ctrl+S to save the MessageBoardDataSource.cs file.

To compile the project

  • In Solution Explorer, right-click MessageBoard_Data, and then click Build.

What did I just do?

In this step, you created a data source that will be consumed by the ASP.Net Web role that you will create in the next Lesson.

Next Steps:

You will create an ASP.NET Web role for displaying the message board and process user input.

Return to Top


Lesson 3: Create a Web Role to Display the Message Board and Process User Input

In this lesson, you modify the Web role project that you generated in Lesson 1 when you created the Windows Azure Cloud Service solution. This involves updating the UI to render the list of message board entries.

Procedures

In this lesson, you will go through the following procedures:

  1. Configure the Web role project
  2. Modify Default.aspx
  3. Modify Default.aspx.cs
  4. Add the storage account settings

You must reference the MessageBoard_Data object from the Web role project. To save time, you will begin with a skeleton default.aspx file.

To configure the Web role project

  1. In Solution Explorer, right-click the MessageBoard_WebRole project, and then click Add Reference.
  2. In the Add Reference dialog, switch to the Projects tab, select the MessageBoard_Data project, and then click OK.
  3. In Solution Explorer, right-click Default.aspx of the MessageBoard_WebRole project, and then click Delete.
  4. In Solution Explorer, right-click MessageBoard_WebRole, point to Add, and then select Existing Item.
  5. In Add Existing Item – MessageBoard_WebRole, browse to the C:\AzureTutorials\Tutorial1\TutorialFiles\ folder, hold the CTRL key down while selecting all four files in the folder, and then click Add.
  6. In Solution Explorer, right-click Solution 'GolferMessageBoard', and then click Rebuild Solution.

The default.aspx file uses a DataList control and an ObjectDataSource control to display the messages. In the following procedure, you configure the two controls.

To modify Default.aspx

  1. In Solution Explorer, right-click Default.aspx of the MessageBoard_WebRole project, and then click View Designer.
  2. Hover over the dsMessages ObjectDataSource control, click the right arrow button, and then click Configure Data Source.

  3. In Choose a business object, select MessageBoard_Data.MessageBoardDataSource, and then click Next.

    Note: If you get a message saying "The Type 'MessageBoard_Data.MessageBoardDataSource' could not be found", rebuild the solution and try again.

  4. Click the SELECT tab.
  5. In Choose a method, select GetEntries(), returns IEnumerable<MessageBoardEntry>, and then click Finish. The GetEntries() is what you defined in the object in the previous lesson.
  6. Hover over the dlMessages DataList control, and then click the right arrow button. In Choose Data Source, select dsMessages.

  7. Click No to reject reset template.
  8. Press Ctrl+S to save the Default.aspx file.

Next, you implement the code necessary to store submitted entries to the Table service.

To modify Default.aspx.cs

  1. In Solution Explorer, right-click Default.aspx of the MessageBoard_WebRole project, and then click View Code.
  2. At the top of Default.aspx.cs, add the following namespace declaration.

    using MessageBoard_Data;

  3. Locate the btnSend_Click method, and insert the code snippet Tutorial01-Lesson03-Task02_WebRoleBtnSend_Click inside the method.

    // create a new entry in the table
    MessageBoardEntry entry = new MessageBoardEntry() { GolferName = txtName.Text, GolferMessage = txtMessage.Text };
    MessageBoardDataSource ds = new MessageBoardDataSource();
    ds.AddEntry(entry);

    txtName.Text = "";
    txtMessage.Text = "";

    dlMessages.DataBind();

    This method creates a new MessageBoardEntry entity, initializes it with the information submitted by the user, and then uses the MessageBoardDataSource class to save the entry to the table. Then, it refreshes its contents using the DataBind() method.

  4. Locate the tmrRefreshMsgs_Tick method, and insert the following line of code.

    dlMessages.DataBind();

    This method refreshes the page every 15 seconds. The refreshing interval is pre-configured in the default.aspx file.

  5. Locate the Page_Load method, and insert the code snippet Tutorial01-Lesson03-Task02_WebRolePage_Load.

    if(!Page.IsPostBack)
    {
       tmrRefreshMsgs.Enabled = true;
    }

    The code enables the page refresh timer.

  6. Press Ctrl+S to save the Default.aspx.cs file.

Earlier in the tutorial, you defined a constant called connectionStringName, the value is DataConnectionString. DataConnectionString is a setting in the configuration file. You must define it. When you add a role to the Windows Azure project, Visual Studio generated two configuration files, ServiceConfiguration.Cloud.cscfg and ServiceConfiguration.Local.cscfg. You can configure the local configuration file to use the Storage Emulator for testing the application locally, and the cloud configuration file to use a Windows Azure storage account.  Creating a storage account will be covered in lesson 5. For the time being, you configure both configuration files to use Storage Emulator.

Note: Storage Emulator offers local storage services that simulate the Blob, the Queue, and the Table services available in Windows Azure. The Storage Emulator UI provides a means to view the status of local storage service and to start, stop, and reset them. For more information, see Overview of the Windows Azure Storage Emulator at http://msdn.microsoft.com/en-us/library/gg432983.aspx.

To add the storage account settings

  1. In Solution Explorer, expand MessageBoard, expand Roles, and then double-click MessageBoard_WebRole to open the properties for this role.
  2. Switch to the Settings tab.
  3. In the Service Configuration drop down in the heading, select All Configurations.
  4. Click Add Setting to add one setting.
  5. Type or select the following values.
    Name Value
    Name DataConnectionString
    Type Connection String
    Value (click the ellipses button (), and then select Use the Windows Azure storage emulator)

    The DataConnectionString is used in the MessageBoardDataSource class you defined in Lesson 2.

  6. Press Ctrl+S to save changes to the role configuration.

What did I just do?

In this step, you created a Web role to display the message board and process user input.

Next Steps:

You will test the application in the compute emulator. Then you will generate a service package that you can use to deploy the application to Windows Azure.

Return to Top


Lesson 4: Test the Application and Generate the Service Package

In this lesson, you launch the message board application in the compute emulator, and then create one or more entries. And then generate the service package for the application. The service package will be used in the next lesson, Lesson 5: Deploying the Application to Windows Azure.

Note:
The Windows Azure compute emulator simulates the Windows Azure fabric on your local computer so that you can run and test your service locally before deploying it. For more information, see Overview of the Windows Azure Compute Emulator at http://msdn.microsoft.com/en-us/library/gg432968.aspx.

Procedures

In this lesson, you will go through the following procedures:

  1. Test the application
  2. Generate the service package

To test the application

  1. In Solution Explorer, right-click MessageBoard, and then click Set as Startup Project.
  2. From the Debug menu, click Start Debugging. You will see a compute emulator icon added to the notification area of taskbar, and a new Internet Explorer window showing the Golfer Message Board application.
  3. (Optional) Right-click the compute emulator icon (a blue flag icon) on the Taskbar to show the compute emulator UI and the storage emulator UI.
  4. Switch to Internet Explorer to view the message board application.
  5. Add a few entries to the message board by entering your name and a message before clicking Send.
  6. Close the Internet Explorer window.

After the application is tested successfully in the compute emulator environment, the next step is to create the service package and then deploy the application to Windows Azure.

Troubleshooting

Here are several problems, along with suggested solutions, in case you encounter one of them.

Error: This access control list is not in canonical form and therefore cannot be modified.
This exception may be thrown when the Windows Azure Web Role uses IIS instead of the Hosted Web Core (HWC).
Here is an example of this error:
http://social.msdn.microsoft.com/Forums/en-SG/windowsazuredevelopment/thread/07fe087e-4ac3-4c4f-bd62-4fccff4afd45
One solution, along with an explanation of the cause, is described here: New Full IIS Capabilities: Differences from Hosted Web Core
In essence, you comment out the <Sites> node in the ServiceDefinition.csdef file.

No connection could be made because the target machine actively refused it 127.0.0.1:10002
This error can be caused if the Azure Storage Emulator is pointing to the wrong instance of SQL Server on your computer. An example of this error is found here.
You can use the DSInit command line tool to change which SQL Server instance the Azure Storage Emulator is pointing to. How to do this is described in How to Initialize the Storage Emulator by Using the DSInit Command-Line Tool


To generate the service package

  1. In Solution Explorer expand the MessageBoard_WebRole project.
  2. Double-click Web.config to open the web.config file. Find in the sessionState child element of system.web and comment it out. This is to avoid a failed attempt by the state provider trying to connect to a non-existant SQL Express database when deployed to the cloud. For example in the following code snippet, it is found as the last child element of the system.web element. It is commented out by surrounding it with "<!--" and "-->":

    <!--
      <sessionState mode="Custom" customProvider="DefaultSessionProvider">
        <providers>
          <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
        </providers>
        </sessionState>
    -->
    </system.web>

  3. In Solution Explorer, right-click the MessageBoard cloud project, and then select Package.
  4. In the Package Windows Azure Application dialog, select the following values:
    Name Value
    Service configuration Cloud
    Build configuration Release
  5. Click Package. After Visual Studio builds the project and generates the service package, Windows Explorer opens with the current folder set to the location where the generated package is stored. The default directory is C:\AzureTutorials\Tutorial1\GolferMessageBoard\MessageBoard\bin\Release\app.publish. Make sure to write down the path. You will need it in the deployment lesson.

What did I just do?

In this step, you tested the application in the compute emulator, and generated a service package for the application.

Next Steps:

You deploy the application to Windows Azure.

Return to Top


Lesson 5: Deploy the Application to Windows Azure

In this lesson, you deploy the application to Windows Azure using Windows Azure Platform Management Portal.

Note: If you haven’t had a Windows Azure Platform subscription, see the Provisioning Windows Azure section of this tutorial.

Procedures

In this lesson, you will go through the following procedures:

  1. Create a storage account. You need a storage account to utilize Windows Azure storage services, for example the table service.
  2. Create a hosted service. The hosted service is used to host the message board application.
  3. Deploy the application to the staging environment
  4. Configure the application to use the storage account. When you develop the application, the application is set to use the local compute emulator. You must change the configuration so the application use the Windows Azure table service.
  5. Test the application
  6. Promote the application to the production environment

For deploying the golfer message board application, you must have a storage account for accessing the Windows Azure storage services, and a hosted service, which is a container for service deployments in Windows Azure. For better performance, you might want to create an affinity group to group the service and the storage accounts within a subscription according to geo-location.

To create a storage account for the golfer message board application to store its data

  1. Open a Web browser and browse to http://windows.azure.com/.
  2. Sign in using the Windows Live ID associated with your Windows Azure account.
  3. In the left pane, click Hosted Services, Storage Accounts & CDN.
  4. In the left pane, click Storage Accounts. Your storage accounts and the associated subscriptions are listed in the middle pane.
  5. From the top menu, click New Storage Account.
  6. In Create a New Storage Account, type or select the following values.
    Name Value
    Choose a subscription (select a subscription that is associated with the storage account)
    Enter a URL <yourname>gmb (i.e. johndolegmb)
    Choose a region or affinity group (click ... .select Create a new affinity group. In Affinity Group Name, type ag<yourname>GMB; in Location, choose the region where you wish your service to run, most likely, the one that is closest to your current location, and then click OK.)
  7. Click OK.
  8. Click Create. Wait until the status for the storage account changes to Created. The process can take several minutes. In the next procedure To create a host service, you will choose the same affinity group for the hosted service.
  9. Make sure the status for the new storage account is Created, and then click the new storage account to display its properties in the Properties pane on the right.
  10. In the Properties pane on the right, write down the Name (the storage account name).   Click the View Access Keys in the Storage menu at the top of the page.  Record the  Primary access key. You will need the information to configure the application to use this storage account.

To create a hosted service

  1. From the portal, in the left pane, click Hosted Services. Your storage accounts and the associated subscriptions are listed in the middle pane.
  2. From the top menu, click New Hosted Service.
  3. In Create a New Hosted Service, type or select the following values.
    Name Value
    Choose a subscription (select a subscription that is associated with the service account)
    Enter a name for your service GolferMessageBoard
    Enter a URL prefix for your service <yourname>gmb

    Note: The URL prefix must be unique.

    Choose a region or affinity group (select Create or choose an affinity group, and then select ag<yourname>GMB - <the region you selected in the last procedure>)
    Deployment options Do not deploy
  4. Click OK. Wait until the status changes to Created. This process can take several minutes.

To deploy the application to the staging environment

  1. From the portal, in the left pane, click Hosted Services.
  2. In the middle pane, click GolferMessageBoard, the hosted service you created in the last procedure.
  3. From the top menu, click New Staging Deployment.
  4. In Create a new Development, type or select the following value.
    Name Value
    Deployment name v1.0.0.0
    Package location C:\AzureTutorials\Tutorial1\GolferMessageBoard\MessageBoard\bin\Release
    \app.publish\MessageBoard.cspkg
    Configuration file C:\AzureTutorials\Tutorial1\GolferMessageBoard\MessageBoard\bin\Release
    \app.publish\ServiceConfiguration.Cloud.cscfg
  5. Click OK.
  6. Click Yes if you get a Warning dialog. You will fix the configuration issue in the next procedure.
  7. Wait until the status changes to Ready. The application deployment process can take several minutes to complete. If you are curious on why it takes long, see What Happens When You Deploy on Windows Azure?

To configure the application to use the storage account

  1. From the portal, in the left pane, click Hosted Services.
  2. In the middle pane, expand GolferMessageBoard, and then click v1.0.0.0.
  3. From the top menu, click Configure. It will take some time before the Configure button becomes enabled.
  4. In Configure Deployment, click Edit current configuration.
  5. Locate the MessageBoard_WebRole configuration settings, and replace the DiagnosticsConnectionString setting and the DataConnectionString setting to the following:

    <Role name="MessageBoard_WebRole">
      <ConfigurationSettings>

        <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="DefaultEndpointsProtocol=https;AccountName=[YOUR STORAGE ACCOUNT NAME];AccountKey=[YOUR STORAGE ACCOUNT PRIMARY KEY]" />

        <Setting name="DataConnectionString" value="DefaultEndpointsProtocol=https;AccountName=[YOUR STORAGE ACCOUNT NAME];AccountKey=[YOUR STORAGE ACCOUNT PRIMARY KEY]" />

      </ConfigurationSettings>
      <Instances count="1" />
      <Certificates />
    </Role>

    Note: Make sure to replace both instances of the placeholders, one for the DataConnectionString and the second one for the DiagnosticsConnectionString.

  6. Click OK to update the configuration.
  7. Click Yes to ignore the warnings. Wait until the Status for the deployment changes to Ready. This process can take several minutes to complete.

To test the application in the staging environment

  1. From the portal, in the left pane, click Hosted Services.
  2. In the middle pane, expand GolferMessageBoard, and then click v1.0.0.0.
  3. In the Properties pane on the right, click the URL in the DNS name box. The application is opened in a new browser tab or a new browser window depending on your browser configuration.
  4. Test the application by entering one or more entries.

After the application is working correctly in the staging environment, you are ready to promote it to the production environment.

To promote the application to production

  1. From the portal, in the left pane, click Hosted Services.
  2. In the middle pane, expand GolferMessageBoard, and then click v1.0.0.0.
  3. From the top menu, click Swap VIP.
  4. In Swap VIPs, click OK. Wait until the Status for the deployment changes to Ready.
  5. In the Properties pane, click the URL in the DNS name box. The application is opened in a new browser tab or a new browser window depending on your browser configuration.

    Note: Some DNS services take longer to replicate the records. If you get a page not found error, you might need to try browsing to the URL again in a few minutes.

  6. Test the application in the production environment by entering one or more entries.

What did I just do?

In this step, you deployed the golfer message board to Windows Azure.

Next Steps:

Congratulations! You have completed tutorial 1. Tutorials 2, 3 and 4 show you how to use SQL Database and other Windows Azure storage services.

Return to Top


See Also

Revert to this revision