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
+30-22Lines changed: 30 additions & 22 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/23/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](#example-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](#enabling-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
@@ -157,7 +158,7 @@ In the example, the above values translate to:
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
@@ -198,19 +199,26 @@ The following request body defines properties required to create a protected ite
198
199
```
199
200
200
201
The `{sourceResourceId}` is the `{virtualMachineId}` mentioned above from the [response of list protectable items](#example-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](#example-request-body).
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
|---------|---------|---------|
@@ -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,7 +492,7 @@ 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
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](#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.
0 commit comments