Proposed Pull Request Change

title description ms.topic ms.service ms.date ms.custom author ms.author content_well_notification ai-usage
Quickstart: Create an Azure Batch account using Terraform In this article, you create an Azure Batch account using Terraform quickstart azure-batch 04/02/2025 devx-track-terraform TomArcherMsft tarcher ['AI-contribution'] ai-assisted
📄 Document Links
GitHub View on GitHub Microsoft Learn View on Microsoft Learn
Content Truncation Detected
The generated rewrite appears to be incomplete.
Original lines: -
Output lines: -
Ratio: -
Raw New Markdown
Generating updated version of doc...
Rendered New Markdown
Generating updated version of doc...
+0 -0
+0 -0
--- title: 'Quickstart: Create an Azure Batch account using Terraform' description: 'In this article, you create an Azure Batch account using Terraform' ms.topic: quickstart ms.service: azure-batch ms.date: 04/02/2025 ms.custom: devx-track-terraform author: TomArcherMsft ms.author: tarcher content_well_notification: - AI-contribution ai-usage: ai-assisted # Customer intent: "As a cloud engineer, I want to create an Azure Batch account using Terraform, so that I can quickly set up compute resources and manage large workloads efficiently." --- # Quickstart: Create an Azure Batch account using Terraform Get started with [Azure Batch](/azure/batch/batch-technical-overview) by using Terraform to create a Batch account, including storage. You need a Batch account to create compute resources (pools of compute nodes) and Batch jobs. You can link an Azure Storage account with your Batch account. This pairing is useful to deploy applications and store input and output data for most real-world workloads. After completing this quickstart, you'll understand the key concepts of the Batch service and be ready to try Batch with more realistic workloads at larger scale. [!INCLUDE [Terraform abstract](~/azure-dev-docs-pr/articles/terraform/includes/abstract.md)] In this article, you learn how to: > [!div class="checklist"] > * Create a random value for the Azure resource group name using [random_pet](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet) > * Create an Azure resource group using [azurerm_resource_group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) > * Create a random value using [random_string](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string) > * Create an Azure Storage account using [azurerm_storage_account](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account) > * Create an Azure Batch account using [azurerm_batch_account](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/batch_account) ## Prerequisites - [Install and configure Terraform](/azure/developer/terraform/quickstart-configure) ## Implement the Terraform code > [!NOTE] > The sample code for this article is located in the [Azure Terraform GitHub repo](https://github.com/Azure/terraform/tree/master/quickstart/101-batch-account-with-storage). 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-batch-account-with-storage/TestRecord.md). > > See more [articles and sample code showing how to use Terraform to manage Azure resources](/azure/terraform) 1. Create a directory in which to test and run the sample Terraform code and make it the current directory. 1. Create a file named `providers.tf` and insert the following code: [!code-terraform[master](~/terraform_samples/quickstart/101-batch-account-with-storage/providers.tf)] 1. Create a file named `main.tf` and insert the following code: [!code-terraform[master](~/terraform_samples/quickstart/101-batch-account-with-storage/main.tf)] 1. Create a file named `variables.tf` and insert the following code: [!code-terraform[master](~/terraform_samples/quickstart/101-batch-account-with-storage/variables.tf)] 1. Create a file named `outputs.tf` and insert the following code: [!code-terraform[master](~/terraform_samples/quickstart/101-batch-account-with-storage/outputs.tf)] ## Initialize Terraform [!INCLUDE [terraform-init.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-init.md)] ## Create a Terraform execution plan [!INCLUDE [terraform-plan.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-plan.md)] ## Apply a Terraform execution plan [!INCLUDE [terraform-apply-plan.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-apply-plan.md)] ## Verify the results #### [Azure CLI](#tab/azure-cli) 1. Get the Azure resource group name. ```console resource_group_name=$(terraform output -raw resource_group_name) ``` 1. Get the Batch account name. ```console batch_name=$(terraform output -raw batch_name) ``` 1. Run [az batch account show](/cli/azure/batch/account#az-batch-account-show) to display information about the new Batch account. ```azurecli az batch account show \ --resource-group $resource_group_name \ --name $batch_name ``` #### [Azure PowerShell](#tab/azure-powershell) 1. Get the Azure resource group name. ```console $resource_group_name=$(terraform output -raw resource_group_name) ``` 1. Get the Batch account name. ```console $batch_name=$(terraform output -raw batch_name) ``` 1. Run [Get-AzBatchAccount](/powershell/module/az.batch/get-azbatchaccount) to display information about the new service. ```azurepowershell Get-AzBatchAccount -ResourceGroupName $resource_group_name ` -Name $batch_name ``` --- ## Clean up resources [!INCLUDE [terraform-plan-destroy.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-plan-destroy.md)] ## Troubleshoot Terraform on Azure [Troubleshoot common problems when using Terraform on Azure](/azure/developer/terraform/troubleshoot) ## Next steps > [!div class="nextstepaction"] > [Run your first Batch job with the Azure CLI](/azure/batch/quick-create-cli)
Success! Branch created successfully. Create Pull Request on GitHub
Error: