2

I'm using Python with Rest API requests to manage backup&restore on Azure VM. I'm able to backup VM, but I can't restore them.

My code in Python to POST

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

and to POST with JSON push

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}}

If I use this request with 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}}

I don't know what to put into "properties" to successfully restore my VM. I'm trying to follow this doc, unfortunately, without success : https://learn.microsoft.com/en-us/rest/api/recoveryservices/restores

Matthieu
  • 21
  • 2

1 Answers1

0

As the other community mentioned that we can refer the parameters by using PowerShell command-let to restore the backup data. Here is the request which capture using the Fiddler for your reference:

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).

Fei Xue
  • 14,369
  • 1
  • 19
  • 27