|
1 | 1 | ---
|
2 |
| -title: Auto-Enable Backup on VM Creation using Azure Policy |
3 |
| -description: 'An article describing how to use Azure Policy to auto-enable backup for all VMs created in a given scope' |
| 2 | +title: Audit and enforce backup during VM creation automatically using Azure Policy |
| 3 | +description: Learn how to use Azure Policy to autoenable backup for all VMs created in a given scope. |
4 | 4 | ms.topic: how-to
|
5 |
| -ms.date: 06/29/2024 |
| 5 | +ms.date: 06/09/2025 |
6 | 6 | ms.service: azure-backup
|
7 | 7 | author: jyothisuri
|
8 | 8 | ms.author: jsuri
|
9 | 9 | ms.custom: engagement-fy24
|
10 | 10 | ---
|
11 | 11 |
|
12 |
| -# Auto-enable backup on VM creation using Azure Policy |
| 12 | +# Audit and enforce backup during virtual machine creation automatically using Azure Policy |
13 | 13 |
|
14 |
| -One of the key responsibilities of a Backup or Compliance Admin in an organization is to ensure that all business-critical machines are backed up with the appropriate retention. |
| 14 | +This article describes how Backup or Compliance Admins can ensure that all business-critical machines have appropriate backup and retention policies. |
15 | 15 |
|
16 |
| -Today, Azure Backup provides a variety of built-in policies (using [Azure Policy](../governance/policy/overview.md)) to help you automatically ensure that your Azure virtual machines are configured for backup. Depending on how your backup teams and resources are organized, you can use any one of the below policies: |
| 16 | +Azure Backup offers a variety of built-in policies through [Azure Policy](../governance/policy/overview.md) to help you automatically configure backup for your Azure Virtual Machines (VMs). Based on the structure of your backup teams and the organization of your resources, you can choose the most suitable policy from the following options to ensure effective and consistent backup management. |
17 | 17 |
|
18 |
| -## Policy 1 - Configure backup on VMs without a given tag to an existing recovery services vault in the same location |
| 18 | +## Azure Policy types for Azure VM backup |
19 | 19 |
|
20 |
| -If your organization has a central backup team that manages backups across application teams, you can use this policy to configure backup to an existing central Recovery Services vault in the same subscription and location as the VMs being governed. You can choose to **exclude** VMs which contain a certain tag, from the scope of this policy. |
| 20 | +The following table lists the various policy types that allows you to manage Azure VM instances backups automatically: |
21 | 21 |
|
22 |
| -## Policy 2 - Configure backup on VMs with a given tag to an existing recovery services vault in the same location |
23 |
| -This policy works the same as Policy 1 above, with the only difference being that you can use this policy to **include** VMs which contain a certain tag, in the scope of this policy. |
| 22 | +| Policy type | Description | |
| 23 | +| --- | --- | |
| 24 | +| Policy 1 | Configures backup on VMs without a given tag to an existing Recovery Services vault in the same location. | |
| 25 | +| Policy 2 | Configures backup on VMs with a given tag to an existing Recovery Services vault in the same location. | |
| 26 | +| Policy 3 | Configures backup on VMs without a given tag to a new Recovery Services vault with a default policy. | |
| 27 | +| Policy 4 | Configures backup on VMs with a given tag to a new Recovery Services vault with a default policy. | |
24 | 28 |
|
25 |
| -## Policy 3 - Configure backup on VMs without a given tag to a new recovery services vault with a default policy |
26 |
| -If you organize applications in dedicated resource groups and want to have them backed up by the same vault, this policy allows you to automatically manage this action. You can choose to **exclude** VMs which contain a certain tag, from the scope of this policy. |
| 29 | +### Policy 1: Configure backup on VMs without a given tag to an existing recovery services vault in the same location |
27 | 30 |
|
28 |
| -## Policy 4 - Configure backup on VMs with a given tag to a new recovery services vault with a default policy |
29 |
| -This policy works the same as Policy 3 above, with the only difference being that you can use this policy to **include** VMs which contain a certain tag, in the scope of this policy. |
| 31 | +This policy enables a central backup team to configure backup for Azure Virtual Machines using an existing central Recovery Services vault located in the same subscription and region as the governed VMs. You can **exclude** specific VMs from the policy scope with a designated tag. |
30 | 32 |
|
31 |
| -In addition to the above, Azure Backup also provides an [audit-only](../governance/policy/concepts/effects.md#audit) policy - **Azure Backup should be enabled for Virtual Machines**. This policy identifies which virtual machines do not have backup enabled, but doesn't automatically configure backups for these VMs. This is useful when you are only looking to evaluate the overall compliance of the VMs but not looking to take action immediately. |
32 | 33 |
|
33 |
| -## Supported Scenarios |
| 34 | +### Policy 2: Configure backup on VMs with a given tag to an existing recovery services vault in the same location |
| 35 | +This policy functions same as Policy 1, with a key difference - the policy **includes** virtual machines in the policy scope if they have a specific tag. |
34 | 36 |
|
35 |
| -* The built-in policy is currently supported only for Azure VMs. Users must take care to ensure that the retention policy specified during assignment is a VM retention policy. Refer to [this](./backup-azure-policy-supported-skus.md) document to see all the VM SKUs supported by this policy. |
| 37 | +### Policy 3: Configure backup on VMs without a given tag to a new recovery services vault with a default policy |
36 | 38 |
|
37 |
| -* Policies 1 and 2 can be assigned to a single location and subscription at a time. To enable backup for VMs across locations and subscriptions, multiple instances of the policy assignment need to be created, one for each combination of location and subscription. |
| 39 | +This policy targets applications organized in dedicated resource groups and backs them up using the same Recovery Services vault. It automatically manages this configuration and allows you to **exclude** virtual machines from the policy scope that have a specific tag. |
38 | 40 |
|
39 |
| -* For Policies 1 and 2, management group scope is currently unsupported. |
| 41 | +### Policy 4: Configure backup on VMs with a given tag to a new recovery services vault with a default policy |
40 | 42 |
|
41 |
| -* For Policies 1 and 2, the specified vault and the VMs configured for backup can be under different resource groups. |
| 43 | +This policy functions same as Policy 3, with a key difference - the policy **includes** virtual machines in the policy scope if they have a specific tag. |
42 | 44 |
|
43 |
| -* Policies 3 and 4 can be assigned to a single subscription at a time (or a resource group within a subscription). |
| 45 | +Azure Backup also provides an [audit-only](../governance/policy/concepts/effects.md#audit) policy - **Azure Backup should be enabled for Virtual Machines**. This policy identifies virtual machines without backup enabled but doesn't apply any backup configuration, which helps assess compliance without enforcing changes. |
| 46 | + |
| 47 | +## Supported and unsupported Scenarios for Azure VMs backup with Azure Policy |
| 48 | + |
| 49 | +The following table lists the supported and unsupported scenarios for the available policy types: |
| 50 | + |
| 51 | +| Policy type | Supported | Unsupported | |
| 52 | +| --- | --- | --- | |
| 53 | +| **Built-in policy** | Currently supported only for Azure VMs. Ensure that the retention policy specified during assignment is a VM retention policy. <br><br> Learn about [the VM SKUs supported by this policy](./backup-azure-policy-supported-skus.md) . | | |
| 54 | +| **Policies 1 and 2** | - Can be assigned to a single location and subscription at a time. To enable backup for VMs across locations and subscriptions, you need to create multiple instances of the policy assignment, one for each combination of location and subscription. <br><br> - The specified vault and the VMs configured for backup can be under different resource groups. | Management group scope is currently unsupported. | |
| 55 | +| **Policies 3 and 4** | Can be assigned to a single subscription at a time (or a resource group within a subscription). | | |
44 | 56 |
|
45 | 57 | [!INCLUDE [backup-center.md](../../includes/backup-center.md)]
|
46 | 58 |
|
47 |
| -## Using the built-in policies |
| 59 | +## Assign built-in Azure Policy for Azure VM backup |
| 60 | + |
| 61 | +This section outlines the end-to-end steps to assign [Policy 1](#policy-1-configure-backup-on-vms-without-a-given-tag-to-an-existing-recovery-services-vault-in-the-same-location). The same instructions apply to the other policies. After assignment, the policy automatically configures backup for any new VM created within the defined scope. |
| 62 | + |
| 63 | +To assign Policy 1 for Azure VM backup, follow these steps: |
| 64 | + |
| 65 | +1. In the [Azure portal](https://portal.azure.com/), go to **Policy**> **Authoring** > **Definitions** to view the list of all built-in policies across Azure Resources. |
| 66 | + |
| 67 | +1. On the **Policy Definitions** pane, filter the list for **Category=Backup** and select the policy named *Configure backup on virtual machines without a given tag to an existing recovery services vault in the same location*. |
| 68 | + |
| 69 | + :::image type="content" source="./media/backup-azure-auto-enable-backup/policy-dashboard-inline.png" alt-text="Screenshot showing how to filter the list by category on Policy dashboard." lightbox="./media/backup-azure-auto-enable-backup/policy-dashboard-expanded.png"::: |
| 70 | + |
| 71 | +1. On the selected policy pane, review the policy details, and then select **Assign**. |
| 72 | + |
| 73 | + :::image type="content" source="./media/backup-azure-auto-enable-backup/policy-definition-blade.png" alt-text="Screenshot shows the Policy Definition pane." lightbox="./media/backup-azure-auto-enable-backup/policy-definition-blade.png"::: |
| 74 | + |
| 75 | +1. On the **Assign Policy** pane, on the **Basics** tab, select the **more icon** corresponding to **Scope**. |
| 76 | + |
| 77 | + :::image type="content" source="./media/backup-azure-auto-enable-backup/policy-assignment-basics.png" alt-text="Screenshot shows the Policy Assignment Basics tab." lightbox="./media/backup-azure-auto-enable-backup/policy-assignment-basics.png"::: |
| 78 | + |
| 79 | +1. On the right context pane, select the subscription for the policy to be applied on. |
| 80 | + |
| 81 | + You can also select a resource group, so that the policy is applied only for VMs in a particular resource group. |
| 82 | + |
| 83 | +1. On the **Parameters** tab, select the **Location**, **Vault**, and **Backup Policy** to which the VMs in the scope must be associated. |
| 84 | + |
| 85 | + You can also specify a tag name and an array of tag values. A VM which contains any of the specified values for the given tag are excluded from the scope of the policy assignment. |
| 86 | + |
| 87 | + :::image type="content" source="./media/backup-azure-auto-enable-backup/policy-assignment-parameters.png" alt-text="Screenshot shows the Policy Assignment Parameters pane." lightbox="./media/backup-azure-auto-enable-backup/policy-assignment-parameters.png"::: |
48 | 88 |
|
49 |
| -The below steps describe the end-to-end process of assigning Policy 1: **Configure backup on VMs without a given tag to an existing recovery services vault in the same location** to a given scope. Similar instructions will apply for the other policies. Once assigned, any new VM created in the scope is automatically configured for backup. |
| 89 | + Ensure that **Effect** is set to **`deployIfNotExists`**. |
50 | 90 |
|
51 |
| -1. Sign in to the Azure portal and navigate to the **Policy** Dashboard. |
52 |
| -2. Select **Definitions** in the left menu to get a list of all built-in policies across Azure Resources. |
53 |
| -3. Filter the list for **Category=Backup** and select the policy named *Configure backup on virtual machines without a given tag to an existing recovery services vault in the same location*. |
54 |
| -:::image type="content" source="./media/backup-azure-auto-enable-backup/policy-dashboard-inline.png" alt-text="Screenshot showing how to filter the list by category on Policy dashboard." lightbox="./media/backup-azure-auto-enable-backup/policy-dashboard-expanded.png"::: |
55 |
| -4. Select the name of the policy. You'll be redirected to the detailed definition for this policy. |
56 |
| - |
57 |
| -5. Select the **Assign** button at the top of the pane. This redirects you to the **Assign Policy** pane. |
58 |
| -6. Under **Basics**, select the three dots next to the **Scope** field. This opens up a right context pane where you can select the subscription for the policy to be applied on. You can also optionally select a resource group, so that the policy is applied only for VMs in a particular resource group. |
59 |
| - |
60 |
| -7. In the **Parameters** tab, choose a location from the drop-down, and select the vault and backup policy to which the VMs in the scope must be associated. You can also choose to specify a tag name and an array of tag values. A VM which contains any of the specified values for the given tag will be excluded from the scope of the policy assignment. |
61 |
| - |
62 |
| -8. Ensure that **Effect** is set to deployIfNotExists. |
63 |
| -9. Navigate to **Review+create** and select **Create**. |
| 91 | +1. On the **Review+create** tab, select **Create**. |
64 | 92 |
|
65 | 93 | > [!NOTE]
|
66 | 94 | >
|
67 | 95 | > - Azure Policy can also be used on existing VMs, using [remediation](../governance/policy/how-to/remediate-resources.md).
|
68 |
| -> - It's recommended that this policy not be assigned to more than 200 VMs at a time. If the policy is assigned to more than 200 VMs, it can result in the backup being triggered a few hours later than that specified by the schedule. |
| 96 | +> - Avoid assigning this policy to more than 200 VM at once, as it might delay backup triggers by several hours beyond the scheduled time. |
69 | 97 |
|
70 |
| -## Next step |
| 98 | +## Related content |
71 | 99 |
|
72 |
| -[Learn more about Azure Policy](../governance/policy/overview.md) |
| 100 | +[About Azure Policy](../governance/policy/overview.md). |
0 commit comments