【Azure APIM】调用APIM的备份接口时候遇见InvalidParameters错误

问题描述

根据官方文档,可以调用REST API来对APIM执行备份操作。

要备份 API 管理服务,请发出以下 HTTP 请求:

POST https://management.chinacloudapi.cn/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backup?api-version={api-version}

其中:

  • subscriptionId - 订阅的 ID,该订阅包含的 API 管理服务是你尝试备份的
  • resourceGroupName - Azure API 管理服务的资源组名称
  • serviceName - 正在创建其备份的 API 管理服务的名称,在创建时指定
  • api-version - 有效的 REST API 版本,例如 2021-08-01 或 2021-04-01-preview

在请求正文中,指定目标存储帐户名称、Blob 容器名称、备份名称和存储访问类型。 如果存储容器不存在,备份操作将创建存储容器。

{
"storageAccount": "{storage account name for the backup}",
"containerName": "{backup container name}",
"backupName": "{backup blob name}",
"accessKey": "{access key for the account}"
}

但是,总是遇见了如下错误:

{
  "error": {
    "code": "InvalidParameters",
    "message": "Invalid parameter: This request is not authorized to perform this operation.\r\nParameter name: backupContainerName (value: [backupcontainer])",
    "details": null,
    "innerError": null
  }
}

 

问题解答

出现错误 “This request is not authorized to perform this operation.\r\nParameter name: backupContainerName”, 说明APIM资源没有权限对Storage Account Container进行读取操作。

需要检查以下几点:

1) 因为请求使用的Access Key方式访问,所以需要检查 Storage Account 是否启用了防火墙,是否允许公网访问?

2) 如果启用了防火墙,则需要根据文档,开启 APIM 的Resource Instance访问,并且选择指定的APIM Managed Identity。

3) 检查APIM Managed Identity是否有写入Blob的权限,比如需要配置:Storage Blob Data Contributor

4) 在APIM的备份请求体中,需要用 "accessType": "SystemAssignedManagedIdentity" 替换 "accessKey": "{access key for the account}"

 

只要以上都检查后,就能解决not authorized to perform this operation的错误。

 

参考资料

如何使用 Azure API 管理中的服务备份和还原实现灾难恢复 : https://docs.azure.cn/zh-cn/api-management/api-management-howto-disaster-recovery-backup-restore?tabs=rest

 

posted @   路边两盏灯  阅读(31)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
历史上的今天:
2023-07-26 【Azure 环境】AAD 注册应用获取AAD Group权限接口遇 403 : Attempted to perform an unauthorized operation 错误
2022-07-26 【Azure 应用服务】PHP应用部署在App Service for Linux环境中,上传文件大于1MB时,遇见了413 Request Entity Too Large 错误的解决方法
2021-07-26 【Azure 应用服务】App Service服务无法启动,打开Kudu站点,App Service Editor 页面均抛出:The service is unavailable
点击右上角即可分享
微信分享提示