使用 Azure CLI 更新 API 管理时出错 - hostnameConfigurations
Error when updating API Management with Azure CLI - hostnameConfigurations
我正在尝试使用 Azure CLI 使用新的主机名更新我的 APIM。
这样做的时候
$hostConfiguration = '[{
"hostName": "myhostname.com",
"type": "Proxy",
"keyVaultId": "https://mykeyvault.vault.azure.net/secrets/mysecret"
}]'
az apim update --name "apim-name" --resource-group "rg-name" --set hostnameConfigurations=$hostConfiguration
我明白了:
Unable to build a model: Cannot deserialize as [HostnameConfiguration] an object of type <class 'str'>, DeserializationError: Cannot deserialize as [HostnameConfiguration] an object of type <class'str'>
我这样做有什么问题吗?
在存储到变量之前,您必须将 json 转换为字符串。
我利用 https://tools.knowledgewalls.com/jsontostring 将您的 json 转换为字符串
更新的代码段
$hostConfiguration ='[{\"hostName\":\"myhostname.com\",\"type\":\"Proxy\",\"keyVaultId\":\"https:\/\/mykeyvault.vault.azure.net\/secrets\/mysecret\"}]'
az apim update --name "apim-name" --resource-group "rg-name" --set hostnameConfigurations=$hostConfiguration
我正在尝试使用 Azure CLI 使用新的主机名更新我的 APIM。
这样做的时候
$hostConfiguration = '[{
"hostName": "myhostname.com",
"type": "Proxy",
"keyVaultId": "https://mykeyvault.vault.azure.net/secrets/mysecret"
}]'
az apim update --name "apim-name" --resource-group "rg-name" --set hostnameConfigurations=$hostConfiguration
我明白了:
Unable to build a model: Cannot deserialize as [HostnameConfiguration] an object of type <class 'str'>, DeserializationError: Cannot deserialize as [HostnameConfiguration] an object of type <class'str'>
我这样做有什么问题吗?
在存储到变量之前,您必须将 json 转换为字符串。
我利用 https://tools.knowledgewalls.com/jsontostring 将您的 json 转换为字符串
更新的代码段
$hostConfiguration ='[{\"hostName\":\"myhostname.com\",\"type\":\"Proxy\",\"keyVaultId\":\"https:\/\/mykeyvault.vault.azure.net\/secrets\/mysecret\"}]'
az apim update --name "apim-name" --resource-group "rg-name" --set hostnameConfigurations=$hostConfiguration