Dela via


Prepare to publish or deploy a cloud service from Visual Studio

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

To publish a cloud service project, you must set up the following services as described in this article:

  • A cloud service to run your roles in the Azure environment, and
  • A storage account that provides access to the Blob, Queue, and Table services.

Create a cloud service

A cloud service runs your roles in the Azure environment. You can create a cloud service either in Visual Studio or through the Azure portal as described in the sections that follow.

Create a cloud service from Visual Studio

  1. With a previously created Cloud Service project, right-click the project select Publish.
  2. If necessary, sign in with the Microsoft or organizational account associated with your Azure subscription, then select Next to advance to the Settings page.
  3. A Create Cloud Service and Storage Account dialog appears (if not, select Create New from the Cloud Service list).
  4. Enter a case-insensitive name for your cloud service, which forms part of your URL and must be unique. Also choose a Region or Affinity Group, and select a Replication option.

Create a cloud service through the Azure portal

  1. Sign in to the Azure portal.
  2. Select Cloud Services (classic) on the left side of the page.
  3. Select + Add, then provide the required information (DNS name, subscription, resource group, and location). It's not necessary to upload a package at this point because you do that later in Visual Studio.
  4. Select Create to complete the process.

Create a storage account

A storage account provides access to the Blob, Queue, and Table services. You can create a storage account through Visual Studio or the Azure portal.

Create a storage account from Visual Studio

  1. In Solution Explorer with a previously created Cloud Service project, locate the Connected Services node within a role project, right-click, and select Add Connected Service. (In Visual Studio 2015, right-click the Storage node and select Create Storage Account.)
  2. In the Connected Services list that appears, select Cloud Storage with Azure Storage.
  3. In the Azure Storage dialog that appears, select +Create New Storage Account, which brings up a dialog in which you specify your subscription, a name fo the account, a pricing tier, resource group, and location.
  4. Select Create when you're done. The new storage account appears in the list of available storage accounts in your subscription.
  5. Select that account and select Add.

Create a storage account through the Azure portal

  1. Sign in to the Azure portal.
  2. Select + New on the top left.
  3. Select Storage under "Azure Marketplace," then Storage account - blob, file, table, queue from the right side.
  4. Provide the required information (name, deployment model, and so forth.
  5. Select Create to complete the process.

Configure your app to use the storage account

After you create a storage account, connecting to it from Visual Studio automatically updates the service configurations for the project, including URLs and access keys.

If you created a cloud service from Visual Studio using the Add Connected Service, you can check the connections by opening ServiceConfiguration.Cloud.cscfg and ServiceConfiguration.Local.cscfg.

If you created a cloud service through the Azure portal, follow the same steps in Create a storage account from Visual Studio but select the existing account rather than creating a new one. Visual Studio then updates the configuration for you.

To configure settings manually, use the property pages in Visual Studio for the applicable role in your cloud service project (right-click the role and select Properties). For more information, see Configuring a connection string to a storage account.

About access keys

The Azure portal shows the URLs that you can use to access resources in each of the 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.

Next steps

To learn more about publishing apps to Azure from Visual Studio, see Publishing a Cloud Service using the Azure Tools.