Azure Cli format for environment variables with problematic characters

Was unable to find a good  resource to determine how to format the string when creating azure container instances when  I had characters  in the environment variables that would  cause the cli to incorrectly parse .
Example:

Was about to go the yml route when I decided to try the  format;

az container create   -e 'key:"value"'

and that worked like a charm.
this is useful when  you have problematic characters (& , ! ,etc.)

Example:

az container create -g myGroup -n MyContainer--image MyImage 
-e 'YOUR_KEY_URL="jdbc:mysql://databaselocation:3306/sonarqube?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&autoReconnect=true&useSSL=false"'

Results in Azure:

I tried other methods (escaping characters, single quotes, double quotes, ^ sign, double ampersand, and even double quote followed by single) but only this format worked.

I believe this solves this person’s error:
https://github.com/Azure/azure-cli/issues/5573
I will also try to cross post it to:
https://docs.microsoft.com/en-us/azure/container-instances/container-instances-environment-variables

1 thought on “Azure Cli format for environment variables with problematic characters

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.