Reputation: 2416
I'm trying to run the az sql db export
command and it requires a SQL Admin username and password. Our password happens to have two dollar signs in it e.g. ABC$$123==). So when I run the following command (with valid values in it, of course):
$pwd = "ABC$$123==)"
az sql db export -s myserver -n mydatabase -g mygroup -p $pwd-u login \
--storage-key MYKEY== --storage-key-type StorageAccessKey \
--storage-uri https://myAccountName.blob.core.windows.net/myContainer/myBacpac.bacpac
I get this response:
')' is not recognized as an internal or external command,
operable program or batch file.
I've tried so many variations of escaping this but haven't found the correct method that works. In the end, I plan to read the password from Azure Key Vault and was gonna pass it straight in to the az cli command. What do I have to do to get this to work?
Upvotes: 4
Views: 1614
Reputation: 1251
As suggested in https://github.com/Azure/azure-cli/issues/20972, setting the value with double quotes inside single quotes (one for PowerShell, one for Command Prompt) solved the issue for me:
For example:
az keyvault secret set --vault-name SomeVault --name foobar --value '"abc123|whoami"'
Upvotes: 2
Reputation: 231
There are two types of quotes in powershell - single and double. In the double quote, you can pass in variables. In a single quote, everything is literal. For cases like your password, I would recommend just using the literal:
$pwd = 'ABC$$123==)'
Upvotes: 4