You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/backup/backup-azure-arm-userestapi-backupazurevms.md
+34-26Lines changed: 34 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,20 +1,21 @@
1
1
---
2
-
title: Back up Azure VMs using REST API
2
+
title: Back up Azure VMs using REST API in Azure Backup
3
3
description: In this article, learn how to configure, initiate, and manage backup operations of Azure VM Backup using REST API.
4
-
ms.topic: conceptual
5
-
ms.date: 08/03/2018
4
+
ms.topic: how-to
5
+
ms.date: 04/24/2024
6
6
ms.assetid: b80b3a41-87bf-49ca-8ef2-68e43c04c1a3
7
7
author: AbhishekMallick-MS
8
8
ms.author: v-abhmallick
9
+
ms.custom: engagement-fy24
9
10
---
10
11
11
12
# Back up an Azure VM using Azure Backup via REST API
12
13
13
-
This article describes how to manage backups for an Azure VM using Azure Backup via REST API. Configure protection for the first time for a previously unprotected Azure VM, trigger an on-demand backup for a protected Azure VM and modify backup properties of a backed-up VM via REST API as explained here.
14
+
This article describes how to manage backups for an Azure VM using Azure Backup via REST API. Configure protection for the first time for a previously unprotected Azure VM, trigger an on-demand backup for a protected Azure VM and modify backup properties of a backed-up VM via REST API as explained here. To protect an Azure VM using the Azure portal, see [this article](backup-during-vm-creation.md).
14
15
15
-
Refer to [create vault](backup-azure-arm-userestapi-createorupdatevault.md) and [create policy](backup-azure-arm-userestapi-createorupdatepolicy.md) REST API tutorials for creating new vaults and policies.
16
+
Learn how to [create vault](backup-azure-arm-userestapi-createorupdatevault.md) and [create policy](backup-azure-arm-userestapi-createorupdatepolicy.md) REST API tutorials for creating new vaults and policies.
16
17
17
-
Let's assume you want to protect a VM "testVM" under a resource group "testRG" to a Recovery Services vault "testVault", present within the resource group "testVaultRG", with the default policy (named "DefaultPolicy").
18
+
Let's assume you want to protect a VM `testVM` under a resource group `testRG` to a Recovery Services vault `testVault`, present within the resource group `testVaultRG`, with the default policy (named `DefaultPolicy`).
18
19
19
20
## Configure backup for an unprotected Azure VM using REST API
20
21
@@ -36,14 +37,14 @@ POST https://management.azure.com/Subscriptions/00000000-0000-0000-0000-00000000
36
37
37
38
The 'refresh' operation is an [asynchronous operation](../azure-resource-manager/management/async-operations.md). It means this operation creates another operation that needs to be tracked separately.
38
39
39
-
It returns two responses: 202 (Accepted) when another operation is created and then 200 (OK) when that operation completes.
40
+
It returns two responses: 202 (Accepted) when another operation is created, and 200 (OK) when that operation completes.
40
41
41
42
|Name |Type |Description |
42
43
|---------|---------|---------|
43
44
|204 No Content || OK with No content returned |
44
45
|202 Accepted || Accepted |
45
46
46
-
##### Example responses to refresh operation
47
+
**Example responses to refresh operation**:
47
48
48
49
Once the *POST* request is submitted, a 202 (Accepted) response is returned.
49
50
@@ -89,7 +90,7 @@ X-Powered-By: ASP.NET
89
90
90
91
### Selecting the relevant Azure VM
91
92
92
-
You can confirm that "caching" is done by [listing all protectable items](/rest/api/backup/backup-protectable-items/list) under the subscription and locate the desired VM in the response. [The response of this operation](#example-responses-to-get-operation) also gives you information on how Recovery Services identifies a VM. Once you are familiar with the pattern, you can skip this step and directly proceed to [enabling protection](#enabling-protection-for-the-azure-vm).
93
+
You can confirm that "caching" is done by [listing all protectable items](/rest/api/backup/backup-protectable-items/list) under the subscription and locate the desired VM in the response. [The response of this operation](#responses-to-get-operation) also gives you information on how Recovery Services identifies a VM. Once you're familiar with the pattern, you can skip this step and directly proceed to [enabling protection](#enable-protection-for-the-azure-vm).
93
94
94
95
This operation is a *GET* operation.
95
96
@@ -105,9 +106,9 @@ The *GET* URI has all the required parameters. No additional request body is nee
105
106
|---------|---------|---------|
106
107
|200 OK |[WorkloadProtectableItemResourceList](/rest/api/backup/backup-protectable-items/list#workloadprotectableitemresourcelist)| OK |
107
108
108
-
#### Example responses to get operation
109
+
**Example responses to get operation**:
109
110
110
-
Once the *GET* request is submitted, a 200 (OK) response is returned.
111
+
Once the *GET* request is submitted, 200 (OK) response is returned.
111
112
112
113
```http
113
114
HTTP/1.1 200 OK
@@ -150,14 +151,14 @@ The response contains the list of all unprotected Azure VMs and each `{value}` c
150
151
151
152
- containerName = "iaasvmcontainer;"+`{name}`
152
153
- protectedItemName = "vm;"+ `{name}`
153
-
-`{virtualMachineId}` is used later in [the request body](#example-request-body)
154
+
-`{virtualMachineId}` is used later in [the request body](#enable-protection-for-the-azure-vm)
After the relevant VM is "cached" and "identified", select the policy to protect. To know more about existing policies in the vault, refer to [list Policy API](/rest/api/backup/backup-policies/list). Then select the [relevant policy](/rest/api/backup/protection-policies/get) by referring to the policy name. To create policies, refer to [create policy tutorial](backup-azure-arm-userestapi-createorupdatepolicy.md). "DefaultPolicy" is selected in the example below.
163
164
@@ -183,7 +184,7 @@ To create a protected item, following are the components of the request body.
183
184
184
185
For the complete list of definitions of the request body and other details, refer to [create protected item REST API document](/rest/api/backup/protected-items/create-or-update#request-body).
185
186
186
-
##### Example request body
187
+
**Example request body**:
187
188
188
189
The following request body defines properties required to create a protected item.
189
190
@@ -197,20 +198,27 @@ The following request body defines properties required to create a protected ite
197
198
}
198
199
```
199
200
200
-
The `{sourceResourceId}` is the `{virtualMachineId}` mentioned above from the [response of list protectable items](#example-responses-to-get-operation).
201
+
The `{sourceResourceId}` is the `{virtualMachineId}` mentioned above from the [response of list protectable items](#responses-to-get-operation).
202
+
Responses to create protected item operation
203
+
@01011011
204
+
205
+
206
+
207
+
208
+
201
209
202
210
#### Responses to create protected item operation
203
211
204
212
The creation of a protected item is an [asynchronous operation](../azure-resource-manager/management/async-operations.md). It means this operation creates another operation that needs to be tracked separately.
205
213
206
-
It returns two responses: 202 (Accepted) when another operation is created and then 200 (OK) when that operation completes.
214
+
It returns two responses: 202 (Accepted) when another operation is created, and 200 (OK) when that operation completes.
207
215
208
216
|Name |Type |Description |
209
217
|---------|---------|---------|
210
218
|200 OK |[ProtectedItemResource](/rest/api/backup/protected-item-operation-results/get#protecteditemresource)| OK |
211
219
|202 Accepted || Accepted |
212
220
213
-
##### Example responses to create protected item operation
221
+
**Example responses to create protected item operation**:
214
222
215
223
Once you submit the *PUT* request for protected item creation or update, the initial response is 202 (Accepted) with a location header or Azure-async-header.
216
224
@@ -273,7 +281,7 @@ This confirms that protection is enabled for the VM and the first backup will be
273
281
274
282
### Excluding disks in Azure VM backup
275
283
276
-
Azure Backup also provides a way to selectively backup a subset of disks in Azure VM. More details are provided [here](selective-disk-backup-restore.md). If you want to selectively backup few disks during enabling protection, the following code snippet should be the [request body during enabling protection](#example-request-body).
284
+
Azure Backup also provides a way to selectively back up a subset of disks in Azure VM. More details are provided [here](selective-disk-backup-restore.md). If you want to selectively back up few disks during enabling protection, the following code snippet should be the [request body during enabling protection](#create-the-request-body-for-on-demand-backup).
277
285
278
286
```json
279
287
{
@@ -296,9 +304,9 @@ In the request body above, the list of disks to be backed up are provided in the
296
304
|Property |Value |
297
305
|---------|---------|
298
306
|diskLunList | The disk LUN list is a list of *LUNs of data disks*. **OS disk is always backed up and doesn't need to be mentioned**. |
299
-
|IsInclusionList | Should be **true** for the LUNs to be included during backup. If it is**false**, the aforementioned LUNs will be excluded. |
307
+
|IsInclusionList | Should be **true** for the LUNs to be included during backup. If it's**false**, the aforementioned LUNs will be excluded. |
300
308
301
-
So, if the requirement is to backup only the OS disk, then _all_ data disks should be excluded. An easier way is to say that no data disks should be included. So the disk LUN list will be empty and the **IsInclusionList** will be **true**. Similarly, think of what is the easier way of selecting a subset: A few disks should be always excluded or a few disks should always be included. Choose the LUN list and the boolean variable value accordingly.
309
+
So, if the requirement is to back up only the OS disk, then _all_ data disks should be excluded. An easier way is to say that no data disks should be included. So the disk LUN list will be empty and the **IsInclusionList** will be **true**. Similarly, think of what is the easier way of selecting a subset: A few disks should be always excluded or a few disks should always be included. Choose the LUN list and the boolean variable value accordingly.
302
310
303
311
## Trigger an on-demand backup for a protected Azure VM
304
312
@@ -343,7 +351,7 @@ The following request body defines properties required to trigger a backup for a
343
351
344
352
Triggering an on-demand backup is an [asynchronous operation](../azure-resource-manager/management/async-operations.md). It means this operation creates another operation that needs to be tracked separately.
345
353
346
-
It returns two responses: 202 (Accepted) when another operation is created and then 200 (OK) when that operation completes.
354
+
It returns two responses: 202 (Accepted) when another operation is created, and 200 (OK) when that operation completes.
347
355
348
356
|Name |Type |Description |
349
357
|---------|---------|---------|
@@ -413,7 +421,7 @@ Since the backup job is a long running operation, it needs to be tracked as expl
413
421
414
422
### Changing the policy of protection
415
423
416
-
To change the policy with which VM is protected, you can use the same format as [enabling protection](#enabling-protection-for-the-azure-vm). Just provide the new policy ID in [the request body](#example-request-body) and submit the request. For example: To change the policy of testVM from 'DefaultPolicy' to 'ProdPolicy', provide the 'ProdPolicy' ID in the request body.
424
+
To change the policy with which VM is protected, you can use the same format as [enabling protection](#enable-protection-for-the-azure-vm)). Just provide the new policy ID in [the request body](#create-the-request-body) and submit the request. For example: To change the policy of testVM from 'DefaultPolicy' to 'ProdPolicy', provide the 'ProdPolicy' ID in the request body.
417
425
418
426
```json
419
427
{
@@ -434,7 +442,7 @@ If the Azure VM is already backed up, you can specify the list of disks to be ba
434
442
> [!IMPORTANT]
435
443
> The request body above is always the final copy of data disks to be excluded or included. This doesn't *add* to the previous configuration. For example: If you first update the protection as "exclude data disk 1" and then repeat with "exclude data disk 2", *only data disk 2 is excluded* in the subsequent backups and data disk 1 will be included. This is always the final list which will be included/excluded in the subsequent backups.
436
444
437
-
To get the current list of disks which are excluded or included, get the protected item information as mentioned [here](/rest/api/backup/protected-items/get). The response will provide the list of data disk LUNs and indicates whether they are included or excluded.
445
+
To get the current list of disks which are excluded or included, get the protected item information as mentioned [here](/rest/api/backup/protected-items/get). The response will provide the list of data disk LUNs and indicates whether they're included or excluded.
*DELETE* protection is an [asynchronous operation](../azure-resource-manager/management/async-operations.md). It means this operation creates another operation that needs to be tracked separately.
474
482
475
-
It returns two responses: 202 (Accepted) when another operation is created and then 204 (NoContent) when that operation completes.
483
+
It returns two responses: 202 (Accepted) when another operation is created, and 204 (NoContent) when that operation completes.
476
484
477
485
|Name |Type |Description |
478
486
|---------|---------|---------|
@@ -484,9 +492,9 @@ It returns two responses: 202 (Accepted) when another operation is created and t
484
492
485
493
### Undo the deletion
486
494
487
-
Undoing the accidental deletion is similar to creating the backup item. After undoing the deletion, the item is retained but no future backups are triggered.
495
+
Undoing the accidental deletion is similar to creating the backup item. After you undo the deletion, the item is retained but no future backups are triggered.
488
496
489
-
Undo deletion is a *PUT* operation which is very similar to [changing the policy](#changing-the-policy-of-protection) and/or [enabling the protection](#enabling-protection-for-the-azure-vm). Just provide the intent to undo the deletion with the variable *isRehydrate* in [the request body](#example-request-body) and submit the request. For example: To undo the deletion for testVM, the following request body should be used.
497
+
Undo deletion is a *PUT* operation which is very similar to [changing the policy](#changing-the-policy-of-protection) and/or [enabling the protection](#enable-protection-for-the-azure-vm). Just provide the intent to undo the deletion with the variable *isRehydrate* in [the request body](#create-the-request-body) and submit the request. For example: To undo the deletion for testVM, the following request body should be used.
Copy file name to clipboardExpand all lines: articles/backup/backup-azure-arm-userestapi-restoreazurevms.md
+8-7Lines changed: 8 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,9 @@
1
1
---
2
2
title: Restore Azure VMs using REST API
3
-
description: In this article, learn how to manage restore operations of Azure Virtual Machine Backup using REST API.
4
-
ms.topic: conceptual
5
-
ms.date: 08/26/2021
3
+
description: In this article, learn how to manage to restore operations of Azure Virtual Machine Backup using REST API.
4
+
ms.topic: how-to
5
+
ms.service: backup
6
+
ms.date: 04/24/2024
6
7
ms.assetid: b8487516-7ac5-4435-9680-674d9ecf5642
7
8
author: AbhishekMallick-MS
8
9
ms.author: v-abhmallick
@@ -22,7 +23,7 @@ The available recovery points of a backup item can be listed using the [list rec
22
23
GET https://management.azure.com/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupFabrics/{fabricName}/protectionContainers/{containerName}/protectedItems/{protectedItemName}/recoveryPoints?api-version=2019-05-13
23
24
```
24
25
25
-
The `{containerName}` and `{protectedItemName}` are as constructed [here](backup-azure-arm-userestapi-backupazurevms.md#example-responses-to-get-operation). `{fabricName}` is "Azure".
26
+
The `{containerName}` and `{protectedItemName}` are as constructed [here](backup-azure-arm-userestapi-backupazurevms.md#responses-to-get-operation). `{fabricName}` is `Azure`.
26
27
27
28
The *GET* URI has all the required parameters. There's no need for an additional request body.
28
29
@@ -127,7 +128,7 @@ Triggering restore operations is a *POST* request. To know more about the API, r
127
128
POST https://management.azure.com/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupFabrics/{fabricName}/protectionContainers/{containerName}/protectedItems/{protectedItemName}/recoveryPoints/{recoveryPointId}/restore?api-version=2019-05-13
128
129
```
129
130
130
-
The `{containerName}` and `{protectedItemName}` are as constructed [here](backup-azure-arm-userestapi-backupazurevms.md#example-responses-to-get-operation). `{fabricName}` is "Azure" and the `{recoveryPointId}` is the `{name}` field of the recovery point mentioned [above](#example-response).
131
+
The `{containerName}` and `{protectedItemName}` are as constructed [here](backup-azure-arm-userestapi-backupazurevms.md#responses-to-get-operation). `{fabricName}` is "Azure" and the `{recoveryPointId}` is the `{name}` field of the recovery point mentioned [above](#example-response).
131
132
132
133
Once the recovery point is obtained, we need to construct the request body for the relevant restore scenario. The following sections outline the request body for each scenario.
133
134
@@ -243,7 +244,7 @@ The following request body defines properties required to trigger a disk restore
243
244
244
245
### Restore disks selectively
245
246
246
-
If you are[selectively backing up disks](backup-azure-arm-userestapi-backupazurevms.md#excluding-disks-in-azure-vm-backup), then the current backed-up disk list is provided in the [recovery point summary](#select-recovery-point) and [detailed response](/rest/api/backup/recovery-points/get). You can also selectively restore disks and more details are provided [here](selective-disk-backup-restore.md#selective-disk-restore). To selectively restore a disk among the list of backed up disks, find the LUN of the disk from the recovery point response and add the **restoreDiskLunList** property to the [request body above](#example-request) as shown below.
247
+
If you're[selectively backing up disks](backup-azure-arm-userestapi-backupazurevms.md#excluding-disks-in-azure-vm-backup), then the current backed-up disk list is provided in the [recovery point summary](#select-recovery-point) and [detailed response](/rest/api/backup/recovery-points/get). You can also selectively restore disks and more details are provided [here](selective-disk-backup-restore.md#selective-disk-restore). To selectively restore a disk among the list of backed up disks, find the LUN of the disk from the recovery point response and add the **restoreDiskLunList** property to the [request body above](#example-request) as shown below.
247
248
248
249
```json
249
250
{
@@ -349,7 +350,7 @@ GET https://management.azure.com/Subscriptions/{subscriptionId}/resourceGroups/{
349
350
350
351
```
351
352
352
-
The `{containerName}` and `{protectedItemName}` are as constructed [here](backup-azure-arm-userestapi-backupazurevms.md#example-responses-to-get-operation). `{fabricName}` is "Azure".
353
+
The `{containerName}` and `{protectedItemName}` are as constructed [here](backup-azure-arm-userestapi-backupazurevms.md#responses-to-get-operation). `{fabricName}` is `Azure`.
353
354
354
355
The *GET* URI has all the required parameters. An additional request body isn't required.
0 commit comments