I'm using Azure CLI to try to set an app config value to this URL:
az appconfig kv set --key "mykey" --value "https://fake.com/action?param1=a¶m2=b" -n "test" --yes
I get the following result. Note that this is coming from the az command, not from the shell.
Please specify config store name or connection string(suggested).
'param2' is not recognized as an internal or external command,
operable program or batch file.
Is there some way to get az to take this URL as the value without having to resort to stupid stuff like URL encoding it? This seems broken to me.
Also note, the message Please specify config store name or connection string(suggested).
is because it's failing to parse the command line properly because this is specified with -n. If I move the arguments around:
az appconfig kv set -n "test" --yes --key "mykey" --value "https://fake.com/action?param1=a¶m2=b"
I now get this:
{
"contentType": null,
"etag": "zuspBqPBOHR1mXfcKCgORXHpAxB",
"key": "mykey",
"label": null,
"lastModified": "2021-08-31T17:39:14+00:00",
"locked": false,
"tags": {},
"value": "https://fake.com/action?param1=a"
}
'param2' is not recognized as an internal or external command,
operable program or batch file.
Which seems worse. It created the key value pair incorrectly then tried to run param2 as a command. WTF?
Following one of the links from @d-m got me to this:
https://github.com/Azure/azure-cli/blob/dev/doc/quoting-issues-with-powershell.md
That link fully explains it, but basically I need to use double quotes inside of single quotes because Powershell evaluates the arguments and then cmd evaluates them. So the single quotes are stripped off by powershell, then the double quotes are stripped by cmd and finally az gets the right argument.
This works:
az appconfig kv set -n "test" --yes --key "mykey" --value '"https://fake.com/action?param1=a¶m2=b"'
{
"contentType": "text/plain",
"etag": "XugiNgxa2I04w0gaG2OBh9Jcj75",
"key": "mykey",
"label": null,
"lastModified": "2021-08-31T18:20:44+00:00",
"locked": false,
"tags": {},
"value": "https://fake.com/action?param1=a¶m2=b"
}