I have a container app with single-revision mode, and minimum replicas set to 1.
These are the steps of my Azure pipeline to deploy new changes to the app:
- script: |
docker login $(ACR_LOGIN_SERVER) -u $(ACR_USERNAME) -p $(ACR_PASSWORD)
displayName: "Login to Azure Container Registry"
- script: |
docker build . --no-cache --file Dockerfile -t $(ACR_LOGIN_SERVER)/$(ACR_QUERY_REPOSITORY_NAME):$(Build.SourceVersion)
workingDirectory: ./backend/server
displayName: "Build Docker image"
- script: |
docker push $(ACR_LOGIN_SERVER)/$(ACR_QUERY_REPOSITORY_NAME):$(Build.SourceVersion)
displayName: "Push image to Azure Container Registry"
- script: |
docker tag $(ACR_LOGIN_SERVER)/$(ACR_QUERY_REPOSITORY_NAME):$(Build.SourceVersion) $(ACR_LOGIN_SERVER)/$(ACR_QUERY_REPOSITORY_NAME):latest
docker push $(ACR_LOGIN_SERVER)/$(ACR_QUERY_REPOSITORY_NAME):latest
displayName: "Tag and push latest image to Azure Container Registry"
- task: AzureCLI@2
inputs:
azureSubscription: $(ARM_SUBSCRIPTION_ID)
scriptType: bash
scriptLocation: inlineScript
inlineScript: |
az containerapp up --name $(CONTAINER_APP_NAME) --resource-group $(RESOURCE_GROUP_NAME) --image $(ACR_LOGIN_SERVER)/$(ACR_QUERY_REPOSITORY_NAME):latest
displayName: "Deploy image to container app"
- task: AzureCLI@2
inputs:
azureSubscription: $(ARM_SUBSCRIPTION_ID)
scriptType: bash
scriptLocation: inlineScript
inlineScript: |
revisions=$(az containerapp revision list --name $(CONTAINER_APP_NAME) --resource-group $(RESOURCE_GROUP_NAME) | jq -r '.[0].name')
az containerapp revision restart --revision $revisions --resource-group $(RESOURCE_GROUP_NAME)
displayName: "Restart container app revision to renew replica"
After having set minimum replicas to 1, I am forced to add a step at the bottom to restart the replica. Otherwise, the new deployed changes won’t take effect.
Do I really have to add this step? Am I doing something wrong?
New contributor
damiangelis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.