This blog explains how to deploy an Azure container app using a YAML template.
Pre-requisites:
- Azure container app environment
- Azure container registry with docker image
Create a YAML file and add following content to it.
Add values for Container App name, resource group name, Azure subscription id where resources going to be created, Container App Environment name and resource group, Azure Container Registry (ACR) name, ACR username, ACR password, image path and image tag.
Following YAML can be used to create an Azure Container App using a docker image in ACR in the same Azure subscription or different Azure subscription.
- Container App will get created with startup health probe, scaling enabled with one minimum replica and 10 maximum replicas.
- 100% traffic goes to latest revision.
location: West Europe name: <<containerappname>> resourceGroup: <<containerappresourcegroup>> type: Microsoft.App/containerApps
#azure resource tags tags: ProvisionedWith: CLI
Project: Demo properties: managedEnvironmentId: /subscriptions/<<azuresubscriptionid>>/resourceGroups/<<containerappenvironmentresourcegroup>>/providers/Microsoft.App/managedEnvironments/<<containerappenvironmentname>> configuration: activeRevisionsMode: Single
#container registry password - can use any name as secret name secrets:
- name: acrpw value: <<secret value>> ingress: external: true allowInsecure: false targetPort: 80 traffic: - latestRevision: true weight: 100 transport: Auto registries: - passwordSecretRef: acrpw server: <<containerregistryname>>.azurecr.io username: <<containerregistryusername>> template: revisionSuffix: demorevision
#docker image and container registry information containers: - image: <<containerregistryname>>.azurecr.io/<<repository>>/<<imagetag>>
name: <<containerappname>>
image type: Private
#if there are any container app environment variables, use following format to add them env: - name: <<environmentvariablename>> value: <<environmentvariablevalue>> resources: cpu: 0.5 memory: 1Gi probes: - type: startup httpGet: path: "/health" port: 80 initialDelaySeconds: 30 periodSeconds: 10 scale: minReplicas: 1 maxReplicas: 10
Once YAML is ready, run following Azure CLI command to create a Container App.
az containerapp create --name <<containerappname>> --resource-group <<containerappresourcegroup>> --yaml <<path to YAML file>>
No comments:
Post a Comment