简体   繁体   English

Azure Rest API用于VM还原的resourceRestoreRequest语法是什么

[英]Azure Rest API What resourceRestoreRequest syntax for VM Restore

I'm using Python with Rest API requests to manage backup&restore on Azure VM. 我使用带有Rest API请求的Python来管理Azure VM上的备份和还原。 I'm able to backup VM, but I can't restore them. 我可以备份VM,但无法还原它们。

My code in Python to POST 我在POST中使用Python编写的代码

headers = {"Authorization": 'Bearer ' + restapi_azure_authentication()}
myResponse = requests.post(url, headers=headers)

and to POST with JSON push 并使用JSON推送进行POST

headers = {"Authorization": 'Bearer ' + restapi_azure_authentication()}
myResponse = requests.post(url, headers=headers, json=json)

I get two messages. 我收到两条消息。 If I use this request: 如果我使用此请求:

POST /Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupFabrics/{fabricName}/protectionContainers/{containerName}/protectedItems/{protectedItemName}/recoveryPoints/{recoveryPointId}/restore?api-version=2016-06-01

I get this message : 我收到此消息:

{"error":{"code":"CloudInternalError","message":"Microsoft Azure Backup encountered an internal error.\\r\\nWait for a few minutes and then try the operatio n again. If the issue persists, please contact Microsoft support.","target":null,"details":null,"innerError":null}} {“错误”:{“代码”:“ CloudInternalError”,“消息”:“ Microsoft Azure备份遇到内部错误。\\ r \\ n请等待几分钟,然后再次尝试操作。如果问题仍然存在,请联系Microsoft支持。“,” target“:null,” details“:null,” innerError“:null}}

If I use this request with JSON push : 如果我将此请求与JSON push一起使用:

json = {
    "properties": {}
}

I get this message: 我收到此消息:

{"error":{"code":"UserErrorInvalidRestoreRequest","message":"Restore operation failed due to invalid parameters or format of the parameters is not correct .\\r\\nPlease ensure parameters provided to restore operation are valid. If the issue persists, please contact Microsoft support.","target":null,"details":n ull,"innerError":null}} {“错误”:{“代码”:“ UserErrorInvalidRestoreRequest”,“消息”:“由于参数无效或参数格式不正确,恢复操作失败。\\ r \\ n请确保提供的用于恢复操作的参数有效。问题仍然存在,请联系Microsoft支持。“,” target“:null,” details“:n ull,” innerError“:null}}

I don't know what to put into "properties" to successfully restore my VM. 我不知道要放入什么“属性”才能成功还原我的VM。 I'm trying to follow this doc, unfortunately, without success : https://docs.microsoft.com/en-us/rest/api/recoveryservices/restores 不幸的是,我试图遵循此文档,但没有成功: https : //docs.microsoft.com/zh-cn/rest/api/recoveryservices/restores

As the other community mentioned that we can refer the parameters by using PowerShell command-let to restore the backup data. 正如另一个社区提到的那样,我们可以使用PowerShell命令let引用参数来还原备份数据。 Here is the request which capture using the Fiddler for your reference: 这是使用Fiddler捕获的请求供您参考:

POST:https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultsName}/backupFabrics/Azure/protectionContainers/{backupContainerName}/protectedItems/{backUpItemName}/recoveryPoints/{recoveryPointId}/restore?api-version=2016-05-01
Authorization: Bearer {access_token}

{
  "properties": {
    "objectType": "IaasVMRestoreRequest",
    "recoveryPointId": "{recoveryPointId}",
    "recoveryType": "RestoreDisks",
    "storageAccountId": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{storageaccountName}",
    "createNewCloudService": false,
    "region": "{region}",
    "sourceResourceId": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{VMName}"
  }
}

In addition, if you have any feedback about the document provide by Microsoft, you can submit it from the right bottom page( Is this page helpful ). 另外,如果您对Microsoft提供的文档有任何反馈,可以从右下角提交( Is this page helpful )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM