Skip to content

Commit 8e77e62

Browse files
authored
Merge pull request #288680 from LiSeda/LS_batch_pools
LS_quick-deploy-batch-account-and-two-pools... articles
2 parents 167a222 + 36946af commit 8e77e62

File tree

3 files changed

+207
-0
lines changed

3 files changed

+207
-0
lines changed

articles/batch/TOC.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@
2727
- name: Create a Batch pool and run a job - Python
2828
displayName: quickstart, first, create
2929
href: quick-run-python.md
30+
- name: Deploy a Batch account and two pools - Terraform
31+
displayName: quickstart, first, create
32+
href: quick-deploy-batch-account-two-pools-terraform.md
33+
- name: Deploy a Batch account and two pools with a start task - Terraform
34+
displayName: quickstart, first, create
35+
href: quick-deploy-batch-account-two-pools-start-task-terraform.md
36+
3037
expanded: true
3138
- name: Tutorials
3239
items:
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
---
2+
title: 'Deploy an Azure Batch account and two pools with a start task - Terraform'
3+
description: In this article, you deploy an Azure Batch account and two pools with a start task using Terraform.
4+
ms.topic: quickstart
5+
ms.date: 10/24/2024
6+
ms.custom: devx-track-terraform
7+
ms.service: azure-batch
8+
author: Padmalathas
9+
ms.author: padmalathas
10+
#customer intent: As a Terraform user, I want to see how to create an Azure resource group, Storage account, Batch account, and two Batch pools with different scaling configurations.
11+
content_well_notification:
12+
- AI-contribution
13+
ai-usage: ai-assisted
14+
---
15+
16+
# Deploy an Azure Batch account and two pools with a start task - Terraform
17+
18+
In this quickstart, you create an Azure Batch account, an Azure Storage account, and two Batch pools using Terraform. Batch is a cloud-based job scheduling service that parallelizes and distributes the processing of large volumes of data across many computers. It's typically used for tasks like rendering 3D graphics, analyzing large datasets, or processing video. In this case, the resources created include a Batch account (which is the central organizing entity for distributed processing tasks), a Storage account for holding the data to be processed, and two Batch pools, which are groups of virtual machines that execute the tasks.
19+
20+
[!INCLUDE [About Terraform](~/azure-dev-docs-pr/articles/terraform/includes/abstract.md)]
21+
22+
> [!div class="checklist"]
23+
> * Specify the required version of Terraform and the required providers.
24+
> * Define the Azure provider with no additional features.
25+
> * Define variables for the resource group location and name prefix.
26+
> * Generate a random name for the Azure resource group.
27+
> * Create a resource group with the generated name at a specified location.
28+
> * Generate a random string for the Storage account name.
29+
> * Create a Storage account with the generated name in the created resource group.
30+
> * Generate a random string for the Batch account name.
31+
> * Create a Batch account with the generated name in the created resource group and linked to the created Storage account.
32+
> * Generate a random name for the Batch pool.
33+
> * Create a Batch pool with a fixed scale in the created resource group and linked to the created Batch account.
34+
> * Create a Batch pool with autoscale in the created resource group and linked to the created Batch account.
35+
> * Output the names of the created resource group, Storage account, Batch account, and both Batch pools.
36+
37+
## Prerequisites
38+
39+
- Create an Azure account with an active subscription. You can [create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
40+
- [Install and configure Terraform](/azure/developer/terraform/quickstart-configure).
41+
42+
## Implement the Terraform code
43+
44+
> [!NOTE]
45+
> The sample code for this article is located in the [Azure Terraform GitHub repo](https://github.com/Azure/terraform/tree/master/quickstart/101-batch-pools-with-start-task). 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-pools-with-start-task/TestRecord.md).
46+
>
47+
> See more [articles and sample code showing how to use Terraform to manage Azure resources](/azure/terraform).
48+
49+
1. Create a directory in which to test and run the sample Terraform code, and make it the current directory.
50+
51+
1. Create a file named `main.tf`, and insert the following code:
52+
:::code language="Terraform" source="~/terraform_samples/quickstart/101-batch-pools-with-start-task/main.tf":::
53+
54+
1. Create a file named `outputs.tf`, and insert the following code:
55+
:::code language="Terraform" source="~/terraform_samples/quickstart/101-batch-pools-with-start-task/outputs.tf":::
56+
57+
1. Create a file named `providers.tf`, and insert the following code:
58+
:::code language="Terraform" source="~/terraform_samples/quickstart/101-batch-pools-with-start-task/providers.tf":::
59+
60+
1. Create a file named `variables.tf`, and insert the following code:
61+
:::code language="Terraform" source="~/terraform_samples/quickstart/101-batch-pools-with-start-task/variables.tf":::
62+
63+
## Initialize Terraform
64+
65+
[!INCLUDE [terraform-init.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-init.md)]
66+
67+
## Create a Terraform execution plan
68+
69+
[!INCLUDE [terraform-plan.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-plan.md)]
70+
71+
## Apply a Terraform execution plan
72+
73+
[!INCLUDE [terraform-apply-plan.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-apply-plan.md)]
74+
75+
## Verify the results
76+
77+
### [Azure CLI](#tab/azure-cli)
78+
79+
Run [`az batch account show`](/cli/azure/batch/account#az-batch-account-show) to view the Batch account.
80+
81+
```azurecli
82+
az batch account show --name <batch_account_name> --resource-group <resource_group_name>
83+
```
84+
85+
In the above command, replace `<batch_account_name>` with the name of your Batch account and `<resource_group_name>` with the name of your resource group.
86+
87+
---
88+
89+
## Clean up resources
90+
91+
[!INCLUDE [terraform-plan-destroy.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-plan-destroy.md)]
92+
93+
## Troubleshoot Terraform on Azure
94+
95+
[Troubleshoot common problems when using Terraform on Azure](/azure/developer/terraform/troubleshoot).
96+
97+
## Next steps
98+
99+
> [!div class="nextstepaction"]
100+
> [See more articles about Batch accounts](/search/?terms=Azure%20batch%20account%20and%20terraform).
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
---
2+
title: 'Deploy an Azure Batch account and two pools - Terraform'
3+
description: In this article, you deploy an Azure Batch account and two pools using Terraform.
4+
ms.topic: quickstart
5+
ms.date: 10/24/2024
6+
ms.custom: devx-track-terraform
7+
ms.service: azure-batch
8+
author: Padmalathas
9+
ms.author: padmalathas
10+
#customer intent: As a Terraform user, I want to see how to create an Azure resource group, Storage account, Batch account, and two Batch pools with different scaling configurations.
11+
content_well_notification:
12+
- AI-contribution
13+
ai-usage: ai-assisted
14+
---
15+
16+
# Deploy an Azure Batch account and two pools - Terraform
17+
18+
In this quickstart, you create an Azure Batch account, an Azure Storage account, and two Batch pools using Terraform. Batch is a cloud-based job scheduling service that parallelizes and distributes the processing of large volumes of data across many computers. It's typically used for parametric sweeps, Monte Carlo simulations, financial risk modeling, and other high-performance computing applications. A Batch account is the top-level resource in the Batch service that provides access to pools, jobs, and tasks. The Storage account is used to store and manage all the files that are used and generated by the Batch service, while the two Batch pools are collections of compute nodes that execute the tasks.
19+
20+
[!INCLUDE [About Terraform](~/azure-dev-docs-pr/articles/terraform/includes/abstract.md)]
21+
22+
> [!div class="checklist"]
23+
> * Specify the required version of Terraform and the required providers.
24+
> * Define the Azure provider with no additional features.
25+
> * Define variables for the location of the resource group and the prefix of the resource group name.
26+
> * Generate a random name for the resource group using the provided prefix.
27+
> * Create an Azure resource group with the generated name at the specified location.
28+
> * Generate a random string to be used as the name for the Storage account.
29+
> * Create a Storage account with the generated name in the created resource group, at the same location, and with a standard account tier and locally redundant Storage replication type.
30+
> * Generate another random string to be used as the name for the Batch account.
31+
> * Create a Batch account with the generated name in the created resource group, at the same location, and link it to the created Storage account with Storage keys authentication mode.
32+
> * Generate a random name for the Batch pool with a "pool" prefix.
33+
> * Create a Batch pool with a fixed scale using the generated name in the created resource group, linked to the created Batch account, with a standard A1 virtual machine (VM) size, Ubuntu 22.04 node agent SKU, and a start task that echoes 'Hello World from $env' with a maximum of one retry and waits for success.
34+
> * Create another Batch pool with auto scale, using the same generated name, in the created resource group, linked to the created Batch account, with a standard A1 VM size, Ubuntu 22.04 node agent SKU, and an autoscale formula.
35+
> * Output the names of the created resource group, Storage account, Batch account, and both Batch pools.
36+
37+
## Prerequisites
38+
39+
- Create an Azure account with an active subscription. You can [create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
40+
- [Install and configure Terraform](/azure/developer/terraform/quickstart-configure).
41+
42+
## Implement the Terraform code
43+
44+
> [!NOTE]
45+
> The sample code for this article is located in the [Azure Terraform GitHub repo](https://github.com/Azure/terraform/tree/master/quickstart/101-batch-pools-with-job). 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-pools-with-job/TestRecord.md).
46+
>
47+
> See more [articles and sample code showing how to use Terraform to manage Azure resources](/azure/terraform).
48+
49+
1. Create a directory in which to test and run the sample Terraform code, and make it the current directory.
50+
51+
1. Create a file named `main.tf`, and insert the following code:
52+
:::code language="Terraform" source="~/terraform_samples/quickstart/101-batch-pools-with-job/main.tf":::
53+
54+
1. Create a file named `outputs.tf`, and insert the following code:
55+
:::code language="Terraform" source="~/terraform_samples/quickstart/101-batch-pools-with-job/outputs.tf":::
56+
57+
1. Create a file named `providers.tf`, and insert the following code:
58+
:::code language="Terraform" source="~/terraform_samples/quickstart/101-batch-pools-with-job/providers.tf":::
59+
60+
1. Create a file named `variables.tf`, and insert the following code:
61+
:::code language="Terraform" source="~/terraform_samples/quickstart/101-batch-pools-with-job/variables.tf":::
62+
63+
## Initialize Terraform
64+
65+
[!INCLUDE [terraform-init.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-init.md)]
66+
67+
## Create a Terraform execution plan
68+
69+
[!INCLUDE [terraform-plan.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-plan.md)]
70+
71+
## Apply a Terraform execution plan
72+
73+
[!INCLUDE [terraform-apply-plan.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-apply-plan.md)]
74+
75+
## Verify the results
76+
77+
### [Azure CLI](#tab/azure-cli)
78+
79+
Run [`az batch account show`](/cli/azure/batch/account#az-batch-account-show) to view the Batch account.
80+
81+
```azurecli
82+
az batch account show --name <batch_account_name> --resource-group <resource_group_name>
83+
```
84+
85+
Replace `<batch_account_name>` with the name of your Batch account and `<resource_group_name>` with the name of your resource group.
86+
87+
---
88+
89+
## Clean up resources
90+
91+
[!INCLUDE [terraform-plan-destroy.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-plan-destroy.md)]
92+
93+
## Troubleshoot Terraform on Azure
94+
95+
[Troubleshoot common problems when using Terraform on Azure](/azure/developer/terraform/troubleshoot).
96+
97+
## Next steps
98+
99+
> [!div class="nextstepaction"]
100+
> [See more articles about Batch accounts](/search/?terms=Azure%20batch%20account%20and%20terraform).

0 commit comments

Comments
 (0)