1. Packages
  2. Azure Classic
  3. API Docs
  4. backup
  5. ProtectedVM

We recommend using Azure Native.

Viewing docs for Azure v4.42.0 (Older version)
published on Monday, Mar 9, 2026 by Pulumi
azure logo

We recommend using Azure Native.

Viewing docs for Azure v4.42.0 (Older version)
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:

    BackupPolicyId string
    Specifies the id of the backup policy to use.
    RecoveryVaultName string
    Specifies the name of the Recovery Services Vault to use. Changing this forces a new resource to be created.
    ResourceGroupName string
    The name of the resource group in which to create the Recovery Services Vault. Changing this forces a new resource to be created.
    SourceVmId string
    Specifies the ID of the VM to backup. Changing this forces a new resource to be created.
    ExcludeDiskLuns List<int>
    A list of Disks' Logical Unit Numbers(LUN) to be excluded for VM Protection.
    IncludeDiskLuns List<int>
    A list of Disks' Logical Unit Numbers(LUN) to be included for VM Protection.
    Tags Dictionary<string, string>
    A mapping of tags to assign to the resource.
    BackupPolicyId string
    Specifies the id of the backup policy to use.
    RecoveryVaultName string
    Specifies the name of the Recovery Services Vault to use. Changing this forces a new resource to be created.
    ResourceGroupName string
    The name of the resource group in which to create the Recovery Services Vault. Changing this forces a new resource to be created.
    SourceVmId string
    Specifies the ID of the VM to backup. Changing this forces a new resource to be created.
    ExcludeDiskLuns []int
    A list of Disks' Logical Unit Numbers(LUN) to be excluded for VM Protection.
    IncludeDiskLuns []int
    A list of Disks' Logical Unit Numbers(LUN) to be included for VM Protection.
    Tags map[string]string
    A mapping of tags to assign to the resource.
    backupPolicyId String
    Specifies the id of the backup policy to use.
    recoveryVaultName String
    Specifies the name of the Recovery Services Vault to use. Changing this forces a new resource to be created.
    resourceGroupName String
    The name of the resource group in which to create the Recovery Services Vault. Changing this forces a new resource to be created.
    sourceVmId String
    Specifies the ID of the VM to backup. Changing this forces a new resource to be created.
    excludeDiskLuns List<Integer>
    A list of Disks' Logical Unit Numbers(LUN) to be excluded for VM Protection.
    includeDiskLuns List<Integer>
    A list of Disks' Logical Unit Numbers(LUN) to be included for VM Protection.
    tags Map<String,String>
    A mapping of tags to assign to the resource.
    backupPolicyId string
    Specifies the id of the backup policy to use.
    recoveryVaultName string
    Specifies the name of the Recovery Services Vault to use. Changing this forces a new resource to be created.
    resourceGroupName string
    The name of the resource group in which to create the Recovery Services Vault. Changing this forces a new resource to be created.
    sourceVmId string
    Specifies the ID of the VM to backup. Changing this forces a new resource to be created.
    excludeDiskLuns number[]
    A list of Disks' Logical Unit Numbers(LUN) to be excluded for VM Protection.
    includeDiskLuns number[]
    A list of Disks' Logical Unit Numbers(LUN) to be included for VM Protection.
    tags {[key: string]: string}
    A mapping of tags to assign to the resource.
    backup_policy_id str
    Specifies the id of the backup policy to use.
    recovery_vault_name str
    Specifies the name of the Recovery Services Vault to use. Changing this forces a new resource to be created.
    resource_group_name str
    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_id str
    Specifies the ID of the VM to backup. Changing this forces a new resource to be created.
    exclude_disk_luns Sequence[int]
    A list of Disks' Logical Unit Numbers(LUN) to be excluded for VM Protection.
    include_disk_luns Sequence[int]
    A list of Disks' Logical Unit Numbers(LUN) to be included for VM Protection.
    tags Mapping[str, str]
    A mapping of tags to assign to the resource.
    backupPolicyId String
    Specifies the id of the backup policy to use.
    recoveryVaultName String
    Specifies the name of the Recovery Services Vault to use. Changing this forces a new resource to be created.
    resourceGroupName String
    The name of the resource group in which to create the Recovery Services Vault. Changing this forces a new resource to be created.
    sourceVmId String
    Specifies the ID of the VM to backup. Changing this forces a new resource to be created.
    excludeDiskLuns List<Number>
    A list of Disks' Logical Unit Numbers(LUN) to be excluded for VM Protection.
    includeDiskLuns List<Number>
    A list of Disks' Logical Unit Numbers(LUN) to be included for VM Protection.
    tags 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) -> ProtectedVM
    func 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.
    The following state arguments are supported:
    BackupPolicyId string
    Specifies the id of the backup policy to use.
    ExcludeDiskLuns List<int>
    A list of Disks' Logical Unit Numbers(LUN) to be excluded for VM Protection.
    IncludeDiskLuns List<int>
    A list of Disks' Logical Unit Numbers(LUN) to be included for VM Protection.
    RecoveryVaultName string
    Specifies the name of the Recovery Services Vault to use. Changing this forces a new resource to be created.
    ResourceGroupName string
    The name of the resource group in which to create the Recovery Services Vault. Changing this forces a new resource to be created.
    SourceVmId string
    Specifies the ID of the VM to backup. Changing this forces a new resource to be created.
    Tags Dictionary<string, string>
    A mapping of tags to assign to the resource.
    BackupPolicyId string
    Specifies the id of the backup policy to use.
    ExcludeDiskLuns []int
    A list of Disks' Logical Unit Numbers(LUN) to be excluded for VM Protection.
    IncludeDiskLuns []int
    A list of Disks' Logical Unit Numbers(LUN) to be included for VM Protection.
    RecoveryVaultName string
    Specifies the name of the Recovery Services Vault to use. Changing this forces a new resource to be created.
    ResourceGroupName string
    The name of the resource group in which to create the Recovery Services Vault. Changing this forces a new resource to be created.
    SourceVmId string
    Specifies the ID of the VM to backup. Changing this forces a new resource to be created.
    Tags map[string]string
    A mapping of tags to assign to the resource.
    backupPolicyId String
    Specifies the id of the backup policy to use.
    excludeDiskLuns List<Integer>
    A list of Disks' Logical Unit Numbers(LUN) to be excluded for VM Protection.
    includeDiskLuns List<Integer>
    A list of Disks' Logical Unit Numbers(LUN) to be included for VM Protection.
    recoveryVaultName String
    Specifies the name of the Recovery Services Vault to use. Changing this forces a new resource to be created.
    resourceGroupName String
    The name of the resource group in which to create the Recovery Services Vault. Changing this forces a new resource to be created.
    sourceVmId String
    Specifies the ID of the VM to backup. Changing this forces a new resource to be created.
    tags Map<String,String>
    A mapping of tags to assign to the resource.
    backupPolicyId string
    Specifies the id of the backup policy to use.
    excludeDiskLuns number[]
    A list of Disks' Logical Unit Numbers(LUN) to be excluded for VM Protection.
    includeDiskLuns number[]
    A list of Disks' Logical Unit Numbers(LUN) to be included for VM Protection.
    recoveryVaultName string
    Specifies the name of the Recovery Services Vault to use. Changing this forces a new resource to be created.
    resourceGroupName string
    The name of the resource group in which to create the Recovery Services Vault. Changing this forces a new resource to be created.
    sourceVmId string
    Specifies the ID of the VM to backup. Changing this forces a new resource to be created.
    tags {[key: string]: string}
    A mapping of tags to assign to the resource.
    backup_policy_id str
    Specifies the id of the backup policy to use.
    exclude_disk_luns Sequence[int]
    A list of Disks' Logical Unit Numbers(LUN) to be excluded for VM Protection.
    include_disk_luns Sequence[int]
    A list of Disks' Logical Unit Numbers(LUN) to be included for VM Protection.
    recovery_vault_name str
    Specifies the name of the Recovery Services Vault to use. Changing this forces a new resource to be created.
    resource_group_name str
    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_id str
    Specifies the ID of the VM to backup. Changing this forces a new resource to be created.
    tags Mapping[str, str]
    A mapping of tags to assign to the resource.
    backupPolicyId String
    Specifies the id of the backup policy to use.
    excludeDiskLuns List<Number>
    A list of Disks' Logical Unit Numbers(LUN) to be excluded for VM Protection.
    includeDiskLuns List<Number>
    A list of Disks' Logical Unit Numbers(LUN) to be included for VM Protection.
    recoveryVaultName String
    Specifies the name of the Recovery Services Vault to use. Changing this forces a new resource to be created.
    resourceGroupName String
    The name of the resource group in which to create the Recovery Services Vault. Changing this forces a new resource to be created.
    sourceVmId String
    Specifies the ID of the VM to backup. Changing this forces a new resource to be created.
    tags 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 azurerm Terraform Provider.
    azure logo

    We recommend using Azure Native.

    Viewing docs for Azure v4.42.0 (Older version)
    published on Monday, Mar 9, 2026 by Pulumi
      Try Pulumi Cloud free. Your team will thank you.