Skip to content
Latchkey

How to Push an Image to ACR and Deploy It With Azure Pipelines

Use Docker@2 buildAndPush against an ACR service connection, then point AzureWebAppContainer at the pushed tag.

Build and push the image with Docker@2, then deploy it to App Service for Containers with AzureWebAppContainer@1 using the same immutable tag.

Steps

  • Create a Docker Registry service connection to your ACR.
  • Run Docker@2 with command: buildAndPush and a build-id tag.
  • Deploy the tag with AzureWebAppContainer@1.

azure-pipelines.yml

azure-pipelines.yml
pool:
  vmImage: ubuntu-latest
variables:
  tag: '$(Build.BuildId)'
steps:
  - task: Docker@2
    inputs:
      containerRegistry: 'myacr'
      repository: 'web'
      command: buildAndPush
      Dockerfile: 'Dockerfile'
      tags: '$(tag)'
  - task: AzureWebAppContainer@1
    inputs:
      azureSubscription: 'my-azure-rm'
      appName: 'my-container-app'
      imageName: 'myacr.azurecr.io/web:$(tag)'

Gotchas

  • The Docker Registry service connection and the azureRM connection are separate; you need both.
  • Tag with $(Build.BuildId) rather than latest so the platform sees a changed image and restarts.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →