问题
I am trying to create a new Azure Key Vault secret using the Azure Cli v2.9.0 (we use this version in our pipelines and upgrading would be difficult at the moment.) via the command below,
az keyvault secret set --vault-name $myKeyVaultName -n $mySecretName --value "abc^def"
The command is accepted and a new secret is created but it drops the caret (^) from the string and results in a secret value of abcdef instead of the intended abc^def.
During my testing I have seen the below message from Powershell but it's very rare : Unable to encode the output with cp1252 encoding. Unsupported characters are discarded.
Strange as tjhe caret is in the character set - https://en.wikipedia.org/wiki/Windows-1252#Code_page_layout
Is there a way to run this command and get Key Vault to accept the value with the caret?
回答1:
I can reproduce your issue.
Actually, it depends on your environment, this issue just occurs when you run the command in Powershell
, if you run the CLI command in Bash
, it works fine.
az keyvault secret set --vault-name joykeyvault -n testkey12 --value "abc^def"
So if you want to run this command in Powershell
environment, just use the line below.
az keyvault secret set --vault-name joykeyvault -n testkey12 --value '"abc^def"'
来源:https://stackoverflow.com/questions/65199856/create-azure-key-vault-secrets-with-azure-cli-drops-caret-character-in-value