Deploy your ASP.NET app to an Azure Cloud Service (Classic)

TFS 2017 | TFS 2015

Note

In Microsoft Team Foundation Server (TFS) 2018 and previous versions, build and release pipelines are called definitions, runs are called builds, service connections are called service endpoints, stages are called environments, and jobs are called phases.

Here we'll show you how to set up continuous deployment of your ASP.NET app to an Azure Cloud Service using Azure Pipelines. Continuous deployment means starting an automated deployment pipeline whenever a new successful build is available.

You can also use these steps to deploy your app to an Azure Government Cloud or to Azure Stack.

Get set up

Begin with a CI build

Before you begin, you'll need a CI build that publishes your Cloud Service package. To set up CI, see:

Azure storage

An Azure blob storage container is required for deploying to Azure cloud services. Carry out the following steps in the Azure portal to create one.

  1. Sign into the Azure management portal and choose the +New icon in the left panel, then choose Data + Storage. Select Storage Account from the list.

  2. At the bottom of the Storage Account blade, in the Select a deployment model list, choose Classic, and then choose Create.

  3. In the Create Storage Account blade:

    • Enter a name for the new storage account.
    • Select an existing Resource Group, or create a new one.
    • Select a location for the new storage account.
    • Leave all the other settings at their default values, and choose Create.

  4. After the storage account has been created, open its blade and choose the Blobs tile. In the Blob service blade, choose the Containers tile and, in the Container blade, choose the +Container icon at the top to create a new container.

  5. In the New Container blade, type a name for the container. Select Container in the Access type list, and choose Create.

Define and test your CD release pipeline

Continuous deployment (CD) means starting an automated release pipeline whenever a new successful build is available. Your CD release pipeline picks up the artifacts published by your CI build and then deploys them to your Azure Cloud Service.

  1. Do one of the following:

    • If you've completed a CI build (see above) then, in the build's Summary tab under Deployments, choose Create release followed by Yes. This starts a new release pipeline that's automatically linked to the build pipeline.

    • Open the Releases tab of Azure Pipelines, open the + drop down in the list of release pipelines, and choose Create release pipeline.

  2. Select the Azure Cloud Service Deployment template and choose Apply.

  3. If you created your new release pipeline from a build summary, check that the build pipeline and artifact is shown in the Artifacts section on the Pipeline tab. If you created a new release pipeline from the Releases tab, choose the + Add link and select your build artifact.

    Selecting the build artifact

  4. Choose the Continuous deployment icon in the Artifacts section, check that the continuous deployment trigger is enabled, and add a filter to include the main branch.

    Checking or setting the Continuous deployment trigger

  5. Open the Tasks tab and select the Stage 1 item. Configure the task variables as follows:

    • Azure Subscription (Classic): Select an Azure Classic service connection. If you have not created one already, create one now by choosing Add. Then return to your release pipeline, refresh the Azure Subscription list, and select the connection you created.

    • Storage account: Select the storage account you created earlier.

    • Service name: Select the name of an existing cloud service, or enter the name of a new cloud service.

    Note

    If your Azure subscription is defined in an Azure Government Cloud, ensure your deployment pipeline meets the relevant compliance requirements. For more information, see Azure Government Cloud deployments.

    Note

    Some settings for the tasks may have been automatically defined as stage variables when you created a release pipeline from a template. These settings cannot be modified in the task settings; instead you must select the parent stage item in order to edit these settings.

  6. Edit the name of the release pipeline, click Save, and click OK. The default stage is named Stage1, which you can edit by clicking directly on the name.

You're now ready to create a release, which means to run the release pipeline with the artifacts produced by a specific build. This will result in deploying the build to Azure:

  1. Choose + Release and select Create a release.

  2. In the Create a new release panel, check that the artifact version you want to use is selected and choose Create.

  3. Choose the release link in the information bar message. For example: "Release Release-1 has been created".

  4. In the pipeline view, choose the status link in the stages of the pipeline to see the logs and agent output.

  5. After the release is complete, navigate to your app and verify its contents.

FAQ

I use TFS on-premises and I don't see some of these features. Why not?

Some of these features are available only on Azure Pipelines and not yet available on-premises. Some features are available on-premises if you have upgraded to the latest version of TFS.