Created
January 16, 2024 12:59
-
-
Save riosengineer/004e28cb4d2a2e10369ae7b1852a340e to your computer and use it in GitHub Desktop.
Azure Container Apps ADO Pipeline Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
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