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@2withcommand: buildAndPushand 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 thanlatestso the platform sees a changed image and restarts.
Related guides
How to Deploy a Container to Azure Container Apps With Azure PipelinesDeploy a container image to Azure Container Apps from Azure Pipelines with the AzureContainerApps@1 task, pas…
How to Deploy a Web App With the AzureWebApp Task in Azure PipelinesDeploy a built package to Azure App Service from Azure Pipelines with the AzureWebApp@1 task, pointing it at…