Skip to content

Commit 5c4c7b7

Browse files
committed
updates1
1 parent 7cf153d commit 5c4c7b7

File tree

2 files changed

+139
-0
lines changed

2 files changed

+139
-0
lines changed
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
---
2+
title: 'Quickstart: Use Terraform to create an Azure Recovery Services vault'
3+
description: In this quickstart, you learn how to create a resource group, an Azure Recovery Services vault, and a backup policy to share files in the Azure environment.
4+
ms.topic: quickstart
5+
ms.date: 01/17/2025
6+
ms.custom: devx-track-terraform
7+
ms.service: azure-site-recovery
8+
author: ankitaduttaMSFT
9+
ms.author: ankitadutta
10+
#customer intent: As a Terraform user, I want to learn how to create a resource group, Azure Recovery Services vault, and a backup policy to share files in Azure.
11+
content_well_notification:
12+
- AI-contribution
13+
---
14+
15+
# Quickstart: Use Terraform to create an Azure Recovery Services vault
16+
17+
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](site-recovery-overview.md) 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.
18+
19+
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.
20+
21+
[!INCLUDE [About Terraform](~/azure-dev-docs-pr/articles/terraform/includes/abstract.md)]
22+
23+
> [!div class="checklist"]
24+
> * Create an Azure resource group with a unique name.
25+
> * Define local variables for the SKU name and tier.
26+
> * Create an Azure Recovery Services vault in the resource group.
27+
> * Create a backup policy to share files in the resource group.
28+
> * Output the names of the Recovery Services Vault and the backup policy for sharing files.
29+
30+
## Prerequisites
31+
32+
- Create an Azure account with an active subscription. You can [create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
33+
34+
- [Install and configure Terraform](/azure/developer/terraform/quickstart-configure).
35+
36+
## Implement the Terraform code
37+
38+
> [!NOTE]
39+
> The sample code for this article is located in the [Azure Terraform GitHub repo](https://github.com/Azure/terraform/tree/master/quickstart/101-azure-recovery-services). You can view the log file containing the [test results from current and previous versions of Terraform](https://github.com/Azure/terraform/tree/master/quickstart/101-azure-recovery-services/TestRecord.md).
40+
>
41+
> See more [articles and sample code showing how to use Terraform to manage Azure resources](/azure/terraform).
42+
43+
1. Create a directory in which to test and run the sample Terraform code, and make it the current directory.
44+
45+
1. Create a file named `main.tf`, and insert the following code:
46+
:::code language="Terraform" source="~/terraform_samples/quickstart/101-azure-recovery-services/main.tf":::
47+
48+
1. Create a file named `outputs.tf`, and insert the following code:
49+
:::code language="Terraform" source="~/terraform_samples/quickstart/101-azure-recovery-services/outputs.tf":::
50+
51+
1. Create a file named `providers.tf`, and insert the following code:
52+
:::code language="Terraform" source="~/terraform_samples/quickstart/101-azure-recovery-services/providers.tf":::
53+
54+
1. Create a file named `variables.tf`, and insert the following code:
55+
:::code language="Terraform" source="~/terraform_samples/quickstart/101-azure-recovery-services/variables.tf":::
56+
57+
## Initialize Terraform
58+
59+
[!INCLUDE [terraform-init.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-init.md)]
60+
61+
## Create a Terraform execution plan
62+
63+
[!INCLUDE [terraform-plan.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-plan.md)]
64+
65+
## Apply a Terraform execution plan
66+
67+
[!INCLUDE [terraform-apply-plan.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-apply-plan.md)]
68+
69+
## Verify the results
70+
71+
### [Azure CLI](#tab/azure-cli)
72+
73+
1. Get the Azure resource group name.
74+
75+
```console
76+
resource_group_name=$(terraform output -raw resource_group_name)
77+
```
78+
79+
1. Get the Azure Recovery Services vault name.
80+
81+
```console
82+
recovery_services_vault_name=$(terraform output -recovery_services_vault_name)
83+
```
84+
85+
1. Get the Azure Recovery Services vault backup policy file share name.
86+
87+
```console
88+
backup_policy_file_share_name=$(terraform output -backup_policy_file_share_name)
89+
```
90+
91+
1. Run [`az backup vault show`](/cli/azure/backup/vault#az-backup-vault-show) to view the Azure Recovery Services vault.
92+
93+
```azurecli
94+
az backup vault show --name $recovery_services_vault_name --resource group $resource_group_name
95+
```
96+
97+
### [Azure PowerShell](#tab/azure-powershell)
98+
99+
1. Get the Azure resource group name.
100+
101+
```console
102+
$resource_group_name=$(terraform output -raw resource_group_name)
103+
```
104+
105+
1. Get the Azure Recovery Services vault name.
106+
107+
```console
108+
$recovery_services_vault_name=$(terraform output -raw recovery_services_vault_name)
109+
```
110+
111+
1. Get the Azure Recovery Services vault backup policy file share name.
112+
113+
```console
114+
$backup_policy_file_share_name=$(terraform output -raw backup_policy_file_share_name)
115+
```
116+
117+
1. Run [`Get-AzRecoveryServicesVault`](/powershell/module/az.recoveryservieces/get-azrecoveryservicesvault) to view the Azure Recovery Services vault.
118+
119+
```azurepowershell
120+
Get-AzRecoveryServicesVault -ResourceGroupName $resource_group_name -Name $recovery_services_vault_name
121+
```
122+
123+
---
124+
125+
## Clean up resources
126+
127+
[!INCLUDE [terraform-plan-destroy.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-plan-destroy.md)]
128+
129+
## Troubleshoot Terraform on Azure
130+
131+
[Troubleshoot common problems when using Terraform on Azure](/azure/developer/terraform/troubleshoot).
132+
133+
## Next steps
134+
135+
> [!div class="nextstepaction"]
136+
> [See more articles about Azure Recovery Services vault](/search/?terms=Azure%20recovery%20services%20vault%20and%20terraform).

articles/site-recovery/toc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
- name: Create a vault - ARM template
2828
displayName: Resource Manager
2929
href: quickstart-create-vault-template.md
30+
- name: Create a vault - Terraform
31+
displayName: ARM, Resource Manager
32+
href: quickstart-create-vault-terraform.md
3033
- name: Tutorials
3134
items:
3235
- name: Azure VM disaster recovery to Azure

0 commit comments

Comments
 (0)