Azure / container-apps-deploy-action

GitHub Action for building and deploying Azure Container Apps
MIT License
50 stars 30 forks source link

Error: argument `targetPort` only works if the container app does not exist yet #105

Open konsti opened 5 months ago

konsti commented 5 months ago

When you set the targetPort argument in the GitHub Action for deploying Container Apps on Azure, the initial deployment succeeds, but subsequent updates fail.

Here's an example configuration that triggers the issue:

- name: Deploy Container App
  uses: azure/container-apps-deploy-action@v2
  with:
    containerAppName: test-app
    resourceGroup: [...resourceGroup]
    imageToDeploy: [...imageUrl]
    targetPort: 8080

Identified Issue:

The root of the problem seems to be the Azure CLI command az containerapp update, which lacks support for the target-port argument. Consequently, this Action defaults to using the up command for both initial deployments and updates. However, if the app is already running, attempting an update with the up command and a specified target-port results in a Forbidden error:

/usr/bin/az containerapp up [...] --target-port 8080
ERROR: Operation returned an invalid status 'Forbidden'

As the ingress setup is only needed during creation, this Action should skip the targetPort and only update the container or (if specified) delete and re-create the container if the targetPort changed