I am working on Azure container app. I have already created the container app from Azure portal with the default image which is from DockerHub registry.
But Now I want to deploy actual code to that container app and I am using az containerapp update
, In github action but I am getting the error
ERROR: (InvalidParameterValueInContainerTemplate) The following field(s) are either invalid or missing. Field 'template.containers.simple-hello-world-container.image' is invalid with details: 'Invalid value: "***/demo-api:1.0.1": GET https:?scope=repository%3Ademo-api%3Apull&service=***: UNAUTHORIZED: authentication required, visit https://aka.ms/acr/authorization for more information.';
other config are updated to that container but image and image registry is not changed. Here is my github action command
- name: Azure Deploy App
uses: azure/CLI@v1
with:
inlineScript: |
az containerapp update
--name ca-demoapi
--resource-group rg-ca
--image ${{ secrets.ACR_SERVER }}/${{ steps.dotenv.outputs.IMAGE_NAME }}:${{ steps.dotenv.outputs.IMAGE_TAG }} --cpu 1.0
--memory 2.0Gi
--min-replicas 0
--max-replicas 2
--scale-rule-name http-rule-10-req
--scale-rule-type http
--scale-rule-http-concurrency 10
--container-name ${{ steps.dotenv.outputs.IMAGE_NAME }}
--ingress 'external'
Complete Github action, which build image, push to ACR and then deploy
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Load dotenv
id: dotenv
uses: falti/dotenv-action@v1.0.4
with:
path: .env
log-variables: true
export-variables: true
keys-case: bypass
- name: Log into Azure Container Registry
uses: docker/login-action@v2
with:
registry: ${{ secrets.ACR_SERVER }}
username: ${{ secrets.AZURE_CLIENT_ID }}
password: ${{ secrets.AZURE_CLIENT_SECRET }}
- name: Build image
run: |
docker build \
-t ${{ steps.dotenv.outputs.IMAGE_NAME }}:${{ steps.dotenv.outputs.IMAGE_TAG }} .
- name: Re-Tag image For ACR
run: |
docker tag ${{ steps.dotenv.outputs.IMAGE_NAME }}:${{ steps.dotenv.outputs.IMAGE_TAG }} ${{ secrets.ACR_SERVER }}/${{ steps.dotenv.outputs.IMAGE_NAME }}:${{ steps.dotenv.outputs.IMAGE_TAG }}
- name: Push image to ACR
run: |
docker push ${{ secrets.ACR_SERVER }}/${{ steps.dotenv.outputs.IMAGE_NAME }}:${{ steps.dotenv.outputs.IMAGE_TAG }}
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Load dotenv
id: dotenv
uses: falti/dotenv-action@v1.0.4
with:
path: .env
log-variables: true
export-variables: true
keys-case: bypass
- name: Azure login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Azure Deploy App
uses: azure/CLI@v1
with:
inlineScript: |
az containerapp update \
--name ca-demoapi \
--resource-group rg-ca \
--image ${{ secrets.ACR_SERVER }}/${{ steps.dotenv.outputs.IMAGE_NAME }}:${{ steps.dotenv.outputs.IMAGE_TAG }}
--cpu 1.0 \
--memory 2.0Gi \
--min-replicas 0 \
--max-replicas 2 \
--scale-rule-name http-rule-10-req \
--scale-rule-type http \
--scale-rule-http-concurrency 10
--container-name ${{ steps.dotenv.outputs.IMAGE_NAME }} \
--ingress 'external'
- name: Azure CLI script
uses: azure/CLI@v1
with:
inlineScript: |
az logout
az cache purge
az account clear
So how can i update the image of the container in CI/ CD pipeline?