ProtectedVM

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
	})
}
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)
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,
});

Create a ProtectedVM Resource

new ProtectedVM(name: string, args: ProtectedVMArgs, opts?: CustomResourceOptions);
@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,
                tags: Optional[Mapping[str, str]] = None)
@overload
def ProtectedVM(resource_name: str,
                args: ProtectedVMArgs,
                opts: Optional[ResourceOptions] = None)
func NewProtectedVM(ctx *Context, name string, args ProtectedVMArgs, opts ...ResourceOption) (*ProtectedVM, error)
public ProtectedVM(string name, ProtectedVMArgs args, CustomResourceOptions? opts = null)
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.

ProtectedVM Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.

Inputs

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.
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.
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.
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.
tags Mapping[str, str]
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 str
The provider-assigned unique ID for this managed resource.

Look up an 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,
        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)
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.

The following state arguments are supported:

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.
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.
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.
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.
tags Mapping[str, str]
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

Package Details

Repository
https://github.com/pulumi/pulumi-azure
License
Apache-2.0
Notes
This Pulumi package is based on the azurerm Terraform Provider.