【发布时间】:2017-05-30 10:26:01
【问题描述】:
我正在使用带有 Rest API 请求的 Python 来管理 Azure VM 上的备份和恢复。我可以备份虚拟机,但无法恢复它们。
我的 Python 代码 POST
headers = {"Authorization": 'Bearer ' + restapi_azure_authentication()}
myResponse = requests.post(url, headers=headers)
并使用 JSON 推送进行 POST
headers = {"Authorization": 'Bearer ' + restapi_azure_authentication()}
myResponse = requests.post(url, headers=headers, json=json)
我收到两条消息。 如果我使用这个请求:
POST /Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupFabrics/{fabricName}/protectionContainers/{containerName}/protectedItems/{protectedItemName}/recoveryPoints/{recoveryPointId}/restore?api-version=2016-06-01
我收到这条消息:
{"error":{"code":"CloudInternalError","message":"Microsoft Azure Backup 遇到内部错误。\r\n等待几分钟,然后尝试操作 再次。如果问题仍然存在,请联系 Microsoft 支持。","target":null,"details":null,"innerError":null}}
如果我将此请求与 JSON 推送一起使用:
json = {
"properties": {}
}
我收到这条消息:
{"error":{"code":"UserErrorInvalidRestoreRequest","message":"由于参数无效或参数格式不正确,恢复操作失败 .\r\n请确保为还原操作提供的参数有效。如果问题仍然存在,请联系 Microsoft 支持。","target":null,"details":n ull,"innerError":null}}
我不知道在“属性”中添加什么才能成功恢复我的虚拟机。 不幸的是,我正在尝试关注此文档,但没有成功:https://docs.microsoft.com/en-us/rest/api/recoveryservices/restores
【问题讨论】:
-
好吧,你没有提供任何“body”,你需要传入
resourceRestoreRequest的body参数 -
我知道,但是Azure Rest API doc没有给出任何例子,所以我不知道怎么写。
-
只需使用 powershell 执行相同的任务,然后输入
-debug开关并查看示例:)
标签: python rest azure virtual-machine restore