|
| 1 | +--- |
| 2 | +title: 'Quickstart: Create an Azure Windows web app with a backup using Terraform' |
| 3 | +description: In this quickstart, you create an Azure Windows web app with a backup schedule and a .NET application stack. |
| 4 | +ms.topic: quickstart |
| 5 | +ms.date: 07/02/2024 |
| 6 | +ms.custom: devx-track-terraform |
| 7 | +ms.service: app-service |
| 8 | +author: msangapu-msft |
| 9 | +ms.author: msangapu |
| 10 | +customer intent: As a Terraform user, I want to see how to create an Azure Windows web app with a backup schedule and a .NET application stack. |
| 11 | +--- |
| 12 | + |
| 13 | +# Quickstart: Create an Azure Windows web app with a backup using Terraform |
| 14 | + |
| 15 | +In Azure App Service, you can make on-demand custom backups or configure scheduled custom backups. In this quickstart, you use Terraform to create an Azure Windows web app with a backup schedule and a .NET application stack. For more information about App Service backups and restores, see [Back up and restore your app in Azure App Service](/azure/app-service/manage-backup?tabs=portal). |
| 16 | + |
| 17 | +[!INCLUDE [About Terraform](~/azure-dev-docs-pr/articles/terraform/includes/abstract.md)] |
| 18 | + |
| 19 | +> [!div class="checklist"] |
| 20 | +> * Create an Azure storage account and container with the randomly generated name . |
| 21 | +> * Create an Azure service plan with the randomly generated name . |
| 22 | +> * Generate a Shared Access Signature (SAS) for the storage account. |
| 23 | +> * Create an Azure Windows web app with the randomly generated name . |
| 24 | +> * Configure a backup schedule for the web app. |
| 25 | +> * Specify the application stack for the web app. |
| 26 | +> * Output the names of key resources created with the Terraform script. |
| 27 | +> * Output the default hostname of the Windows web app. |
| 28 | +
|
| 29 | +## Prerequisites |
| 30 | + |
| 31 | +- Create an Azure account with an active subscription. You can [create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F). |
| 32 | + |
| 33 | +- [Install and configure Terraform](/azure/developer/terraform/quickstart-configure) |
| 34 | + |
| 35 | +## Implement the Terraform code |
| 36 | + |
| 37 | +> [!NOTE] |
| 38 | +> The sample code for this article is located in the [Azure Terraform GitHub repo](https://github.com/Azure/terraform/tree/master/quickstart/101-app-service-backup). 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-app-service-backup/TestRecord.md). |
| 39 | +> |
| 40 | +> See more [articles and sample code showing how to use Terraform to manage Azure resources](/azure/terraform) |
| 41 | +
|
| 42 | +1. Create a directory in which to test and run the sample Terraform code and make it the current directory. |
| 43 | + |
| 44 | +1. Create a file named `providers.tf` and insert the following code. |
| 45 | + :::code language="Terraform" source="~/terraform_samples/quickstart/101-app-service-backup/providers.tf"::: |
| 46 | + |
| 47 | +1. Create a file named `main.tf` and insert the following code. |
| 48 | + :::code language="Terraform" source="~/terraform_samples/quickstart/101-app-service-backup/main.tf"::: |
| 49 | + |
| 50 | +1. Create a file named `variables.tf` and insert the following code. |
| 51 | + :::code language="Terraform" source="~/terraform_samples/quickstart/101-app-service-backup/variables.tf"::: |
| 52 | + |
| 53 | +1. Create a file named `outputs.tf` and insert the following code. |
| 54 | + :::code language="Terraform" source="~/terraform_samples/quickstart/101-app-service-backup/outputs.tf"::: |
| 55 | + |
| 56 | +## Initialize Terraform |
| 57 | + |
| 58 | +[!INCLUDE [terraform-init.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-init.md)] |
| 59 | + |
| 60 | +## Create a Terraform execution plan |
| 61 | + |
| 62 | +[!INCLUDE [terraform-plan.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-plan.md)] |
| 63 | + |
| 64 | +## Apply a Terraform execution plan |
| 65 | + |
| 66 | +[!INCLUDE [terraform-apply-plan.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-apply-plan.md)] |
| 67 | + |
| 68 | +## Verify the results |
| 69 | + |
| 70 | +Run [az webapp show](/cli/azure/webapp#az-webapp-show) to view the Azure Windows web app. |
| 71 | + |
| 72 | +```azurecli |
| 73 | +az webapp show --name <web_app_name> --resource-group <resource_group_name> |
| 74 | +``` |
| 75 | + |
| 76 | +Replace `<web_app_name>` with the name of your Azure Windows web app and `<resource_group_name>` with the name of your resource group. |
| 77 | + |
| 78 | +## Clean up resources |
| 79 | + |
| 80 | +[!INCLUDE [terraform-plan-destroy.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-plan-destroy.md)] |
| 81 | + |
| 82 | +## Troubleshoot Terraform on Azure |
| 83 | + |
| 84 | +[Troubleshoot common problems when using Terraform on Azure](/azure/developer/terraform/troubleshoot). |
| 85 | + |
| 86 | +## Next steps |
| 87 | + |
| 88 | +> [!div class="nextstepaction"] |
| 89 | +> [See more articles about App Service](/azure/app-service) |
0 commit comments