I am trying to set the environment variables of container in azure container app but getting issue when there is space on the value. my .env is as below
BD_PASSWORD=v=K1i2
WS_PROJECT_AR_DSO=https://example.com
AUTO_BATCH_SUBMIT_CRON_START_TIME=*/2 * * * *
EMAIL_WHITELIST=["a.com","b.net"]
I tried with key=value space-separated, but it failed I tried "key1=value" "key2=value2" , but it again failed
How to send space separated and/or value with contains double quotes like Email whitelist value. I am using Azure CLI with the following command
az containerapp update \
--name ca-devpi \
--resource-group rg-dev-pi \
--image ${{ secrets.ACR_SERVER }}/dev-pi:latest \
--container-name dev-pi \
--cpu 1.0 --memory 2Gi \
--min-replicas 0 --max-replicas 2 \
--scale-rule-name my-http-rule \
--scale-rule-type http \
--scale-rule-http-concurrency 15 \
--set-env-vars $SPACE_SEPARATED_VALUES
And the error I am getting
ERROR: Environment variables must be in the format "<key>=<value> <key>=secretref:<value> ...".
Update
After trying the suggestion from @Azeem and @SiddheshDesai. I can see similar behavior. i.e. if I print $SPACE_SEPARATED_VALUES I can see values are in the format of "AUTO_BATCH_SUBMIT_CRON_START_TIME=*/2 * * * *" "EMAIL_WHITELIST=[\"a.com\",\"b.net\"]"
but I pass the same variable as --set-env-vars $SPACE_SEPARATED_VALUES
then I am getting the same error that
ERROR: Environment variables must be in the format "<key>=<value> <key>=secretref:<value> ...
If i pass with double quotes like this
--set-env-vars "$SPACE_SEPARATED_VALUES"
then I am getting error
ERROR: (ContainerAppInvalidEnvVarName) Env variable name '"AUTO_BATCH_SUBMIT_CRON_START_TIME' contains invalid character, regex used for validation is '^[-._a-zA-Z][-._a-zA-Z0-9]*$'
And I pass direct values like this
--set-env-vars "AUTO_BATCH_SUBMIT_CRON_START_TIME=*/2 * * * *" "EMAIL_WHITELIST=[\"a.com\",\"b.net\"]"
then it works. Now this my be because of Azure CLI shell because this is how I am using
- name: Update Container app
uses: azure/CLI@v1
with:
inlineScript: |
az containerapp update \
--name ${{ vars.DBA_APP }} \
--resource-group ${{ vars.CONTAINER_RG }} \
--set-env-vars $SPACE_SEPARATED_VALUES
I tried the below
Azure CLI
command and put theenv vars
in double quotes like below:-My Github Action workflow:-
Complete workflow here
Output:-
Portal:-