Azure / container-apps-deploy-action

GitHub Action for building and deploying Azure Container Apps
MIT License
52 stars 29 forks source link

Wrong argument for environment variables when updating #89

Open ohmios opened 9 months ago

ohmios commented 9 months ago

Version 2 of this action passes --env-vars as a parameter to az containerapp update, but according to the documentation the parameter should be --set-env-vars. This causes the following error: unrecognized arguments: --env-vars.

image

The content of my workflow file that caused the error is:

name: Dockerize and deploy SvelteKit project to Azure Container App

on:
  push:
    branches:
      - main
  workflow_dispatch:

permissions:
  id-token: write
  contents: read

jobs:
  build-push-and-deploy:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v4.1.1

      - name: Login to Azure
        uses: Azure/login@v1.5.1
        with:
          client-id: ${{ secrets.AZURE_CLIENT_ID }}
          tenant-id: ${{ secrets.AZURE_TENANT_ID }}
          subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

      - name: Build and deploy app to Azure Container Apps
        uses: azure/container-apps-deploy-action@v2
        with:
          appSourcePath: ${{ github.workspace }}
          acrName: ${{ secrets.ACR_NAME }}
          containerAppName: ${{ secrets.CA_NAME }}
          resourceGroup: ${{ secrets.CA_RG_NAME }}
          imageToBuild: ${{ secrets.ACR_URL }}/my-app:${{ github.SHA }}.${{ github.RUN_ATTEMPT }}
          targetPort: 3000
          environmentVariables: >
              "AUTHORITY=secretref:authority"
              "TENANT_ID=secretref:tenant-id"
              "CLIENT_ID=secretref:client-id"
              "CLIENT_SECRET=secretref:client-secret"
              "REDIRECT_URI=secretref:redirect-uri"
              "COSMOS_ENDPOINT=secretref:cosmos-endpoint"
              "COSMOS_DATABASE=secretref:cosmos-database" 
              "COSMOS_CONTAINER=secretref:cosmos-container"

It works fine as long as the environmentVariables parameter is not set. The only difference between the content of this file and my current file is that I use Azure CLI Action to set the enviroment variables in a previous step, as a workaround.

daniv-msft commented 9 months ago

Thanks @ohmios ! @cormacpayne, could you please confirm the discrepancy on our side?

cormacpayne commented 9 months ago

@daniv-msft it looks like our intention is to use the --replace-env-vars argument when calling az containerapp update and --env-vars for other commands (such as create and up), but somehow we're getting into a flow where --env-vars is being used with update.

@snehapar9 would you mind taking a quick look since you recently worked on refactoring which command is being called for different flows?

snehapar9 commented 9 months ago

Thank you for opening this @ohmios! Do you mind sharing what your workflow file looks like? Would be helpful to determine why we're entering this flow based on the arguments provided to the action.

ohmios commented 9 months ago

@snehapar9 I have updated the issue with the content of my workflow file. Let me know if you need more information.

snehapar9 commented 9 months ago

Thank you @ohmios! We are working on this. Will let you know if we need more information.

harryli0108 commented 9 months ago

@ohmios The fix for this issue has just been merged. The latest v2 should now include this fix. Please don't hesitate to let us know if there's any further issue!

I'll close this issue in a few days if there's no other problems regarding to the env var command issue.

moderj commented 8 months ago

Hey I'm noticing an issue regarding the environmentVariables flag

This is the error it throws when running github action ERROR: unrecognized arguments: --replace-env-vars LOG_LEVEL=info DB_URL=secretref:*** DB_NAME=secretref:*** Error: The process '/usr/bin/az' failed with exit code 2 Error: The process '/usr/bin/az' failed with exit code 2

This is the stage: Screenshot 2024-02-13 102020

any help with that?