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. Select App Services in the Azure portal left navigation, and then select the web app you want to deploy.

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

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

    Select source control service, then select Authorize.

  4. 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: Use the App Service build service

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

  1. Select App Services in the Azure portal left navigation, and then select the web app 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 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.

    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: Use Azure Pipelines

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

For Azure App Service to create continuous delivery Azure Pipelines in your Azure DevOps organization:

  • 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.

To configure Azure Pipelines (Preview):

  1. Select App Services in the Azure portal left navigation, and then select the web app you want to deploy.

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

  3. On the Build provider page, select Azure Pipelines (Preview), and then select Continue.

  4. On the Configure page, in the Code section:

    • 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 Azure Repos, select the Azure DevOps Organization, Project, Repository, and Branch you want to deploy continuously, or configure a new Azure DevOps organization.

      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.

  5. Select Continue.

  6. For Azure Repos, in the Build section, specify the language framework that Azure Pipelines should use to run build tasks, and then select Continue.

  7. On the Test page, choose whether to enable load tests, and then select Continue.

  8. Depending on your App Service plan pricing tier, you may see a Deploy to staging page. Choose whether to enable deployment slots, and then select Continue.

    Note

    Azure Pipelines doesn't allow continuous delivery to the production slot. This restriction prevents accidental deployments to production. Set up continuous delivery to a staging slot, verify the changes there, and then swap the slots when you are ready.

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

    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

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 the same ones that are run in production. Therefore, the deployment can fail because of locked files. The app in production may also behave unpredictably during deployment, because not all the files updated at the same time. 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 Mecurial 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