Skip to content

Commit abe0c6a

Browse files
Merge pull request #273076 from AbhishekMallick-MS/Apr-23-2024-Freshness1
Freshness - VM backup with REST
2 parents d7d738f + 6f236c2 commit abe0c6a

File tree

2 files changed

+42
-33
lines changed

2 files changed

+42
-33
lines changed

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

Lines changed: 34 additions & 26 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/24/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](#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).
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
@@ -150,14 +151,14 @@ The response contains the list of all unprotected Azure VMs and each `{value}` c
150151

151152
- containerName = "iaasvmcontainer;"+`{name}`
152153
- 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)
154155

155156
In the example, the above values translate to:
156157

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

@@ -197,20 +198,27 @@ The following request body defines properties required to create a protected ite
197198
}
198199
```
199200

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+
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](#create-the-request-body-for-on-demand-backup).
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
|---------|---------|---------|
@@ -413,7 +421,7 @@ Since the backup job is a long running operation, it needs to be tracked as expl
413421

414422
### Changing the policy of protection
415423

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

418426
```json
419427
{
@@ -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,9 +492,9 @@ 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

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

491499
```http
492500
{

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
---
22
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
67
ms.assetid: b8487516-7ac5-4435-9680-674d9ecf5642
78
author: AbhishekMallick-MS
89
ms.author: v-abhmallick
@@ -22,7 +23,7 @@ The available recovery points of a backup item can be listed using the [list rec
2223
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
2324
```
2425

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`.
2627

2728
The *GET* URI has all the required parameters. There's no need for an additional request body.
2829

@@ -127,7 +128,7 @@ Triggering restore operations is a *POST* request. To know more about the API, r
127128
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
128129
```
129130

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

132133
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.
133134

@@ -243,7 +244,7 @@ The following request body defines properties required to trigger a disk restore
243244

244245
### Restore disks selectively
245246

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

248249
```json
249250
{
@@ -349,7 +350,7 @@ GET https://management.azure.com/Subscriptions/{subscriptionId}/resourceGroups/{
349350
350351
```
351352

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`.
353354

354355
The *GET* URI has all the required parameters. An additional request body isn't required.
355356

0 commit comments

Comments
 (0)