使用 Azure CLI 设置 Azure Function 应用程序配置时出现 ) 问题

Issue with ) when using Azure CLI to set Azure Function app Configurations

我使用带有命令的 Azure CLI 发布了一个应用程序

func azure functionapp publish [my-app-name] --nozip

现在我想更新应用程序的配置以连接到 Azure Key Vault 并从 Vault 获取机密。所以,我是运行这个命令

az functionapp config appsettings set --name [my-app-name] --resource-group [my-app-res-group] --settings "PublicKey=@Microsoft.KeyVault(VaultName=[vault-name];SecretName=[secret-name])"

这个 returns 像这样的错误

request failed: Error occurred in request., RetryError: HTTPSConnectionPool(host='management.azure.com', port=443): Max retries exceeded with url: /subscriptions/[my-sub-guid]/resourceGroups/[my-app-res-group]/providers/Microsoft.Web/sites/[my-app-name]/config/appsettings?api-version=2019-08-01 (Caused by ResponseError('too many 500 error responses',))

但是该命令工作正常并将设置发布到 Azure,只是它不发布

PublicKey=@Microsoft.KeyVault(VaultName=[vault-name];SecretName=[secret-name])

但是

PublicKey=@Microsoft.KeyVault(VaultName=[vault-name];SecretName=[secret-name]

关闭 ) 有什么问题,我该怎么做才能解决这个问题。

P.S。我知道我可以通过 Azure 门户、Visual Studio 和 VS Code 执行此操作,但使用命令行工具执行此操作对我来说至关重要!

您可以查看此 wiki,了解 PowerShell 的引用问题:

要让它发挥作用,您有几个选择:

  1. 为强制 powershell 添加额外的双引号以将参数视为文字:

    az functionapp config appsettings set --name [my-app-name] --resource-group [my-app-res-group] --settings `""PublicKey=@Microsoft.KeyVault(VaultName=[vault-name];SecretName=[secret-name])"`"
    
  2. 使用--%停止PowerShell解析参数并转义双引号

    az --% functionapp config appsettings set --name [my-app-name] --resource-group [my-app-res-group] --settings "PublicKey=@Microsoft.KeyVault(VaultName=[vault-name];SecretName=[secret-name])"