You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用Azure CLI az rest命令清除keyVaultReferenceIdentity配置并解决报错

解决方案

错误原因

  • 首次执行报错是未指定请求的Content-Type,Azure资源管理API要求PATCH请求的媒体类型必须为application/json
  • 第二次报错是因为PowerShell格式的哈希表无法直接作为参数传递给Azure CLI,Azure CLI无法解析该格式导致参数拆解失败

正确执行命令

推荐使用Azure CLI内置--content-type参数的写法,无需手动构造请求头,语法更简洁:

az rest --method PATCH `
  --uri "${resourceId}?api-version=2021-01-01" `
  --content-type "application/json" `
  --body '{"properties":{"keyVaultReferenceIdentity":null}}' `
  --query properties.keyVaultReferenceIdentity `
  -o json

如果需要自定义请求头,需将头信息转换为JSON格式的字符串再传递给--headers参数:

$headers = '{"Content-Type": "application/json"}'
az rest --method PATCH `
  --headers $headers `
  --uri "${resourceId}?api-version=2021-01-01" `
  --body '{"properties":{"keyVaultReferenceIdentity":null}}' `
  --query properties.keyVaultReferenceIdentity `
  -o json

结果验证

命令执行成功后返回值为null,即代表keyVaultReferenceIdentity配置已被成功清除。

内容的提问来源于stack exchange,提问作者Krzysztof Madej

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.07 08:15:01