I have a new app deployed to azure container apps. The image is stored also on azure container registry.
What I would like, when I push a new image to lets say with develop tag, the container app recognizes that and creates a new revision.
How you can do that?
To automatically create new revisions in Azure container apps whenever a new version is available, you can utilize a CICD approach. Thanks @Thomas for suggesting the same. I followed the steps below to achieve this requirement.
First, I enabled managed identity in the Container app and assigned the AcrPull permission as shown in the screenshot.
Next, I created a CI/CD pipeline with two tasks. The first task is Docker@2(buildAndPush) and the second task is AzureContainerApps@1(creates new revision in Azure container app)
trigger: none
pool:
vmImage: ubuntu-latest
steps:
- task: Docker@2
displayName: Build & Push docker image to ACR
inputs:
containerRegistry: 'svc-acr' #using service connection for authenticating to ACR
repository: 'testimg'
command: 'buildAndPush'
Dockerfile: 'Dockerfile'
tags: |
develop
$(Build.BuildId)
- task: AzureContainerApps@1
inputs:
azureSubscription: 'svcv-g'
acrName: 'containerregistryvjy'
imageToDeploy: 'containerregistryvjy.azurecr.io/testimg:$(Build.BuildId)'
containerAppName: 'acavjy01'
resourceGroup: 'rg-name'
containerAppEnvironment: 'managedEnvironment-rgname-bfb2'
To test the flow, save and run the pipeline and verify the output.
I also made a minor change in the code and ran the pipeline to ensure that continuous deployment (CD) is working as expected.