Azure Recovery Services Protection Container

This page shows how to write Terraform and Azure Resource Manager for Recovery Services Protection Container and write them securely.

azurerm_site_recovery_protection_container (Terraform)

The Protection Container in Recovery Services can be configured in Terraform with the resource name azurerm_site_recovery_protection_container. The following sections describe 10 examples of how to use the resource and its parameters.

Example Usage from GitHub

main.tf#L14
resource "azurerm_site_recovery_protection_container" "primary" {
  name                 = "primary-protection-container"
  resource_group_name = var.secondary_resource_group_name
  recovery_vault_name = var.vault_name
  recovery_fabric_name = azurerm_site_recovery_fabric.primary.name
}
main.tf#L31
resource "azurerm_site_recovery_protection_container" "primary" {
  count                = signum(var.create ? 1 : 0)
  name                 = "primary-protection-container"
  resource_group_name  = var.resource_group_name
  recovery_vault_name  = azurerm_recovery_services_vault.vault.*.name[0]
  recovery_fabric_name = azurerm_site_recovery_fabric.primary.*.name[0]
main.tf#L31
resource "azurerm_site_recovery_protection_container" "primary" {
  count                = signum(var.create ? 1 : 0)
  name                 = "primary-protection-container"
  resource_group_name  = var.resource_group_name
  recovery_vault_name  = azurerm_recovery_services_vault.vault.*.name[0]
  recovery_fabric_name = azurerm_site_recovery_fabric.primary.*.name[0]
main.tf#L7
resource "azurerm_site_recovery_protection_container" "this" {
  name                 = var.name
  recovery_fabric_name = var.recovery_fabric_name
  recovery_vault_name  = var.recovery_vault_name
  resource_group_name  = var.resource_group_name

main.tf#L7
resource "azurerm_site_recovery_protection_container" "this" {
  name                 = var.name
  recovery_fabric_name = var.recovery_fabric_name
  recovery_vault_name  = var.recovery_vault_name
  resource_group_name  = var.resource_group_name

protection_container.tf#L4
resource "azurerm_site_recovery_protection_container" "protection_container" {
  for_each = try(var.settings.protection_containers, {})

  name                 = each.value.name
  resource_group_name  = var.resource_group_name
  recovery_vault_name  = azurerm_recovery_services_vault.asr.name
protection_container.tf#L1
resource "azurerm_site_recovery_protection_container" "protection_container" {
  depends_on = [azurerm_recovery_services_vault.asr, azurerm_site_recovery_fabric.recovery_fabric]
  # depends_on = [time_sleep.delay_create]
  for_each = try(var.settings.protection_containers, {})

  name                 = each.value.name
protection_container.tf#L4
resource "azurerm_site_recovery_protection_container" "protection_container" {
  for_each = try(var.settings.protection_containers, {})

  name                 = each.value.name
  resource_group_name  = var.resource_group_name
  recovery_vault_name  = azurerm_recovery_services_vault.asr.name
protection_container.tf#L1
resource "azurerm_site_recovery_protection_container" "protection_container" {
  depends_on = [azurerm_recovery_services_vault.asr, azurerm_site_recovery_fabric.recovery_fabric]
  # depends_on = [time_sleep.delay_create]
  for_each = try(var.settings.protection_containers, {})

  name                 = each.value.name
protection_container.tf#L4
resource "azurerm_site_recovery_protection_container" "protection_container" {
  for_each = try(var.settings.protection_containers, {})

  name                 = each.value.name
  resource_group_name  = var.resource_group_name
  recovery_vault_name  = azurerm_recovery_services_vault.asr.name

Review your Terraform file for Azure best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

Explanation in Terraform Registry

Manages a Azure Site Recovery protection container. Protection containers serve as containers for replicated VMs and belong to a single region / recovery fabric. Protection containers can contain more than one replicated VM. To replicate a VM, a container must exist in both the source and target Azure regions.

Microsoft.RecoveryServices/vaults/replicationFabrics/replicationProtectionContainers (Azure Resource Manager)

The vaults/replicationFabrics/replicationProtectionContainers in Microsoft.RecoveryServices can be configured in Azure Resource Manager with the resource name Microsoft.RecoveryServices/vaults/replicationFabrics/replicationProtectionContainers. The following sections describe how to use the resource and its parameters.

Example Usage from GitHub

An example could not be found in GitHub.

Frequently asked questions

What is Azure Recovery Services Protection Container?

Azure Recovery Services Protection Container is a resource for Recovery Services of Microsoft Azure. Settings can be wrote in Terraform.

Where can I find the example code for the Azure Recovery Services Protection Container?

For Terraform, the adamdost-msft/azure-cloud-ops, rohrerb/terraform-eiac and tmeadon/clippings source code examples are useful. See the Terraform Example section for further details.