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

简介: 【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-012021-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

 

相关文章
|
13天前
【APIM】启用APIM Analytics时遇见Request failed错误
Data collection is required for detailed monitoring, custom dashboards, and more. A Log Analytics workspace is also required for the data storage. You can change the workspace destination at any time in Diagnostic settings. How do I use Log Analytics?
41 12
|
2月前
|
API
【Azure APIM】调用APIM的备份接口时候遇见Authentication Failed错误
【Azure APIM】调用APIM的备份接口时候遇见Authentication Failed错误
|
3月前
|
存储 API 网络安全
【Azure APIM】调用APIM的备份接口时候遇见InvalidParameters错误
"Invalid parameter: This request is not authorized to perform this operation.\r\nParameter name: backupContainerName (value: [backupcontainer])"
70 11
|
2月前
解决微软云Azure Function运行报错-Value cannot be null. (Parameter ‘provider‘)
解决微软云Azure Function运行报错-Value cannot be null. (Parameter ‘provider‘)
50 4
|
2月前
|
JSON API 网络架构
【Azure APIM】验证APIM删除后的恢复步骤
【Azure APIM】验证APIM删除后的恢复步骤
|
2月前
|
API Python
【Azure 环境】AAD 注册应用获取AAD Group权限接口遇 403 : Attempted to perform an unauthorized operation 错误
【Azure 环境】AAD 注册应用获取AAD Group权限接口遇 403 : Attempted to perform an unauthorized operation 错误
|
2月前
|
XML 缓存 API
【Azure API 管理】使用APIM进行XML内容读取时遇见的诡异错误 Expression evaluation failed. Object reference not set to an instance of an object.
【Azure API 管理】使用APIM进行XML内容读取时遇见的诡异错误 Expression evaluation failed. Object reference not set to an instance of an object.
|
2月前
|
API
【Azure API 管理】解决API Management添加AAD Group时遇见的 Failed to query Azure Active Directory graph due to error 错误
【Azure API 管理】解决API Management添加AAD Group时遇见的 Failed to query Azure Active Directory graph due to error 错误
|
2月前
|
网络协议 API
【Azure APIM】列举几种在APIM 策略中的主动生产的错误语句
【Azure APIM】列举几种在APIM 策略中的主动生产的错误语句
|
2月前
|
存储 API
【Azure API 管理】为调用APIM的请求启用Trace -- 调试APIM Policy的利器
【Azure API 管理】为调用APIM的请求启用Trace -- 调试APIM Policy的利器