Warm tip: This article is reproduced from serverfault.com, please click

Create Azure Key Vault Secrets with Azure CLI drops caret ^ character in value

发布于 2020-12-08 13:28:35

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.

enter image description here

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?

Questioner
Phil Murray
Viewed
0
Joy Wang 2020-12-09 09:54:04

I can reproduce your issue.

enter image description here

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"

enter image description here

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"'

enter image description here