Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Azure CLI更新API管理时出错-主机名配置_Azure_Azure Cli - Fatal编程技术网

使用Azure CLI更新API管理时出错-主机名配置

使用Azure CLI更新API管理时出错-主机名配置,azure,azure-cli,Azure,Azure Cli,我正在尝试使用Azure CLI使用新主机名更新我的APIM 这样做的时候 $hostConfiguration = '[{ "hostName": "myhostname.com", "type": "Proxy", "keyVaultId": "https://mykeyvault.vault.azure.net/secrets/mysecret"

我正在尝试使用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'>
无法生成模型:无法反序列化为[HostnameConfiguration]类型的对象,反序列化错误:无法反序列化为[HostnameConfiguration]类型的对象

我这样做有什么问题?

在存储到变量之前,必须将json转换为字符串

我利用了将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

如果有帮助的话,请考虑接受这个解决方案:“是的!非常感谢。