Continuous deployment to Azure App Service

Azure App Service enables continuous deployment from GitHub, BitBucket, and Azure Repos repositories by pulling in the latest updates. This article shows you how to use the Azure portal to continuously deploy your app through the Kudu build service or Azure Pipelines.

For more information on the source control services, see Create a repo (GitHub), Create a repo (BitBucket), or Create a new Git repo (Azure Repos).

Prepare your repository

To get automatic builds from Azure App Service Kudu build server, make sure that your repository root has the correct files in your project.

Runtime Root directory files
ASP.NET (Windows only) *.sln, *.csproj, or default.aspx
ASP.NET Core *.sln or *.csproj
PHP index.php
Ruby (Linux only) Gemfile
Node.js server.js, app.js, or package.json with a start script
Python *.py, requirements.txt, or runtime.txt
HTML default.htm, default.html, default.asp, index.htm, index.html, or iisstart.htm
WebJobs <job_name>/run.<extension> under App_Data/jobs/continuous for continuous WebJobs, or App_Data/jobs/triggered for triggered WebJobs. For more information, see Kudu WebJobs documentation.
Functions See Continuous deployment for Azure Functions.

To customize your deployment, include a .deployment file in the repository root. For more information, see Customize deployments and Custom deployment script.

Note

If you develop in Visual Studio, let Visual Studio create a repository for you. The project is immediately ready to be deployed by using Git.

Authorize Azure App Service

To use Azure Repos, make sure your Azure DevOps organization is linked to your Azure subscription. For more information, see Set up an Azure DevOps Services account so it can deploy to a web app.

For Bitbucket or GitHub, authorize Azure App Service to connect to your repository. You only need to authorize with a source control service once.

  1. In the Azure portal, search for App Services and select.

    Search for App services.

  2. Select the App Service you want to deploy.

    Select your app.

  3. On the app page, select Deployment Center in the left menu.

  4. On the Deployment Center page, select GitHub or Bitbucket, and then select Authorize.

    Select source control service, then select Authorize.

  5. Sign in to the service if necessary, and follow the authorization prompts.

Enable continuous deployment

After you authorize a source control service, configure your app for continuous deployment through the built-in Kudu App Service build server, or through Azure Pipelines.

Option 1: Kudu App Service

You can use the built-in Kudu App Service build server to continuously deploy from GitHub, Bitbucket, or Azure Repos.

  1. In the Azure portal, search for App Services, and then select the App Service you want to deploy.

  2. On the app page, select Deployment Center in the left menu.

  3. Select your authorized source control provider on the Deployment Center page, and select Continue. For GitHub or Bitbucket, you can also select Change account to change the authorized account.

    Note

    To use Azure Repos, make sure your Azure DevOps Services organization is linked to your Azure subscription. For more information, see Set up an Azure DevOps Services account so it can deploy to a web app.

  4. For GitHub or Azure Repos, on the Build provider page, select App Service build service, and then select Continue. Bitbucket always uses the App Service build service.

    Select App Service build service, then select Continue.

  5. On the Configure page:

    • For GitHub, drop down and select the Organization, Repository, and Branch you want to deploy continuously.

      Note

      If you don't see any repositories, you may need to authorize Azure App Service in GitHub. Browse to your GitHub repository and go to Settings > Applications > Authorized OAuth Apps. Select Azure App Service, and then select Grant. For organization repositories, you must be an owner of the organization to grant the permissions.

    • For Bitbucket, select the Bitbucket Team, Repository, and Branch you want to deploy continuously.

    • For Azure Repos, select the Azure DevOps Organization, Project, Repository, and Branch you want to deploy continuously.

      Note

      If your Azure DevOps organization isn't listed, make sure it's linked to your Azure subscription. For more information, see Set up an Azure DevOps Services account so it can deploy to a web app..

  6. Select Continue.

    Fill in repository information, then select Continue.

  7. After you configure the build provider, review the settings on the Summary page, and then select Finish.

  8. New commits in the selected repository and branch now deploy continuously into your App Service app. You can track the commits and deployments on the Deployment Center page.

    Track commits and deployments in Deployment Center

Option 2: Azure Pipelines

If your account has the necessary permissions, you can set up Azure Pipelines to continuously deploy from GitHub or Azure Repos. For more information about deploying through Azure Pipelines, see Deploy a web app to Azure App Services.

Prerequisites

For Azure App Service to create continuous delivery using Azure Pipelines, your Azure DevOps organization should have the following permissions:

  • Your Azure account must have permissions to write to Azure Active Directory and create a service.

  • Your Azure account must have the Owner role in your Azure subscription.

  • You must be an administrator in the Azure DevOps project you want to use.

GitHub + Azure Pipelines

  1. In the Azure portal, search for App Services, and then select the App Service you want to deploy.

  2. On the app page, select Deployment Center in the left menu.

  3. Select GitHub as the source control provider on the Deployment Center page and select Continue. For GitHub, you can select Change Account to change the authorized account.

    source control

  4. On the Build Provider page, select Azure Pipelines (Preview), and then select Continue.

    build provider

  5. On the Configure page, in the Code section, select the Organization, Repository, and Branch you want to deploy continuously and select Continue.

    Note

    If you don't see any repositories, you may need to authorize Azure App Service in GitHub. Browse to your GitHub repository and go to Settings > Applications > Authorized OAuth Apps. Select Azure App Service, and then select Grant. For organization repositories, you must be an owner of the organization to grant the permissions.

    In the Build section, specify the Azure DevOps Organization, Project, language framework that Azure Pipelines should use to run build tasks, and then select Continue.

    build provider

  6. After you configure the build provider, review the settings on the Summary page, and then select Finish.

    build provider

  7. New commits in the selected repository and branch now deploy continuously into your App Service. You can track the commits and deployments on the Deployment Center page.

    Track commits and deployments in Deployment Center

Azure Repos + Azure Pipelines

  1. In the Azure portal, search for App Services, and then select the App Service you want to deploy.

  2. On the app page, select Deployment Center in the left menu.

  3. Select Azure Repos as the source control provider on the Deployment Center page and select Continue.

    source control

  4. On the Build Provider page, select Azure Pipelines (Preview), and then select Continue.

    source control

  5. On the Configure page, in the Code section, select the Organization, Repository, and Branch you want to deploy continuously and select Continue.

    Note

    If your existing Azure DevOps organization isn't listed, you may need to link it to your Azure subscription. For more information, see Define your CD release pipeline.

    In the Build section, specify the Azure DevOps Organization, Project, language framework that Azure Pipelines should use to run build tasks, and then select Continue.

    build provider

  6. After you configure the build provider, review the settings on the Summary page, and then select Finish.

    build provider

  7. New commits in the selected repository and branch now deploy continuously into your App Service. You can track the commits and deployments on the Deployment Center page.

Disable continuous deployment

To disable continuous deployment, select Disconnect at the top of your app's Deployment Center page.

Disable continuous deployment

What happens to my app during deployment?

All the officially supported deployment methods make changes to the files in the /home/site/wwwroot folder of your app. These files are used to run your app. Therefore, the deployment can fail because of locked files. The app may also behave unpredictably during deployment, because not all the files updated at the same time. This is undesirable for a customer-facing app. There are a few different ways to avoid these issues:

Use unsupported repos

For Windows apps, you can manually configure continuous deployment from a cloud Git or Mercurial repository that the portal doesn't directly support, such as GitLab. You do it by choosing the External box in the Deployment Center page. For more information, see Set up continuous deployment using manual steps.

Additional resources