Azure and SQL Database Tutorials - Tutorial 1: Using Azure Web Role and Azure Table Service
Azure is a cloud platform that enables you to quickly build, deploy and manage applications across a global network of Microsoft-managed data centers. You can build applications using any language, tool or framework.
Microsoft Azure provides three options for executing applications. These options can be used separately or combined.
- Virtual Machine: Virtual Machines (VM) provides the ability to create a virtual machine on demand. You can use the virtual machine as a development computer, or as a server to run your applications. Once you have a virtual machine created, you can deploy your existing applications to it without engaging developers to make code changes. The downside of using virtual machines is that you are responsible to administering the VMs.
- Web Site: The Web Site option offers a managed web environment using Internet Information Services (IIS). You can move an existing IIS website into Microsoft Azure Web Sites unchanged, or you can create a new one directly in the cloud. Once a website is running, you can add or remove instances dynamically, relying on Web Sites to load balance requests across them.
- Cloud Service: Cloud Service is designed expressly to support scalable, reliable, and low-admin applications, and it's an example of what's commonly called Platform as a Service (PaaS). To use it, you create an application using the technology you choose, such as C#, Java, PHP, Python, Node.js, or something else. Your code then executes in virtual machines (referred to as instances) running a version of Windows Server.
This tutorial demonstrates the process of creating a Microsoft Azure application and the process of deploying the application to a Microsoft Azure Cloud Service. The application is a simple golfer message board web application for users to enter or view messages, it contains one web role (Web front-end), that allows golfers to view the message board and add new message entries. The application uses the Microsoft Azure Table service to store messages. Here is a screenshot of the application:
Last reviewed: 11/04/2012
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 Microsoft Azure SDK (October 2012).
Note: For the tutorial in PHP, see [[Using the Microsoft Azure Web Role and Microsoft Azure Table Service with PHP]].
Objectives
In this tutorial, you will learn how to:
- Understand the process of developing a Microsoft Azure application
- Understand the process of deploying an application to Microsoft Azure
- Create a web role
- Use the Table service
Prerequisites
Note the following requirements before you begin this lesson:
- .NET development experience.
- Before you begin this step, you must complete the steps in [[Microsoft Azure and SQL Database Tutorials (en-US)]] to configure the development environment and download the tutorials files.
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 Microsoft Azure subscription, you can still learn programming Microsoft 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 Microsoft 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 Microsoft Azure. Storage consists of three main parts: Table service, Blob service and Queue service. Other than the Microsoft Azure Storage Service, you can also use SQL Database to store data. In this tutorial, you will use Microsoft Azure Table service. Tutorial 2 covers SQL Database; tutorial 3 covers Blob service; and tutorial 4 covers Queue service. For more information, see Data Management.
- The Compute service is also referred as Cloud Service. It is the application you deploy on Microsoft Azure. Every Cloud 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 What is a Cloud Service. Tutorial 4 will introduce Worker role.
- You can use the Microsoft Azure Management portal to administrate Microsoft Azure platform resources.
- You develop the Microsoft Azure application using Visual Studio and Microsoft Azure SDK.
- You deploy the application to local Microsoft Azure Emulator for testing, and to Microsoft Azure.
- A Microsoft Azure project includes two configuration files: ServiceDefinition.csdef and ServiceConfiguration.cscfg. These files are packaged with your Microsoft Azure application and deployed to Microsoft Azure.
Understanding the Table Service Object Model
The Microsoft 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 Microsoft Azure Storage service. In lesson 4, you will create a new Microsoft Azure storage account using Microsoft 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 Microsoft Azure Visual Studio Project
- Lesson 2: Create a Data Source for Accessing Windows Azure Table Service
- Lesson 3: Create a Web Role to Display the Message Board and Process User Inputs
- Lesson 4: Test the Application and Deploy the Application
Lesson 1: Create a Microsoft Azure Visual Studio Project
In this lesson, you create a Microsoft Azure Project with Visual Studio. A Microsoft Azure application can contain one or more roles. The application you will develop in this tutorial only contains one web role talking to Microsoft Azure Table service. In [[Windows Azure and SQL Database Tutorials - Tutorial 4: Using Microsoft Azure Worker Role and Microsoft 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
Click Start, point to All Programs, point to Microsoft Visual Studio 2012, right-click Visual Studio 2012, and then click Run as administrator.
If the User Account Control dialog appears, click Yes.
Click the File menu, point to New, and then click Project.
In the New Project dialog, type or select the following values:
Name Value Installed Templates (In the left pane, expand Installed, expand Templates, expand Visual C# , and then click Cloud.) Template Microsoft Azure Cloud Service Name MessageBoard Location C:\AzureTutorials\Tutorial1 Solution name GolferMessageBoard Create directory for solution (selected) Click OK.
In the New Microsoft Azure Project dialog, inside the left pane, double-click ASP.NET Web Role to add it to the Microsoft Azure Cloud Service Solution list. The default name is WebRole1.
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, MessageBoard_WebRole is an ASP.NET web role project.
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 Microsoft Azure Storage emulator; the ServiceConfiguration.Cloud.cscfg file contains the settings to use Microsoft Azure storage service. For more information, see Configuring the Microsoft Azure Application with Visual Studio at http://msdn.microsoft.com/en-us/library/ee405486.aspx.
What did I just do?
In this step, you created a Microsoft Azure project with Visual Studio.
Next Steps
You add a new class library project to the solution for accessing Microsoft Azure Table service.
Return to Top
Lesson 2: Create a Data Source
The application stores message entries using Microsoft 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:
To add a new project
From Solution Explorer, right-click Solution 'GolferMessageBoard', point to Add, and then click New Project.
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 Click OK.
In Solution Explorer, delete Class1.cs inside the MessageBoard_Data project. You will add a new class file, instead of using the default one.
In Solution Explorer, right-click the MessageBoard_Data project, and then click Add Reference.
In the Reference Manager dialog, expand Assemblies, click Framework, and then select System.Data.Services.Client; Expand Assemblies, click Extensions, and then select Microsoft.WindowsAzure.Configuration, Microsoft.WindowsAzure.StorageClient and Microsoft.WindowsAzure.ServiceRuntime. And then click OK. System.Data.Services.Client and Microsoft.Windows.StorageClient are used for utilizing the Microsoft Azure storage services. Microsoft.WindowsAzure.ServiceRuntime is used for retrieving data connection string in the configuration file.
Note: If multiple extension assemblies are presented, select the ones with version 1.7.0.0.
Note: If you cannot find a component, use the search box on the upper right corner of the dialog.
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
In Solution Explorer, right-click MessageBoard_Data, point to Add, and then click New Item.
In the Add New Item – MessageBoard_Data dialog, type and select the following values:
Name Value Installed Templates Visual C# , Code Template Class Name MessageBoardEntry.cs Click Add.
At the top of the MessageBoardEntry.cs file, insert the following namespace declaration.
using Microsoft.WindowsAzure.StorageClient;
Update the declaration of the MessageBoardEntry class to make it public and derive from the TableServiceEntity class.
public class MessageBoardEntry : TableServiceEntity { }
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 [[Microsoft 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:
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
In Solution Explorer, right-click MessageBoard_Data, point to Add, and then click New Item.
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 At the top of the MessageBoardDataSource.cs file, insert the following namespace declarations.
using Microsoft.WindowsAzure; using Microsoft.WindowsAzure.StorageClient; using Microsoft.WindowsAzure.ServiceRuntime;
Make the MessageBoardDataSource class public.
public class MessageBoardDataSource { }
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;
Add a default constructor to the class by inserting the code snippet Tutorial01-Lesson02-Task04_MessageBoardDataSourceConstructors..
public MessageBoardDataSource() { //add reference Microsoft.WindowsAzure.Configuration storageAccount = CloudStorageAccount.Parse( CloudConfigurationManager.GetSetting(connectionStringName)); // Create the table client tableClient = storageAccount.CreateCloudTableClient(); 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.
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:
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 Microsoft 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:
- Configure the web role project
- Modify Default.aspx
- Modify Default.aspx.cs
- 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
- In Solution Explorer, right-click the MessageBoard_WebRole project, and then click Add Reference.
- In the Reference Manageer dialog, expand Solution, and then click Projects.
- Select MessageBoard_Data, and then click OK.
- In Solution Explorer, right-click Default.aspx of the MessageBoard_WebRole project, and then click Delete.
- In Solution Explorer, right-click MessageBoard_WebRole, point to Add, and then select Existing Item.
- 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.
- 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
In Solution Explorer, right-click Default.aspx of the MessageBoard_WebRole project, and then click View Designer.
Hover over the dsMessages ObjectDataSource control on the bottom of the page, click the right arrow button, and then click Configure Data Source.
In Choose your 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.
Click the SELECT tab.
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.
Hover over the dlMessages DataList control, and then click the right arrow button. In Choose Data Source, select dsMessages.
Click No to reject reset template.
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
In Solution Explorer, right-click Default.aspx of the MessageBoard_WebRole project, and then click View Code.
At the top of Default.aspx.cs, add the following namespace declaration.
using MessageBoard_Data;
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.
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.
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.
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 Microsoft 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 Microsoft Azure storage account. Creating a storage account will be covered in lesson 4. 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 Microsoft 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 Microsoft Azure Storage Emulator at http://msdn.microsoft.com/en-us/library/gg432983.aspx.
To add the storage account settings
In Solution Explorer, expand MessageBoard, expand Roles, and then double-click MessageBoard_WebRole to open the properties for this role.
In the left, click Settings.
In the Service Configuration drop down in the heading, select All Configurations.
Click Add Setting.
Type or select the following values.
Name Value Name DataConnectionString Type Connection String Value (click the ellipses button (…), and then select Use the Microsoft Azure storage emulator). "UseDevelopmentStorage=true" will appear in the Value cell. The DataConnectionString is used in the MessageBoardDataSource class you defined in Lesson 2.
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 Microsoft Azure.
Return to Top
Lesson 4: Test the Application and Deploy the Application
In this lesson, you test the message board application in the local compute emulator, and then deploy the application to Microsoft Azure as a cloud service.
Note: The Microsoft Azure compute emulator simulates the Microsoft 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 Microsoft Azure Compute Emulator at http://msdn.microsoft.com/en-us/library/gg432968.aspx.
Procedures
In this lesson, you will go through the following procedures:
- Test the application
- Generate the service package
- Sign in to Microsoft Azure
- Create a storage account. You need a storage account to utilize Microsoft Azure storage services, for example the table service.
- Create a cloud service. The cloud service is used to host the message board application.
- To configure the ServiceConfiguration.Cloud.cscfg file
- Deploy the application to the staging environment
- Test the application
- Promote the application to the production environment
To test the application
- In Solution Explorer, right-click MessageBoard, and then click Set as Startup Project.
- 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.
- (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.
- Switch to Internet Explorer to view the message board application.
- Add a few entries to the message board by entering your name and a message before clicking Send.
- 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 Microsoft 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 Microsoft 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
In Solution Explorer, right-click the MessageBoard cloud project, and then select Package.
In the Package Microsoft Azure Application dialog, select the following values:
Name Value Service configuration Cloud Build configuration Release 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.
You will get a few warning messages about 'DataConnectionString" set up to use the local storage emulator. You can ignore these warning for now.
For deploying the golfer message board application, you must have a storage account for accessing the Microsoft Azure storage services, and a cloud service, which is a container for service deployments in Microsoft 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 sign in to Microsoft Azure
Open a Web browser and browse to http://windows.azure.com/. This is the Microsoft Azure Management Portal.
Sign in using the Windows Live ID associated with your Microsoft Azure account.
Note: If you haven’t had a Microsoft Azure Platform subscription, see the Provisioning Microsoft Azure section of this tutorial.
To create a storage account for the golfer message board application to store its data
- From the portal, in the left pane, click STORAGE.
- On the bottom left corner, click NEW, click STORAGE, and then click QUICK CREATE.
- Type or select the following values.
Name Value URL <yourname>gmb (i.e. johndolegmb) REGION/AFFINITY GROUP (Choose the region where you wish your service to run, most likely, the one that is closest to your current location. Select an affinity group instead of a region if you want your storage services to be in the same data center with the cloud service that you will create in the next step. To create an affinity group, open the NETWORKS area of the Management Portal, click AFFINITY GROUPS, and then click CREATE.) - Click the check mark on the bottom right corner. Wait until the status of the storage account changes to Online. The process can take several minutes.
- Once the storage account is created, click the storage account from the storage account list to select it, and then click MANAGE KEYS on the bottom of the page.
- Record the STORAGE ACCOUNT NAME and PRIMARY ACCESS KEY. Later in the tutorial, you will need to configure your cloud service to use storage account by specifying the account name and the access key.
- Close the dialog.
To create a cloud service
- From the portal, in the left pane, click CLOUD SERVICES.
- On the bottom left corner of the portal page, click NEW, click COMPUTE, click CLOUD SERVICE, and then click CUSTOM CREATE.
- Type or select the following values.
Name Value URL <yourname>gmb Note: The URL prefix must be unique.
REGION/AFFINITY GROUP (For better performance, select the same region as the one you chose for the storage service, or use an affinity group.) Deployment a cloud service package now (not selected) - Click the check sign on the bottom right corner. Wait until the status changes to Created. This process could take several minutes.
When you create and test the application locally, the application is configured to use the development storage. Now you have created a storage account, you can configure the application to use the storage account before deploying the application to Windows Azure. The configuration information is in the ServiceConfiguration.Cloud.cscfg file. This file was created when you generated the service package.
To configure the ServiceConfiguration.Cloud.cscfg file
- Use Notepad to open C:\AzureTutorials\Tutorial1\GolferMessageBoard\MessageBoard\bin\Release\app.publish\ServiceConfiguration.Cloud.cscfg. This path can be different if you installed the tutorial files into a different folder than the c root directory. Notice the value of DataConnectionString is "UseDevelopmentStorage=true".
- Change the value of DataConnectionString to DefaultEndpointsProtocol=https;AccountName=<your storage account name>;AccountKey=<your storage account primary access key>. Replace <your storage account name> and <your storage account access key> accordingly.
- Change the value of Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString to DefaultEndpointsProtocol=https;AccountName=<your storage account name>;AccountKey=<your storage account primary access key>. You must replace <your storage account name> and <your storage account primary access key> with the actual account name and account key for the storage account that you created earlier in the tutorial.
- Optionally, you can increase the Instances count to scale out the application.
- Save the file and close Notepad.
To deploy the application to the staging environment
- From the portal, in the left pane, click CLOUD SERVICES.
- In the middle pane, click the cloud service you just created. The default name is <yourname>gmb..
- From the top of the page, click STAGING.
- Click UPLOAD A NEW STAGING DEPLOYMENT.
- From Upload a package, 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.cspkgConfiguration file C:\AzureTutorials\Tutorial1\GolferMessageBoard\MessageBoard\bin\Release
\app.publish\ServiceConfiguration.Cloud.cscfgDeploy even if one or more roles contain a single instance (Selected). You can always increase the number of instances from the portal. Start deployment (Selected) - Click the check sign on the bottom right corner of the page.
- Wait until the upload process is completed. The process can take several minutes to complete.
To test the application in the staging environment
- From the portal, in the left pane, click CLOUD SERVICES.
- In the middle pane, click the cloud service you created.
- From the top of the page, click STAGING.
- On the right side of the page, click the site URL.
- 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
From the portal, in the left pane, click CLOUD SERVICES.
In the middle pane, click the cloud service you created.
From the top of the page, click STAGING.
On the bottom of the page, click SWAP.
On the right, click YES.
On the top of the page, click PRODUCTION. It takes several minutes to complete the operation.
On the right, click the SITE URL.
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.
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 Microsoft Azure.
Next Steps:
Congratulations! You have completed tutorial 1. Tutorials 2, 3 and 4 show you how to use SQL Database and other Microsoft Azure storage services.
Return to Top
See Also
- [[Microsoft Azure and SQL Database Tutorials (en-US)]]
- Microsoft Azure and SQL Database Tutorials - Tutorial 2 Using SQL Database
- Microsoft Azure and SQL Database Tutorials - Tutorial 2.1 Create an OData Service
- Microsoft Azure and SQL Database Tutorials - Tutorial 3 Using Microsoft Azure Blob Service
- Microsoft Azure and SQL Database Tutorials - Tutorial 4 Using Microsoft Azure Worker Role and Microsoft Azure Queue Service
- [[Using the Microsoft Azure Web Role and Microsoft Azure Table Service with PHP]]