This API can be used for restoring the selected volumes on a specific host as Virtual machine. Boot volumes must be part of the selection, since the virtual machine must have boot volumes to be able to start.
This API uses results of previous APIs such as revisions list gathered via Get volumes or Get volume revisions, host id fetched via the Get host or Register host API and others, described below.
Input Parameters
The following table provides the parameters and descriptions.
Parameter | Description |
sessionId - | String (GUID)obtained via a prior call to Hyper-V Create Session API. |
hostId | Integer, id of the host, either obtained when it was registered the first time, or via the Get registered hosts API call |
recoveryType | Either TestRecovery or ProductionRecovery. If TestRecovery, virtualSwitchId must not be provided. It is only applicable for production recovery. |
diskLocation path | Local folder or network share. For network shares, user and password can be provided by additional parameter. |
diskLocation credentials | Optional, network share only. userName - optional parameter to use for shares requiring auth. password - optional parameter to use for shares requiring auth. |
diskFormat | String, allowed values are Vhd or Vhdx. This parameter is validated against capabilities restore time but can be pre-validated using the validation API s (see other APIs in this section). |
firmwareType | String, allowed values are Bios or Uefi. This parameter is validated against capabilities at restore time but can be pre-validated using the validation APIs (see other APIs in this section). |
hostProperties | name - string, name of the virtual machine on which the restored volumes is running (this is typically the host name that was backed up, since that very same system is being restored, however, any name can be used). Can be obtained the Get registered hosts APIs, hostName parameter of the host that is being restored. virtualSwitchId - string (typically in GUID format), obtained via a prior call to get the virtual switches. Do not populate when using TestRecovery. For ProductionRecovery this is mandatory. cores - integer, CPU cores memory - amount of memory in MB |
revisions | Array of integers, representing the revisions to restore, obtained by a prior call to either Get volumes (for latest revision), or Get Revisions for volumes API call. Boot volumes must be part of those volumes, since the restore as VM requires boot volumes to be present. |
skipValidations | Default is false. If not specified (which means false is implied), validations automatically run. While the validations can be run as separate API requests, they are also included by default as part of the API's processing of the Restore request. However, since the validation calls are expensive, they can also be disabled in the Restore request (so a user can do them separately). This can be done via specifying "skipValidations": true in the request. |
Example
"sessionId": "5d05495f-39e5-4e4e-ad0c-e351cc2c78f3"
"hostId": 2,
"recoveryType": "ProductionRecovery",
"diskLocation": {
"path": "\\\\server\\share\folder1",
"credentials": {
"userName": "user1",
"password": "password"
}
},
"diskFormat": "Vhdx",
"firmwareType": "Bios",
"hostProperties": {
"name": "TestComputer1",
"cores": 4,
"memory": 4096,
"virtualSwitchId": "C08CE7B8-9B3C-408E-8E30-5E16A3AEB444"
},
"revisions":[
3511
]
Example Post
POST /v2/accounts/test_acc/computers/0000/restore/diskimage/standard/vm
Input Parameters
{
"sessionId": "2bd04387-9e6d-49c7-8d32-d144af9a8d78",
"hostId": 2,
"recoveryType": "string",
"diskLocation": {
"path": "\\\\\\\\server1\\\\share1\\\\folder1",
"credentials": {
"userName": "user1",
"password": "passwordtext"
}
},
"diskFormat": "Vhdx",
"firmwareType": "Bios",
"hostProperties": {
"name": "TestComputer1",
"cores": 4,
"memory": 4096,
"virtualSwitchId": "C08CE7B8-9B3C-408E-8E30-5E16A3AEB444"
},
"revisions": [
0
]
}
Output Parameters
Boolean value, showing that the async action has started. The restore begins and finishes in the background on the agent side.
Response status: 204 No Content (for online operation)