Skip to content

Commit 34224a8

Browse files
author
AbhishekMallick-MS
committed
Freshness - VM backup with REST
1 parent 3dcc65d commit 34224a8

File tree

1 file changed

+30
-22
lines changed

1 file changed

+30
-22
lines changed

articles/backup/backup-azure-arm-userestapi-backupazurevms.md

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
---
2-
title: Back up Azure VMs using REST API
2+
title: Back up Azure VMs using REST API in Azure Backup
33
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
66
ms.assetid: b80b3a41-87bf-49ca-8ef2-68e43c04c1a3
77
author: AbhishekMallick-MS
88
ms.author: v-abhmallick
9+
ms.custom: engagement-fy24
910
---
1011

1112
# Back up an Azure VM using Azure Backup via REST API
1213

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

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

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

1920
## Configure backup for an unprotected Azure VM using REST API
2021

@@ -36,14 +37,14 @@ POST https://management.azure.com/Subscriptions/00000000-0000-0000-0000-00000000
3637

3738
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.
3839

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

4142
|Name |Type |Description |
4243
|---------|---------|---------|
4344
|204 No Content | | OK with No content returned |
4445
|202 Accepted | | Accepted |
4546

46-
##### Example responses to refresh operation
47+
**Example responses to refresh operation**:
4748

4849
Once the *POST* request is submitted, a 202 (Accepted) response is returned.
4950

@@ -89,7 +90,7 @@ X-Powered-By: ASP.NET
8990

9091
### Selecting the relevant Azure VM
9192

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

9495
This operation is a *GET* operation.
9596

@@ -105,9 +106,9 @@ The *GET* URI has all the required parameters. No additional request body is nee
105106
|---------|---------|---------|
106107
|200 OK | [WorkloadProtectableItemResourceList](/rest/api/backup/backup-protectable-items/list#workloadprotectableitemresourcelist) | OK |
107108

108-
#### Example responses to get operation
109+
**Example responses to get operation**:
109110

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

112113
```http
113114
HTTP/1.1 200 OK
@@ -157,7 +158,7 @@ In the example, the above values translate to:
157158
- containerName = "iaasvmcontainer;iaasvmcontainerv2;testRG;testVM"
158159
- protectedItemName = "vm;iaasvmcontainerv2;testRG;testVM"
159160

160-
### Enabling protection for the Azure VM
161+
### Enable protection for the Azure VM
161162

162163
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.
163164

@@ -183,7 +184,7 @@ To create a protected item, following are the components of the request body.
183184

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

186-
##### Example request body
187+
**Example request body**:
187188

188189
The following request body defines properties required to create a protected item.
189190

@@ -198,19 +199,26 @@ The following request body defines properties required to create a protected ite
198199
```
199200

200201
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+
201209

202210
#### Responses to create protected item operation
203211

204212
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.
205213

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

208216
|Name |Type |Description |
209217
|---------|---------|---------|
210218
|200 OK | [ProtectedItemResource](/rest/api/backup/protected-item-operation-results/get#protecteditemresource) | OK |
211219
|202 Accepted | | Accepted |
212220

213-
##### Example responses to create protected item operation
221+
**Example responses to create protected item operation**:
214222

215223
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.
216224

@@ -273,7 +281,7 @@ This confirms that protection is enabled for the VM and the first backup will be
273281

274282
### Excluding disks in Azure VM backup
275283

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

278286
```json
279287
{
@@ -296,9 +304,9 @@ In the request body above, the list of disks to be backed up are provided in the
296304
|Property |Value |
297305
|---------|---------|
298306
|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. |
300308

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

303311
## Trigger an on-demand backup for a protected Azure VM
304312

@@ -343,7 +351,7 @@ The following request body defines properties required to trigger a backup for a
343351

344352
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.
345353

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

348356
|Name |Type |Description |
349357
|---------|---------|---------|
@@ -434,7 +442,7 @@ If the Azure VM is already backed up, you can specify the list of disks to be ba
434442
> [!IMPORTANT]
435443
> 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.
436444
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.
438446

439447
### Stop protection but retain existing data
440448

@@ -472,7 +480,7 @@ DELETE https://management.azure.com//Subscriptions/00000000-0000-0000-0000-00000
472480

473481
*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.
474482

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

477485
|Name |Type |Description |
478486
|---------|---------|---------|
@@ -484,7 +492,7 @@ It returns two responses: 202 (Accepted) when another operation is created and t
484492
485493
### Undo the deletion
486494

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

489497
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.
490498

0 commit comments

Comments
 (0)