Imirce go Cruinniú Mullaigh Nuálaíoch:
Foghlaim conas is féidir le haistriú agus nuachóiriú go Azure feidhmíocht, athléimneacht agus slándáil do ghnó a threisiú, rud a chuireann ar do chumas glacadh go hiomlán le IS.Cláraigh anois
Ní thacaítear leis an mbrabhsálaí seo a thuilleadh.
Uasghrádú go Microsoft Edge chun leas a bhaint as na gnéithe is déanaí, nuashonruithe slándála, agus tacaíocht theicniúil.
Quickstart: Use Terraform to create an Azure Recovery Services vault
Alt
In this quickstart, you learn how to use Terraform to create an Azure resource group, an Azure Recovery Services vault, and a backup policy to share files in Azure. The Azure Site Recovery service can help your business applications to stay online during planned and unplanned outages. Specifically, Site Recovery uses replication, failover, and recovery to manage on-premises machines and Azure virtual machines during disaster recovery. These Site Recovery methods can contribute to your business continuity and disaster recovery strategy.
An Azure Recovery Services vault is a storage entity in Azure that houses data such as backups and recovery points that can protect and manage your data. You create the vault first and then the backup policy for sharing files, which specifies when and how often backups should occur, plus the retention period. This setup can help to ensure that your data is backed up consistently and can be easily restored if needed.
Terraform enables the definition, preview, and deployment of cloud infrastructure. Using Terraform, you create configuration files using HCL syntax. The HCL syntax allows you to specify the cloud provider - such as Azure - and the elements that make up your cloud infrastructure. After you create your configuration files, you create an execution plan that allows you to preview your infrastructure changes before they're deployed. Once you verify the changes, you apply the execution plan to deploy the infrastructure.
Create an Azure resource group with a unique name.
Define local variables for the SKU name and tier.
Create an Azure Recovery Services vault in the resource group.
Create a backup policy to share files in the resource group.
Output the names of the Recovery Services Vault and the backup policy for sharing files.
Create a file named outputs.tf, and insert the following code:
Terraform
output"recovery_services_vault_name" {
value = azurerm_recovery_services_vault.vault.name
}
output"backup_policy_file_share_name" {
value = azurerm_backup_policy_file_share.policy.name
}
Create a file named providers.tf, and insert the following code:
Terraform
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~>3.0"
}
random = {
source = "hashicorp/random"
version = "~>3.0"
}
}
}
provider"azurerm" {
features {}
}
Create a file named variables.tf, and insert the following code:
Terraform
variable"resource_group_location" {
type = string
default = "eastus"
description = "Location of the resource group."
}
variable"resource_group_name_prefix" {
type = string
default = "rg"
description = "Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription."
}
variable"vaultName" {
description = "Name of the Recovery Services Vault."
type = string
default = "examplevault"
}
Initialize Terraform
Run terraform init to initialize the Terraform deployment. This command downloads the Azure provider required to manage your Azure resources.
Console
terraform init -upgrade
Key points:
The -upgrade parameter upgrades the necessary provider plugins to the newest version that complies with the configuration's version constraints.
The terraform plan command creates an execution plan, but doesn't execute it. Instead, it determines what actions are necessary to create the configuration specified in your configuration files. This pattern allows you to verify whether the execution plan matches your expectations before making any changes to actual resources.
The optional -out parameter allows you to specify an output file for the plan. Using the -out parameter ensures that the plan you reviewed is exactly what is applied.
Apply a Terraform execution plan
Run terraform apply to apply the execution plan to your cloud infrastructure.
Console
terraform apply main.tfplan
Key points:
The example terraform apply command assumes you previously ran terraform plan -out main.tfplan.
If you specified a different filename for the -out parameter, use that same filename in the call to terraform apply.
If you didn't use the -out parameter, call terraform apply without any parameters.
The terraform plan command creates an execution plan, but doesn't execute it. Instead, it determines what actions are necessary to create the configuration specified in your configuration files. This pattern allows you to verify whether the execution plan matches your expectations before making any changes to actual resources.
The optional -out parameter allows you to specify an output file for the plan. Using the -out parameter ensures that the plan you reviewed is exactly what is applied.