We recommend using Azure Native.
published on Monday, Mar 9, 2026 by Pulumi
We recommend using Azure Native.
published on Monday, Mar 9, 2026 by Pulumi
Manages Azure Backup for an Azure VM
Example Usage
using Pulumi;
using Azure = Pulumi.Azure;
class MyStack : Stack
{
public MyStack()
{
var exampleResourceGroup = new Azure.Core.ResourceGroup("exampleResourceGroup", new Azure.Core.ResourceGroupArgs
{
Location = "West Europe",
});
var exampleVault = new Azure.RecoveryServices.Vault("exampleVault", new Azure.RecoveryServices.VaultArgs
{
Location = exampleResourceGroup.Location,
ResourceGroupName = exampleResourceGroup.Name,
Sku = "Standard",
});
var examplePolicyVM = new Azure.Backup.PolicyVM("examplePolicyVM", new Azure.Backup.PolicyVMArgs
{
ResourceGroupName = exampleResourceGroup.Name,
RecoveryVaultName = exampleVault.Name,
Backup = new Azure.Backup.Inputs.PolicyVMBackupArgs
{
Frequency = "Daily",
Time = "23:00",
},
});
var vm1 = new Azure.Backup.ProtectedVM("vm1", new Azure.Backup.ProtectedVMArgs
{
ResourceGroupName = exampleResourceGroup.Name,
RecoveryVaultName = exampleVault.Name,
SourceVmId = azurerm_virtual_machine.Example.Id,
BackupPolicyId = examplePolicyVM.Id,
});
}
}
package main
import (
"github.com/pulumi/pulumi-azure/sdk/v4/go/azure/backup"
"github.com/pulumi/pulumi-azure/sdk/v4/go/azure/core"
"github.com/pulumi/pulumi-azure/sdk/v4/go/azure/recoveryservices"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
exampleResourceGroup, err := core.NewResourceGroup(ctx, "exampleResourceGroup", &core.ResourceGroupArgs{
Location: pulumi.String("West Europe"),
})
if err != nil {
return err
}
exampleVault, err := recoveryservices.NewVault(ctx, "exampleVault", &recoveryservices.VaultArgs{
Location: exampleResourceGroup.Location,
ResourceGroupName: exampleResourceGroup.Name,
Sku: pulumi.String("Standard"),
})
if err != nil {
return err
}
examplePolicyVM, err := backup.NewPolicyVM(ctx, "examplePolicyVM", &backup.PolicyVMArgs{
ResourceGroupName: exampleResourceGroup.Name,
RecoveryVaultName: exampleVault.Name,
Backup: &backup.PolicyVMBackupArgs{
Frequency: pulumi.String("Daily"),
Time: pulumi.String("23:00"),
},
})
if err != nil {
return err
}
_, err = backup.NewProtectedVM(ctx, "vm1", &backup.ProtectedVMArgs{
ResourceGroupName: exampleResourceGroup.Name,
RecoveryVaultName: exampleVault.Name,
SourceVmId: pulumi.Any(azurerm_virtual_machine.Example.Id),
BackupPolicyId: examplePolicyVM.ID(),
})
if err != nil {
return err
}
return nil
})
}
Example coming soon!
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
const exampleResourceGroup = new azure.core.ResourceGroup("exampleResourceGroup", {location: "West Europe"});
const exampleVault = new azure.recoveryservices.Vault("exampleVault", {
location: exampleResourceGroup.location,
resourceGroupName: exampleResourceGroup.name,
sku: "Standard",
});
const examplePolicyVM = new azure.backup.PolicyVM("examplePolicyVM", {
resourceGroupName: exampleResourceGroup.name,
recoveryVaultName: exampleVault.name,
backup: {
frequency: "Daily",
time: "23:00",
},
});
const vm1 = new azure.backup.ProtectedVM("vm1", {
resourceGroupName: exampleResourceGroup.name,
recoveryVaultName: exampleVault.name,
sourceVmId: azurerm_virtual_machine.example.id,
backupPolicyId: examplePolicyVM.id,
});
import pulumi
import pulumi_azure as azure
example_resource_group = azure.core.ResourceGroup("exampleResourceGroup", location="West Europe")
example_vault = azure.recoveryservices.Vault("exampleVault",
location=example_resource_group.location,
resource_group_name=example_resource_group.name,
sku="Standard")
example_policy_vm = azure.backup.PolicyVM("examplePolicyVM",
resource_group_name=example_resource_group.name,
recovery_vault_name=example_vault.name,
backup=azure.backup.PolicyVMBackupArgs(
frequency="Daily",
time="23:00",
))
vm1 = azure.backup.ProtectedVM("vm1",
resource_group_name=example_resource_group.name,
recovery_vault_name=example_vault.name,
source_vm_id=azurerm_virtual_machine["example"]["id"],
backup_policy_id=example_policy_vm.id)
Example coming soon!
Create ProtectedVM Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new ProtectedVM(name: string, args: ProtectedVMArgs, opts?: CustomResourceOptions);@overload
def ProtectedVM(resource_name: str,
args: ProtectedVMArgs,
opts: Optional[ResourceOptions] = None)
@overload
def ProtectedVM(resource_name: str,
opts: Optional[ResourceOptions] = None,
backup_policy_id: Optional[str] = None,
recovery_vault_name: Optional[str] = None,
resource_group_name: Optional[str] = None,
source_vm_id: Optional[str] = None,
exclude_disk_luns: Optional[Sequence[int]] = None,
include_disk_luns: Optional[Sequence[int]] = None,
tags: Optional[Mapping[str, str]] = None)func NewProtectedVM(ctx *Context, name string, args ProtectedVMArgs, opts ...ResourceOption) (*ProtectedVM, error)public ProtectedVM(string name, ProtectedVMArgs args, CustomResourceOptions? opts = null)
public ProtectedVM(String name, ProtectedVMArgs args)
public ProtectedVM(String name, ProtectedVMArgs args, CustomResourceOptions options)
type: azure:backup:ProtectedVM
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args ProtectedVMArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args ProtectedVMArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args ProtectedVMArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args ProtectedVMArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args ProtectedVMArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var protectedVMResource = new Azure.Backup.ProtectedVM("protectedVMResource", new()
{
BackupPolicyId = "string",
RecoveryVaultName = "string",
ResourceGroupName = "string",
SourceVmId = "string",
ExcludeDiskLuns = new[]
{
0,
},
IncludeDiskLuns = new[]
{
0,
},
Tags =
{
{ "string", "string" },
},
});
example, err := backup.NewProtectedVM(ctx, "protectedVMResource", &backup.ProtectedVMArgs{
BackupPolicyId: pulumi.String("string"),
RecoveryVaultName: pulumi.String("string"),
ResourceGroupName: pulumi.String("string"),
SourceVmId: pulumi.String("string"),
ExcludeDiskLuns: pulumi.IntArray{
pulumi.Int(0),
},
IncludeDiskLuns: pulumi.IntArray{
pulumi.Int(0),
},
Tags: pulumi.StringMap{
"string": pulumi.String("string"),
},
})
var protectedVMResource = new ProtectedVM("protectedVMResource", ProtectedVMArgs.builder()
.backupPolicyId("string")
.recoveryVaultName("string")
.resourceGroupName("string")
.sourceVmId("string")
.excludeDiskLuns(0)
.includeDiskLuns(0)
.tags(Map.of("string", "string"))
.build());
protected_vm_resource = azure.backup.ProtectedVM("protectedVMResource",
backup_policy_id="string",
recovery_vault_name="string",
resource_group_name="string",
source_vm_id="string",
exclude_disk_luns=[0],
include_disk_luns=[0],
tags={
"string": "string",
})
const protectedVMResource = new azure.backup.ProtectedVM("protectedVMResource", {
backupPolicyId: "string",
recoveryVaultName: "string",
resourceGroupName: "string",
sourceVmId: "string",
excludeDiskLuns: [0],
includeDiskLuns: [0],
tags: {
string: "string",
},
});
type: azure:backup:ProtectedVM
properties:
backupPolicyId: string
excludeDiskLuns:
- 0
includeDiskLuns:
- 0
recoveryVaultName: string
resourceGroupName: string
sourceVmId: string
tags:
string: string
ProtectedVM Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The ProtectedVM resource accepts the following input properties:
- Backup
Policy stringId - Specifies the id of the backup policy to use.
- Recovery
Vault stringName - Specifies the name of the Recovery Services Vault to use. Changing this forces a new resource to be created.
- Resource
Group stringName - The name of the resource group in which to create the Recovery Services Vault. Changing this forces a new resource to be created.
- Source
Vm stringId - Specifies the ID of the VM to backup. Changing this forces a new resource to be created.
- Exclude
Disk List<int>Luns - A list of Disks' Logical Unit Numbers(LUN) to be excluded for VM Protection.
- Include
Disk List<int>Luns - A list of Disks' Logical Unit Numbers(LUN) to be included for VM Protection.
- Dictionary<string, string>
- A mapping of tags to assign to the resource.
- Backup
Policy stringId - Specifies the id of the backup policy to use.
- Recovery
Vault stringName - Specifies the name of the Recovery Services Vault to use. Changing this forces a new resource to be created.
- Resource
Group stringName - The name of the resource group in which to create the Recovery Services Vault. Changing this forces a new resource to be created.
- Source
Vm stringId - Specifies the ID of the VM to backup. Changing this forces a new resource to be created.
- Exclude
Disk []intLuns - A list of Disks' Logical Unit Numbers(LUN) to be excluded for VM Protection.
- Include
Disk []intLuns - A list of Disks' Logical Unit Numbers(LUN) to be included for VM Protection.
- map[string]string
- A mapping of tags to assign to the resource.
- backup
Policy StringId - Specifies the id of the backup policy to use.
- recovery
Vault StringName - Specifies the name of the Recovery Services Vault to use. Changing this forces a new resource to be created.
- resource
Group StringName - The name of the resource group in which to create the Recovery Services Vault. Changing this forces a new resource to be created.
- source
Vm StringId - Specifies the ID of the VM to backup. Changing this forces a new resource to be created.
- exclude
Disk List<Integer>Luns - A list of Disks' Logical Unit Numbers(LUN) to be excluded for VM Protection.
- include
Disk List<Integer>Luns - A list of Disks' Logical Unit Numbers(LUN) to be included for VM Protection.
- Map<String,String>
- A mapping of tags to assign to the resource.
- backup
Policy stringId - Specifies the id of the backup policy to use.
- recovery
Vault stringName - Specifies the name of the Recovery Services Vault to use. Changing this forces a new resource to be created.
- resource
Group stringName - The name of the resource group in which to create the Recovery Services Vault. Changing this forces a new resource to be created.
- source
Vm stringId - Specifies the ID of the VM to backup. Changing this forces a new resource to be created.
- exclude
Disk number[]Luns - A list of Disks' Logical Unit Numbers(LUN) to be excluded for VM Protection.
- include
Disk number[]Luns - A list of Disks' Logical Unit Numbers(LUN) to be included for VM Protection.
- {[key: string]: string}
- A mapping of tags to assign to the resource.
- backup_
policy_ strid - Specifies the id of the backup policy to use.
- recovery_
vault_ strname - Specifies the name of the Recovery Services Vault to use. Changing this forces a new resource to be created.
- resource_
group_ strname - The name of the resource group in which to create the Recovery Services Vault. Changing this forces a new resource to be created.
- source_
vm_ strid - Specifies the ID of the VM to backup. Changing this forces a new resource to be created.
- exclude_
disk_ Sequence[int]luns - A list of Disks' Logical Unit Numbers(LUN) to be excluded for VM Protection.
- include_
disk_ Sequence[int]luns - A list of Disks' Logical Unit Numbers(LUN) to be included for VM Protection.
- Mapping[str, str]
- A mapping of tags to assign to the resource.
- backup
Policy StringId - Specifies the id of the backup policy to use.
- recovery
Vault StringName - Specifies the name of the Recovery Services Vault to use. Changing this forces a new resource to be created.
- resource
Group StringName - The name of the resource group in which to create the Recovery Services Vault. Changing this forces a new resource to be created.
- source
Vm StringId - Specifies the ID of the VM to backup. Changing this forces a new resource to be created.
- exclude
Disk List<Number>Luns - A list of Disks' Logical Unit Numbers(LUN) to be excluded for VM Protection.
- include
Disk List<Number>Luns - A list of Disks' Logical Unit Numbers(LUN) to be included for VM Protection.
- Map<String>
- A mapping of tags to assign to the resource.
Outputs
All input properties are implicitly available as output properties. Additionally, the ProtectedVM resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing ProtectedVM Resource
Get an existing ProtectedVM resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: ProtectedVMState, opts?: CustomResourceOptions): ProtectedVM@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
backup_policy_id: Optional[str] = None,
exclude_disk_luns: Optional[Sequence[int]] = None,
include_disk_luns: Optional[Sequence[int]] = None,
recovery_vault_name: Optional[str] = None,
resource_group_name: Optional[str] = None,
source_vm_id: Optional[str] = None,
tags: Optional[Mapping[str, str]] = None) -> ProtectedVMfunc GetProtectedVM(ctx *Context, name string, id IDInput, state *ProtectedVMState, opts ...ResourceOption) (*ProtectedVM, error)public static ProtectedVM Get(string name, Input<string> id, ProtectedVMState? state, CustomResourceOptions? opts = null)public static ProtectedVM get(String name, Output<String> id, ProtectedVMState state, CustomResourceOptions options)resources: _: type: azure:backup:ProtectedVM get: id: ${id}- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Backup
Policy stringId - Specifies the id of the backup policy to use.
- Exclude
Disk List<int>Luns - A list of Disks' Logical Unit Numbers(LUN) to be excluded for VM Protection.
- Include
Disk List<int>Luns - A list of Disks' Logical Unit Numbers(LUN) to be included for VM Protection.
- Recovery
Vault stringName - Specifies the name of the Recovery Services Vault to use. Changing this forces a new resource to be created.
- Resource
Group stringName - The name of the resource group in which to create the Recovery Services Vault. Changing this forces a new resource to be created.
- Source
Vm stringId - Specifies the ID of the VM to backup. Changing this forces a new resource to be created.
- Dictionary<string, string>
- A mapping of tags to assign to the resource.
- Backup
Policy stringId - Specifies the id of the backup policy to use.
- Exclude
Disk []intLuns - A list of Disks' Logical Unit Numbers(LUN) to be excluded for VM Protection.
- Include
Disk []intLuns - A list of Disks' Logical Unit Numbers(LUN) to be included for VM Protection.
- Recovery
Vault stringName - Specifies the name of the Recovery Services Vault to use. Changing this forces a new resource to be created.
- Resource
Group stringName - The name of the resource group in which to create the Recovery Services Vault. Changing this forces a new resource to be created.
- Source
Vm stringId - Specifies the ID of the VM to backup. Changing this forces a new resource to be created.
- map[string]string
- A mapping of tags to assign to the resource.
- backup
Policy StringId - Specifies the id of the backup policy to use.
- exclude
Disk List<Integer>Luns - A list of Disks' Logical Unit Numbers(LUN) to be excluded for VM Protection.
- include
Disk List<Integer>Luns - A list of Disks' Logical Unit Numbers(LUN) to be included for VM Protection.
- recovery
Vault StringName - Specifies the name of the Recovery Services Vault to use. Changing this forces a new resource to be created.
- resource
Group StringName - The name of the resource group in which to create the Recovery Services Vault. Changing this forces a new resource to be created.
- source
Vm StringId - Specifies the ID of the VM to backup. Changing this forces a new resource to be created.
- Map<String,String>
- A mapping of tags to assign to the resource.
- backup
Policy stringId - Specifies the id of the backup policy to use.
- exclude
Disk number[]Luns - A list of Disks' Logical Unit Numbers(LUN) to be excluded for VM Protection.
- include
Disk number[]Luns - A list of Disks' Logical Unit Numbers(LUN) to be included for VM Protection.
- recovery
Vault stringName - Specifies the name of the Recovery Services Vault to use. Changing this forces a new resource to be created.
- resource
Group stringName - The name of the resource group in which to create the Recovery Services Vault. Changing this forces a new resource to be created.
- source
Vm stringId - Specifies the ID of the VM to backup. Changing this forces a new resource to be created.
- {[key: string]: string}
- A mapping of tags to assign to the resource.
- backup_
policy_ strid - Specifies the id of the backup policy to use.
- exclude_
disk_ Sequence[int]luns - A list of Disks' Logical Unit Numbers(LUN) to be excluded for VM Protection.
- include_
disk_ Sequence[int]luns - A list of Disks' Logical Unit Numbers(LUN) to be included for VM Protection.
- recovery_
vault_ strname - Specifies the name of the Recovery Services Vault to use. Changing this forces a new resource to be created.
- resource_
group_ strname - The name of the resource group in which to create the Recovery Services Vault. Changing this forces a new resource to be created.
- source_
vm_ strid - Specifies the ID of the VM to backup. Changing this forces a new resource to be created.
- Mapping[str, str]
- A mapping of tags to assign to the resource.
- backup
Policy StringId - Specifies the id of the backup policy to use.
- exclude
Disk List<Number>Luns - A list of Disks' Logical Unit Numbers(LUN) to be excluded for VM Protection.
- include
Disk List<Number>Luns - A list of Disks' Logical Unit Numbers(LUN) to be included for VM Protection.
- recovery
Vault StringName - Specifies the name of the Recovery Services Vault to use. Changing this forces a new resource to be created.
- resource
Group StringName - The name of the resource group in which to create the Recovery Services Vault. Changing this forces a new resource to be created.
- source
Vm StringId - Specifies the ID of the VM to backup. Changing this forces a new resource to be created.
- Map<String>
- A mapping of tags to assign to the resource.
Import
Recovery Services Protected VMs can be imported using the resource id, e.g.
$ pulumi import azure:backup/protectedVM:ProtectedVM item1 "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.RecoveryServices/vaults/example-recovery-vault/backupFabrics/Azure/protectionContainers/iaasvmcontainer;iaasvmcontainerv2;group1;vm1/protectedItems/vm;iaasvmcontainerv2;group1;vm1"
Note the ID requires quoting as there are semicolons
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- Azure Classic pulumi/pulumi-azure
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
azurermTerraform Provider.
We recommend using Azure Native.
published on Monday, Mar 9, 2026 by Pulumi
