Build and deploy your ASP.NET Core app to Azure

Last Update: 5/26/2017

Team Services | TFS 2017 RTM | Previous versions: XAML Build, Release

Are you new to Team Build, Release Management, or CI/CD? If so, we recommend that you first read CI/CD for newbies and then come back here after that.

ASP.NET Core is a lean and composable framework for building web and cloud applications. In this walkthrough we'll show you how to create a continuous integration (CI) and continuous deployment (CD) pipeline to automatically build and deploy your ASP.NET Core app to Azure.


If you don't yet have an app but want to try this out, then see the Q&A below.

To create your CI/CD pipeline, you'll do the following:

Get set up

Team Services account

You'll need an account on Visual Studio Team Services. To create one, visit Sign up for Team Services.

You can also use Team Foundation Server (TFS) if your organization requires the use of on-premises servers instead of Team Services, and we'll show some of those details. Also see Get Started with TFS for general information.

Set up local version control and a team project

Creating a release pipeline relies on having your application code in version control. To set up a local repository and connect it to a remote repository in a team project, follow the instructions in either Share your code with Git and Visual Studio or Share your code with TFVC and Visual Studio.

Create the Azure app service

An Azure App Service is where you'll deploy your application. Technically speaking, an app service is a resource with a specific pricing tier in Azure that can then host multiple, distinct applications. In this example we'll use a Web App. If you're creating a new App Service for this example, you can use the Free pricing tier.

To create a new Web App, simply go to the App Services blade on the Azure portal, click +Add, select the Web App template, click Create, and enter a name and other details. The web app URL will then be {name}

Can I use an existing Azure account? ▼

If you have an existing Azure account, you can certainly use a new or existing App Service in that account for this walkthrough.

How do I create a new Azure account with free credits? ▼

If you don't yet have an Azure account, you can get started with free credits at

Alternately, consider signing up for Visual Studio Dev Essentials which gives you $25/month in Azure credit each month for a full year.

Can I just use a temporary App Service instead? ▼

Yes, just visit Create your Azure App Service App to set up a Web App for temporary use (1 hour). On that page, do the following:

  1. Select Web App and choose Next.
  2. Select Empty Site and choose Create (we use an empty site because you already have the necessary application code in your Visual Studio project).
  3. Enter your Microsoft account credentials when requested.
In a few moments the site will then give you a URL such as This is the URL of your live site to which we'll deploy the application.

Learn more at the Web Apps Overview.

Define and test your CI build process

Continuous integration means starting an automated build whenever new code is committed to or checked into the team project's source control repository. This gives you immediate feedback that the code builds and can potentially be deployed. You can also run automated tests. Finally, this CI build will produce a web deploy package artifact and publish it so that it can be consumed by your CD process.

Create the build definition

In this section we'll create a build definition for the ASP.NET Core web application, starting with an empty definition and adding each step manually. The result will be a .ZIP file for the web application that's stored where it can be accessed by the release definition we'll create in the next section.

  1. Open your team project in your web browser ▼

    Browse to team project

    (If you don't see your team project listed on the home page, select Browse.)

    • On-premises TFS: http://{your_server}:8080/tfs/DefaultCollection/{your_team_project}
    • Visual Studio Team Services: https://{your_account}{your_team_project}

    The TFS URL doesn't work for me. How can I get the correct URL?

  2. Create a build definition (Build & Release tab > Builds) ▼

    Build tab

  3. Select the ASP.NET Core (PREVIEW) process.
  4. As the repository source, select the team project, repository, and branch.

Review the tasks

To get started with a new app, you don't need to modify any of the tasks, but feel free to familiarize yourself with them. You can always make customizations later.

After you select the ASP.NET Core (PREVIEW) template, instances of the .NET Core task are added to your build definition to restore, build, test, and publish the app.

A publish build artifacts task is also added. This task publishes your web deploy package as an artifact. Your CD release process uses this package to deploy your app.


There's a known issue with the .NET Core task publish command created by the template. it doesn't target a specific project. The workaround is to make sure you've got only a single project in your repository.

Review the variables

Variables give you a convenient way to get key bits of data into various parts of your build process. You refer to a variable using $(<variable_name>). Some variables are pre-defined; others you need to define directly.

On the Variables tab you'll find the following variables:

Name Value
BuildConfiguration release
BuildPlatform any cpu

Select the default agent queue

Click the Options or General tab.


In general your build will run faster with private agents, especially if you don't clean the repository.

Visual Studio 2017

For the default agent queue, select Hosted VS2017. If you're using TFS or Team Services with private agents, select the queue connected with a pool that has agents with Visual Studio 2017 installed.

Visual Studio 2015

For the default agent queue, select Hosted. If you're using TFS or Team Services with private agents, select the queue connected with a pool that has agents with Visual Studio 2015 installed.

Enable continuous integration (CI)

On the Triggers tab, enable continuous integration (CI). This tells the system to queue a build whenever someone on your team commits or checks in new code.

Queue and test the build

Save the build definition and queue a new build by selecting the Queue new build command.

Once the build is done (after a couple of minutes), click on the build number (such as "Build 332"), click the Artifacts tab, and then Explore to see the zip file produced by the build. This is the web deploy package that your release definition will consume to deploy your app.

After you've run the build, you're ready to create a release definition to deploy your app to Azure.

Define and test your CD release process

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

  1. Do one of the following:

    • If you've just completed a CI build (see above), choose the link to the completed build (for example, Build 1634). In the build's Summary tab under Deployments, choose Create release followed by Yes. This starts a new release definition that's automatically linked to the build definition.

    • Open the Releases tab of the Build & Release hub, open the + drop-down in the list of release definitions, and choose Create release definition

  2. Select the Azure App Service Deployment template and choose Next.

  3. In the Artifacts section, make sure your CI build definition for the Web deploy package is selected as the artifact source.

  4. Select the Continuous deployment check box, and then choose Create.

  5. Select the Deploy Azure App Service task and configure it as follows:

    Task step Parameters
    Deploy: Azure App Service Deploy
    Deploy: Azure App Service Deploy
    Deploy the app to Azure App Services
    Azure Subscription: Select a connection from the list under Available Azure Service Connections. If no connections appear, choose Manage, select New Service Endpoint then Azure Resource Manager, and follow the prompts. Then return to your release definition, refresh the AzureRM Subscription list, and select the connection you just created. Note: If your Azure subscription is defined in an Azure Government Cloud, ensure your deployment process meets the relevant compliance requirements. For more details, see Azure Government Cloud deployments.
    App Service Name: the name of the web app (the part of the URL without
    Deploy to Slot: make sure this is cleared (the default)
    Virtual Application: leave blank
    Web Deploy Package: $(System.DefaultWorkingDirectory)\**\*.zip (the default)
    Advanced: Take App Offline: If you run into locked .DLL problems when you test the release, as explained below, try selecting this check box.

    If you are using TFS (rather than Team Services) you may find that the Azure App Service Deploy task is not available, depending on your version and update of TFS. Instead, you can use the Azure Web App Deployment task to deploy your app.

  6. Edit the name of the release definition, choose Save, and choose OK. Note that the default environment is named Environment1, which you can edit by clicking directly on the name.

You're now ready to create a release, which means to start the process of running the release definition with the artifacts produced by a specific build. This will result in deploying the build to Azure:

  1. Choose + Release and select Create Release.

  2. Select the build you just completed in the highlighted drop-down list and choose Create.

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

  4. Open the Logs tab to watch the release console output.

  5. After the release is complete, navigate to your site running in Azure using the Web App URL http://{web_app_name}, and verify its contents.


If you encounter deployment failures with a message about locked .DLL files, then try selecting Advanced: Take App Offline, as mentioned above.

Commit a change and see it automatically go live

Now you get to see the magic of a release pipeline at work! You'll make a change in Visual Studio, commit it or check it in to the source repository, and then let the build and release definitions take care of the rest.

  1. On your deployed web site, click About at the top, and examine the page. We'll change the "Use this area..." text to something different.

  2. In Visual Studio, switch to Solution Explorer, expand src > {project name} > Views > Home and open About.cshtml.

  3. Change the text within the <p> tag, for example, to Hello continuous integration and continuous deployment!

  4. Save the file, push/check-in the changes to the Team Project:

    • If you're using Git in Visual Studio, click the changes icon on the status bar:

      Location of the changes button on the Visual Studio status bar

      Then enter a commit message, click Commit All, click the Sync link, then click Outgoing Commits > Push. This will push the changes to respiratory on Team Services.

    • If you're using Team Foundation version control (TFVC), switch to the Team Explorer pane, then to Pending Changes where you should see About.cshtml listed. Enter a comment and click Check In.

  5. Once the push/check-in is complete, switch to Team Services in your browser.

  6. Navigate to Builds and click on your build definition. You should see a build in progress:

    A continuous integration build running in Team Services

  7. When the build has completed, navigate to Releases and you should see that a release has started for that build:

    A continuous deployment release running in Team Services

  8. When the release has completed, browse to your web site, refresh the page, and see that the change has been deployed.


How do I create an ASP.NET Core solution?

  1. If you are using Visual Studio 2015 Update 3, then install .NET Core 1.0.1 - VS 2015 Tooling Preview 2 or newer. If you are using Visual Studio 2017, then you're all set and can skip to the next step.

  2. In Visual Studio, connect to your team project.

  3. On the Team Explorer home page (Keyboard: Ctrl + 0, H), under Solutions, click New.

  4. Select the Visual C# templates node, the Web sub-node.

  5. Select ASP.NET Core Web Application (.NET Core) and click OK.

  6. Select Web Application from the template list.

  7. Make sure Authentication is set to No Authentication.

  8. Visual Studio 2013: Make sure Host in the cloud is not checked, and then click OK.

  9. Commit and push (Git) or check in (TFVC) your code.

Where can I learn more about ASP.NET Core?

Introduction to ASP.NET Core

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

Some of these features are available only on Visual Studio Team Services and not yet available on-premises. Some features are available on-premises if you have upgraded to the latest version of TFS.