Setting Up Services Required to Publish a Cloud Service from Visual Studio
Before you can publish a cloud service project, you must set up the following services:
A cloud service in the Windows Azure Management Portal
Runs your roles in the Windows Azure environment.
A storage account
Provides access to the Blob, Queue, and Table services.
Use the following procedures to set up these services and configure your application:
To publish a cloud service to Windows Azure, you must first use the Windows Azure Management Portal to create a cloud service, which runs your roles in the Windows Azure environment.
To create a cloud service by using the Management Portal
Sign in to the Windows Azure Management Portal on the Microsoft website.
(optional) To display a list of cloud services that you've already created, choose the Cloud Services link on the left side of the page.
Choose the + icon in the lower-left corner, and then choose Cloud Service on the menu that appears.
Another screen with two options, Quick Create and Custom Create, appears. If you choose Quick Create, you can create a cloud service just by specifying its URL and the region where it will be physically hosted. If you choose Custom Create, you can immediately publish a cloud service by specifying a package (.cspkg file), a configuration (.cscfg) file, and a certificate. Custom Create isn’t required if you intend to publish your cloud service by using the Publish command in a Windows Azure project. The Publish command is available on the shortcut menu for a Windows Azure project.
Choose Quick Create to later publish your cloud service by using Visual Studio.
Specify a name for your cloud service.
The complete URL appears next to the name.
In the list, choose the region where most of your users are located.
At the bottom of the window, choose the Create Cloud Service link.
A storage account provides access to the Blob, Queue, and Table services.
To create a storage account by using the Management Portal
Sign in to the Windows Azure Platform Management Portal on the Microsoft website.
(optional) To view your storage accounts, choose the Storage link in the panel on the left side of the page.
In the lower-left corner of the page, choose the + icon.
In the menu that appears, choose Storage, and then choose Quick Create.
Give the storage account a name that will result in a unique URL.
Give your cloud service a name.
The complete URL appears next to the name.
In the list of regions, choose a region where most of your users are located.
Specify whether you want to enable geo-replication.
If you enable geo-replication, your data will be saved in multiple physical locations to reduce the chance of loss. This feature makes storage more expensive, but you can reduce the cost by enabling geo-location when you create the storage account instead of adding the feature later. For more information, see Geo-replication.
At the bottom of the window, choose the Create Storage Account link.
After you create your storage account, you will see the URLs that you can use to access resources in each of the Windows Azure storage services, and also the primary and secondary access keys for your account. You use these keys to authenticate requests made against the storage services.
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 be compromised. Additionally, it is recommended that you regenerate your access keys on a regular basis. You can modify a connection string setting to use the secondary key while you regenerate the primary key, then you can modify it to use the regenerated primary key while you regenerate the secondary key.
You must configure any role that accesses storage services to use the Windows Azure storage services that you have created. To do this, you can use multiple service configurations for your Windows Azure project. By default, two are created in your Windows Azure project. By using multiple service configurations, you can use the same connection string in your code, but have a different value for a connection string in each service configuration. For example, you can use one service configuration to run and debug your application locally using the Windows Azure storage emulator and a different service configuration to publish your application to Windows Azure. For more information about service configurations, see Configuring a Windows Azure Project.
To Configure Your Application to Use Services That the Storage Account Provides
In Visual Studio open your Windows Azure solution. In Solution Explorer, open the shortcut menu for each role in your Windows Azure project that accesses the storage services and choose Properties.
A page with the name of the role is displayed in the Visual Studio editor. The page displays the fields for the Configuration tab.
In the property pages for the role, choose Settings.
In the Service Configuration list, choose the name of the service configuration that you want to edit.
If you want to make changes to all of the service configurations for this role, you can choose All Configurations. For more information about how to update service configurations, see Manage Connection Strings for Storage Accounts.
To modify any connection string settings, choose the … button next to the setting.
The Create Storage Connection String dialog box appears.
Under Connect using, choose the Your subscription option.
In the Subscription list, choose your subscription.
If the list of subscriptions doesn't include the one that you want, choose the Download Publish Settings link.
In the Account name list, choose your storage account name.
Windows Azure Tools obtains storage account credentials automatically by using the .publishsettings file. To specify your storage account credentials manually, choose the Manually entered credentials option, and then continue with this procedure. You can get your storage account name and primary key from the Management Portal. If you don’t want to specify your storage account settings manually, choose the OK button to close the dialog box.
Choose the Enter storage account credentials link.
In the Account name box, enter the name of your storage account.
Log into the Management Portal, and then choose the Storage button. The portal shows a list of storage accounts. If you choose an account, a page for it opens. You can copy the name of the storage account from this page. If you are using a previous version of the Management Portal, the name of your storage account appears in the Storage Accounts view of the Management Portal. To copy this name, highlight it in the Properties window of this view, and then choose the Ctrl-C keys. To paste the name into Visual Studio, choose the Account name text box, and then choose the Ctrl+V keys.
In the Account key box, enter your primary key, or copy and paste it from the Management Portal.
To copy this key from the Management Portal:
At the bottom of the page for the appropriate storage account, choose the Manage Keys button.
On the Manage Keys Access page, select the text of the primary access key, and then choose the Ctrl+C keys.
In Windows Azure Tools, paste the key into the Account key box.
You must select one of the following options to determine how the service will access the storage account:
Use HTTP. This is the standard option. For example, http://<account name>.blob.core.windows.net.
Use HTTPS for a secure connection. For example, https://<accountname>.blob.core.windows.net.
Specify custom endpoints for each of the three services. You can then type these endpoints into the field for the specific service.
If you create custom endpoints this allows you to create a more complex connection string. When you use this string format, you can specify storage service endpoints that include a custom domain name that you have registered for your storage account with the Blob service. Also you can grant access only to blob resources in a single container through a shared access signature. For more information about how to create custom endpoints, see How to Configure Connection Strings.
To save these connection string changes, choose the OK button and then choose the Save button on the toolbar.
After you save these changes, you can get the value of this connection string in your code by using . When you publish your application to Windows Azure, choose the service configuration that contains the Windows Azure storage account for the connection string. After your application is published, verify that the application works as expected against the Windows Azure storage services