0

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?

Lóri Nóda
  • 694
  • 1
  • 10
  • 20
  • are you pushing your image manually ? you can use a CICD tool to push then create a new revision – Thomas Jun 17 '23 at 05:00

1 Answers1

1

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. enter image description here

enter image description here

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.

enter link description here

enter image description here

I also made a minor change in the code and ran the pipeline to ensure that continuous deployment (CD) is working as expected.

enter image description here

HowAreYou
  • 605
  • 2
  • 6