Skip to content

Latest commit

 

History

History
132 lines (85 loc) · 5.36 KB

File metadata and controls

132 lines (85 loc) · 5.36 KB
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

Quickstart: Create an Azure Batch account using Terraform

Get started with Azure Batch 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]

In this article, you learn how to:

[!div class="checklist"]

Prerequisites

Implement the Terraform code

  1. Create a directory in which to test and run the sample Terraform code and make it the current directory.

  2. Create a file named providers.tf and insert the following code:

    [!code-terraformmaster]

  3. Create a file named main.tf and insert the following code:

    [!code-terraformmaster]

  4. Create a file named variables.tf and insert the following code:

    [!code-terraformmaster]

  5. Create a file named outputs.tf and insert the following code:

    [!code-terraformmaster]

Initialize Terraform

[!INCLUDE terraform-init.md]

Create a Terraform execution plan

[!INCLUDE terraform-plan.md]

Apply a Terraform execution plan

[!INCLUDE terraform-apply-plan.md]

Verify the results

  1. Get the Azure resource group name.

    resource_group_name=$(terraform output -raw resource_group_name)
  2. Get the Batch account name.

    batch_name=$(terraform output -raw batch_name)
  3. Run az batch account show to display information about the new Batch account.

    az batch account show \
        --resource-group $resource_group_name \
        --name $batch_name
    
  1. Get the Azure resource group name.

    $resource_group_name=$(terraform output -raw resource_group_name)
  2. Get the Batch account name.

    $batch_name=$(terraform output -raw batch_name)
  3. Run Get-AzBatchAccount to display information about the new service.

    Get-AzBatchAccount -ResourceGroupName $resource_group_name `
                       -Name $batch_name
    

Clean up resources

[!INCLUDE terraform-plan-destroy.md]

Troubleshoot Terraform on Azure

Troubleshoot common problems when using Terraform on Azure

Next steps

[!div class="nextstepaction"] Run your first Batch job with the Azure CLI