Azure API Management操作异常求助:无法删除/创建API
Azure API Management 删除/创建API报错排查方案
一、删除API报错 Unable to delete API testapi. There is a chance it was deleted, please try to refresh.
- 检查API关联资源:APIM删除API前必须解除与产品、策略、订阅或网关的绑定,即使UI未显示关联也可能存在隐性绑定。可通过Azure CLI查询并移除:
- 查询关联产品:
az apim api show --resource-group <你的资源组名> --service-name <APIM实例名> --api-id testapi --query "products" - 移除产品关联:
az apim api remove-from-product --resource-group <资源组名> --service-name <APIM实例名> --product-id <关联产品ID> --api-id testapi
- 查询关联产品:
- 清除UI缓存:使用浏览器无痕模式打开Azure门户,或清除缓存后重新操作,避免缓存导致的显示异常。
- 直接用CLI删除:绕开UI潜在问题,执行命令:
az apim api delete --resource-group <资源组名> --service-name <APIM实例名> --api-id testapi
二、OpenAPI创建API报错 Could not create an API. Please try again later.
- 验证OpenAPI规范合法性:使用本地OpenAPI验证工具(如Swagger Editor本地版)检查yaml/json文件语法,避免使用Azure不支持的扩展字段或非法格式。
- 检查文件大小:APIM导入OpenAPI默认限制约4MB,若文件过大,尝试拆分API或精简冗余内容。
- 用CLI导入测试:绕开UI执行导入命令,排查是否为UI层面问题:
az apim api import --resource-group <资源组名> --service-name <APIM实例名> --specification-path <本地OpenAPI文件路径> --specification-format OpenApiYaml/OpenApiJson --api-id <目标API ID> - 检查APIM实例状态:在APIM实例“概述”页查看运行状态与资源指标,确认无CPU/内存配额不足或实例异常情况。
内容的提问来源于stack exchange,提问作者SHIVAM SINGH
相关产品推荐
相关产品推荐

