Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

az container create environment variables does not parse values with ampersand correctly #5573

Closed
moenkhaus opened this issue Feb 13, 2018 · 3 comments
Assignees
Labels
Container Infrastructure question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@moenkhaus
Copy link

moenkhaus commented Feb 13, 2018

I am attempting to pass in environment variables to az container create command. When a value has an ampersand contained within it, the environment variables cut out the remainder of the value and subsequent key/values that follow.

Environment

Powershell 5.1.16299.98
Azure Client 2.0 (https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest)

Powershell script

az container create --resource-group <resourceGroup>
--name --image <image>
--cpu 1 --memory 1
--registry-password --ip-address public
--ports `
--environment-variables Key1="value1&value2" Key2=value3

Current output

"containers": [
{
"command": null,
"environmentVariables": [
{
"name": "Key1",
"value": "value1"
}
]
..

Expected output

"containers": [
{
"command": null,
"environmentVariables": [
{
"name": "Key1",
"value": "value1&value2"
},
{
"name": "Key2",
"value": "value3"
},
]
..

Update #1

Also in the current output is the following error message, I presume due to again how it's parsing.

'Value2' is not recognized as an internal or external command,
operable program or batch file.

Do I need to escape the string somehow?

update 2

When running in interactive mode (without the "`" line breaks") the environment variables run as expected. I tried removing the line breaks in powershell just the same but am presented with the same error.

update 3

works in normal command prompt, issue appears restricted to powershell

@tjprescott tjprescott added the Container Instances az container label Feb 13, 2018
@bsiegel bsiegel added the Service Attention This issue is responsible by Azure service team. label Sep 26, 2018
@EstebanSmits
Copy link

EstebanSmits commented Oct 16, 2018

Had issues with ampersand's myself today.
Try using the format :
az container create -e 'key:"value"'
A small write up is available here with my own personal error and results: http://daxmax.com/azure-cli-format-for-environment-variables-with-problematic-characters/

@tjprescott
Copy link
Member

Ampersand is used as the call operator in Powershell. https://ss64.com/ps/call.html You need to escape the ampersand characters.

@tjprescott tjprescott added Infrastructure question The issue doesn't require a change to the product in order to be resolved. Most issues start as that and removed Container Instances az container Service Attention This issue is responsible by Azure service team. labels Oct 17, 2018
@haroldrandom haroldrandom added Container Infrastructure question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Oct 25, 2019
@stmax82
Copy link

stmax82 commented Feb 7, 2020

@EstebanSmits are you sure it's -e 'key:"value"'?

I had to replace the colon with an equals sign to make it work:

Trying to set:

GF_DATABASE_URL=sqlite3://data/mygrafana.db?cache=private&mode=rwc&_journal_mode=WAL

requires:

-e 'GF_DATABASE_URL="sqlite3://data/mygrafana.db?cache=private&mode=rwc&_journal_mode=WAL"'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Container Infrastructure question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
Development

No branches or pull requests

7 participants