Skip to content

Instantly share code, notes, and snippets.

@riosengineer
Created January 16, 2024 12:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save riosengineer/004e28cb4d2a2e10369ae7b1852a340e to your computer and use it in GitHub Desktop.
Save riosengineer/004e28cb4d2a2e10369ae7b1852a340e to your computer and use it in GitHub Desktop.
Azure Container Apps ADO Pipeline Example
---
trigger:
branches:
include:
- main
paths:
exclude:
- '**/*.yaml'
variables:
# Docker build & push connection
- name: dockerServiceConnection
value: 'YOUR_DOCKER_REG_CONNECTION'
# ADO ARM Connection
- name: azureServiceConnection
value: 'YOUR_ARM_CONNECTION'
# Resource Group name where the ACA is deployed to
- name: aca-rg
value: 'YOUR-ACA-RG'
# Azure Container App name within your ACA enviornment
- name: aca-name
value: 'YOUR-ACA-NAME'
- name: aca-acr
value: 'YOUR-ACR.azurecr.io'
# Azure Container Registry repository where the image resides
- name: aca-repo
value: 'YOUR-ACR-REPO'
# Azure DevOps Enviornment for deployment history + approvals
- name: ado-env
value: 'YOUR-ADO-ENVIORNMENT'
# Build tag based on ADO pipeline Build Id
- name: tag
value: '$(Build.BuildId)'
pool:
vmImage: ubuntu-latest
stages:
- stage: Build
displayName: Build & Push Docker Image
jobs:
- job: BuildDocker
displayName: Build & Push Docker Image
steps:
- task: Docker@2
displayName: Build and push an image to container registry
inputs:
command: buildAndPush
repository: $(aca-repo)
dockerfile: 'Dockerfile' # Change if your Dockerfile doesn't sit in root of the repo
containerRegistry: $(dockerServiceConnection)
tags: |
$(tag)
- stage: Deploy
displayName: Deploy ACA
dependsOn: Build
jobs:
- deployment: ACADeploy
displayName: Deploy Azure Container App
environment: $(ado-env)
strategy:
runOnce:
deploy:
steps:
- task: AzureCLI@2
displayName: Updating ACA image
inputs:
azureSubscription: $(azureServiceConnection)
scriptType: 'pscore'
scriptLocation: 'inlineScript'
inlineScript: |
az containerapp update -n $(aca-name) -g $(aca-rg) --image $(aca-acr)/$(aca-repo):$(Build.BuildId)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment