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

如何导出API及操作级有效策略至XML文件?已尝试curl未成功

获取Azure APIM API/操作级别的有效策略

你当前调用的API只能返回直接分配给目标API的策略,而Azure APIM的有效策略是全局、产品、API、操作多层级策略合并后的结果,需要使用专门的有效策略查询接口来获取:

API级别有效策略请求

curl --location 'https://management.azure.com/subscriptions/xxxxxxxxxxxx/resourceGroups/xxxxxxxxx/providers/Microsoft.ApiManagement/service/xxxxxxxxxx/apis/apiname/policies/effective?format=xml&api-version=2022-08-01' \
--header 'Authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

操作级别有效策略请求

只需在路径中追加操作ID即可:

curl --location 'https://management.azure.com/subscriptions/xxxxxxxxxxxx/resourceGroups/xxxxxxxxx/providers/Microsoft.ApiManagement/service/xxxxxxxxxx/apis/apiname/operations/{operationId}/policies/effective?format=xml&api-version=2022-08-01' \
--header 'Authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

关键说明

  • 核心改动是将原请求路径中的policy替换为effective,这个接口会自动整合所有层级的策略,返回实际生效的完整内容
  • 接口返回的XML包含了全局策略、关联产品的策略、API自身策略(以及操作级策略,如果是操作请求)的合并结果
  • 确保你的Bearer令牌拥有Microsoft.ApiManagement/service/apis/policies/effective/read的权限

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.29 09:46:10