|
| 1 | +--- |
| 2 | +title: 'Quickstart: Create an Azure windows web app 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: 06/25/2024 |
| 6 | +ms.custom: devx-track-terraform |
| 7 | +ms.service: windows |
| 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 using Terraform |
| 14 | + |
| 15 | +In this quickstart, you use Terraform to create an Azure windows web app with a backup schedule and a .NET application stack using Terraform. Azure windows web app is a fully managed platform for building, deploying, and scaling web apps. It's designed to let you focus on your application code, without the worry of managing infrastructure or the underlying operating system. You can use it to host web apps, REST APIs, and backend services for mobile, desktop, and web applications. |
| 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 `main.tf` and insert the following code. |
| 45 | +:::code language="Terraform" source="~/terraform_samples_test/quickstart/101-app-service-backup/main.tf"::: |
| 46 | + |
| 47 | +1. Create a file named `outputs.tf` and insert the following code. |
| 48 | +:::code language="Terraform" source="~/terraform_samples_test/quickstart/101-app-service-backup/outputs.tf"::: |
| 49 | + |
| 50 | +1. Create a file named `providers.tf` and insert the following code. |
| 51 | +:::code language="Terraform" source="~/terraform_samples_test/quickstart/101-app-service-backup/providers.tf"::: |
| 52 | + |
| 53 | +1. Create a file named `variables.tf` and insert the following code. |
| 54 | +:::code language="Terraform" source="~/terraform_samples_test/quickstart/101-app-service-backup/variables.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 | +You must 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 Azure windows web app](/search/?terms=Azure%20windows%20web%20app%20and%20terraform) |
0 commit comments