【问题标题】:Error creating key vault certificate in Azure CLI在 Azure CLI 中创建密钥保管库证书时出错
【发布时间】:2021-06-04 16:04:35
【问题描述】:

我正在尝试使用 Azure CLI 将证书添加到 Azure Key Vault。我正在关注文档here 和快速入门here。两个页面都说生成证书的命令是:

az keyvault certificate create --vault-name vaultname -n cert1 -p "$(az keyvault certificate get-default-policy)"

我的脚本中有这一行:

az keyvault certificate create --vault-name $keyVault -n $certName -p "$(az keyvault certificate get-default-policy)"

每次运行时都会出现以下异常。我在这里遗漏了什么明显的东西吗?

az : Expecting property name enclosed in double quotes: line 1 column 5 (char 4)

【问题讨论】:

    标签: azure-keyvault azure-cli


    【解决方案1】:

    这是因为 Powershell 将get-default-policy 的输出保存为与 bash 和 CMD 不同的编码。

    请使用此解决方法:

    az keyvault certificate get-default-policy | Out-File -Encoding utf8 defaultpolicy.json
    
    az keyvault certificate create --vault-name $keyVault -n $certName --policy `@defaultpolicy.json
    

    【讨论】:

      猜你喜欢
      • 2020-10-19
      • 2022-10-15
      • 1970-01-01
      • 2020-04-04
      • 2017-01-05
      • 2022-01-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多