Skip to content

Commit e7d1b1d

Browse files
authored
Merge pull request #199226 from carlrab/azurecli-docs-batch
updated parent files for scripts
2 parents c57de20 + bf962c2 commit e7d1b1d

6 files changed

+163
-67
lines changed

articles/batch/scripts/batch-cli-sample-add-application.md

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,61 @@
22
title: Azure CLI Script Example - Add an Application in Batch | Microsoft Docs
33
description: Learn how to add an application for use with an Azure Batch pool or a task using the Azure CLI.
44
ms.topic: sample
5-
ms.date: 09/17/2021
5+
ms.date: 05/24/2022
66
ms.custom: devx-track-azurecli, seo-azure-cli
77
keywords: batch, azure cli samples, azure cli code samples, azure cli script samples
88
---
99

1010
# CLI example: Add an application to an Azure Batch account
1111

12-
This script demonstrates how to add an application for use with an Azure Batch pool or task. To set up an application to add to your Batch account, package your executable, together with any dependencies, into a zip file.
12+
This script demonstrates how to add an application for use with an Azure Batch pool or task. To set up an application to add to your Batch account, package your executable, together with any dependencies, into a zip file.
13+
14+
[!INCLUDE [quickstarts-free-trial-note](../../../includes/quickstarts-free-trial-note.md)]
1315

1416
[!INCLUDE [azure-cli-prepare-your-environment.md](../../../includes/azure-cli-prepare-your-environment.md)]
1517

16-
- This tutorial requires version 2.0.20 or later of the Azure CLI. If using Azure Cloud Shell, the latest version is already installed.
18+
## Sample script
19+
20+
[!INCLUDE [cli-launch-cloud-shell-sign-in.md](../../../includes/cli-launch-cloud-shell-sign-in.md)]
21+
22+
### Create batch account and new application
23+
24+
:::code language="azurecli" source="~/azure_cli_scripts/batch/add-application/add-application.sh" id="FullScript":::
25+
26+
### Create batch application package
1727

18-
## Example script
28+
An application can reference multiple application executable packages of different versions. The executables and any dependencies need to be zipped up for the package. Once uploaded, the CLI attempts to activate the package so that it's ready for use.
1929

20-
[!code-azurecli-interactive[main](../../../cli_scripts/batch/add-application/add-application.sh "Add Application")]
30+
```azurecli
31+
az batch application package create \
32+
--resource-group $resourceGroup \
33+
--name $batchAccount \
34+
--application-name "MyApplication" \
35+
--package-file my-application-exe.zip \
36+
--version-name 1.0
37+
```
38+
39+
### Update the application
40+
41+
Update the application to assign the newly added application package as the default version.
42+
43+
```azurecli
44+
az batch application set \
45+
--resource-group $resourceGroup \
46+
--name $batchAccount \
47+
--application-name "MyApplication" \
48+
--default-version 1.0
49+
```
2150

22-
## Clean up deployment
51+
## Clean up resources
2352

24-
Run the following command to remove the
25-
resource group and all resources associated with it.
53+
[!INCLUDE [cli-clean-up-resources.md](../../../includes/cli-clean-up-resources.md)]
2654

27-
```azurecli-interactive
28-
az group delete --name myResourceGroup
55+
```azurecli
56+
az group delete --name $resourceGroup
2957
```
3058

31-
## Script explanation
59+
## Sample reference
3260

3361
This script uses the following commands.
3462
Each command in the table links to command-specific documentation.

articles/batch/scripts/batch-cli-sample-create-account.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,38 @@
11
---
22
title: Azure CLI Script Example - Create Batch account - Batch service | Microsoft Docs
3-
description: Learn how to create a Batch account in Batch service mode with this Azure CLI script example. This also script shows how to query or update various properties of the account.
3+
description: Learn how to create a Batch account in Batch service mode with this Azure CLI script example. This script also shows how to query or update various properties of the account.
44
ms.topic: sample
5-
ms.date: 09/17/2021
5+
ms.date: 05/24/2022
66
ms.custom: devx-track-azurecli, seo-azure-cli
77
keywords: batch, azure cli samples, azure cli code samples, azure cli script samples
88
---
99

1010
# CLI example: Create a Batch account in Batch service mode
1111

1212
This script creates an Azure Batch account in Batch service mode and shows how to query or update various properties of the account. When you create a Batch account in the default Batch service mode, its compute nodes are assigned internally by the Batch
13-
service. Allocated compute nodes are subject to a separate vCPU (core) quota and the account can be
14-
authenticated either via shared key credentials or an Azure Active Directory token.
13+
service. Allocated compute nodes are subject to a separate vCPU (core) quota and the account can be authenticated either via shared key credentials or an Azure Active Directory token.
14+
15+
[!INCLUDE [quickstarts-free-trial-note](../../../includes/quickstarts-free-trial-note.md)]
1516

1617
[!INCLUDE [azure-cli-prepare-your-environment.md](../../../includes/azure-cli-prepare-your-environment.md)]
1718

18-
- This tutorial requires version 2.0.20 or later of the Azure CLI. If using Azure Cloud Shell, the latest version is already installed.
19+
## Sample script
20+
21+
[!INCLUDE [cli-launch-cloud-shell-sign-in.md](../../../includes/cli-launch-cloud-shell-sign-in.md)]
1922

20-
## Example script
23+
### Run the script
2124

22-
[!code-azurecli-interactive[main](../../../cli_scripts/batch/create-account/create-account.sh "Create Account")]
25+
:::code language="azurecli" source="~/azure_cli_scripts/batch/create-account/create-account.sh" id="FullScript":::
2326

24-
## Clean up deployment
27+
## Clean up resources
2528

26-
Run the following command to remove the
27-
resource group and all resources associated with it.
29+
[!INCLUDE [cli-clean-up-resources.md](../../../includes/cli-clean-up-resources.md)]
2830

29-
```azurecli-interactive
30-
az group delete --name myResourceGroup
31+
```azurecli
32+
az group delete --name $resourceGroup
3133
```
3234

33-
## Script explanation
35+
## Sample reference
3436

3537
This script uses the following commands. Each command in the table links to command-specific documentation.
3638

articles/batch/scripts/batch-cli-sample-create-user-subscription-account.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Azure CLI Script Example - Create Batch account - user subscription | Microsoft Docs
33
description: Learn how to create an Azure Batch account in user subscription mode. This account allocates compute nodes into your subscription.
44
ms.topic: sample
5-
ms.date: 09/17/2021
5+
ms.date: 05/24/2022
66
ms.custom: devx-track-azurecli, seo-azure-cli
77
keywords: batch, azure cli samples, azure cli examples, azure cli code samples
88
---
@@ -11,23 +11,27 @@ keywords: batch, azure cli samples, azure cli examples, azure cli code samples
1111

1212
This script creates an Azure Batch account in user subscription mode. An account that allocates compute nodes into your subscription must be authenticated via an Azure Active Directory token. The compute nodes allocated count toward your subscription's vCPU (core) quota.
1313

14+
[!INCLUDE [quickstarts-free-trial-note](../../../includes/quickstarts-free-trial-note.md)]
15+
1416
[!INCLUDE [azure-cli-prepare-your-environment.md](../../../includes/azure-cli-prepare-your-environment.md)]
1517

16-
- This tutorial requires version 2.0.20 or later of the Azure CLI. If using Azure Cloud Shell, the latest version is already installed.
18+
## Sample script
19+
20+
[!INCLUDE [cli-launch-cloud-shell-sign-in.md](../../../includes/cli-launch-cloud-shell-sign-in.md)]
1721

18-
## Example script
22+
### Run the script
1923

20-
[!code-azurecli-interactive[main](../../../cli_scripts/batch/create-account/create-account-user-subscription.sh "Create Account using user subscription")]
24+
:::code language="azurecli" source="~/azure_cli_scripts/batch/create-account/create-account-user-subscription.sh" id="FullScript":::
2125

22-
## Clean up deployment
26+
## Clean up resources
2327

24-
Run the following command to remove the resource group and all resources associated with it.
28+
[!INCLUDE [cli-clean-up-resources.md](../../../includes/cli-clean-up-resources.md)]
2529

26-
```azurecli-interactive
27-
az group delete --name myResourceGroup
30+
```azurecli
31+
az group delete --name $resourceGroup
2832
```
2933

30-
## Script explanation
34+
## Sample reference
3135

3236
This script uses the following commands. Each command in the table links to command-specific documentation.
3337

articles/batch/scripts/batch-cli-sample-manage-linux-pool.md

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Azure CLI Script Example - Linux Pool in Batch | Microsoft Docs
33
description: Learn the commands available in the Azure CLI to create and manage a pool of Linux compute nodes in Azure Batch.
44
ms.topic: sample
5-
ms.date: 09/17/2021
5+
ms.date: 05/24/2022
66
ms.custom: devx-track-azurecli, seo-azure-cli
77
keywords: linux, azure cli samples, azure cli code samples, azure cli script samples
88
---
@@ -11,24 +11,48 @@ keywords: linux, azure cli samples, azure cli code samples, azure cli script sam
1111

1212
This script demonstrates some of the commands available in the Azure CLI to create and manage a pool of Linux compute nodes in Azure Batch.
1313

14+
[!INCLUDE [quickstarts-free-trial-note](../../../includes/quickstarts-free-trial-note.md)]
15+
1416
[!INCLUDE [azure-cli-prepare-your-environment.md](../../../includes/azure-cli-prepare-your-environment.md)]
1517

16-
- This tutorial requires version 2.0.20 or later of the Azure CLI. If using Azure Cloud Shell, the latest version is already installed.
18+
## Sample script
19+
20+
[!INCLUDE [cli-launch-cloud-shell-sign-in.md](../../../includes/cli-launch-cloud-shell-sign-in.md)]
21+
22+
### To create a Linux pool in Azure Batch
23+
24+
:::code language="azurecli" source="~/azure_cli_scripts/batch/manage-pool/manage-pool-linux.sh" id="FullScript":::
25+
26+
### To reboot a batch node
1727

18-
## Example script
28+
If a particular node in the pool is having issues, it can be rebooted or reimaged. The ID of the node can be retrieved with the list command above. A typical node ID is in the format `tvm-xxxxxxxxxx_1-<timestamp>`.
1929

20-
[!code-azurecli-interactive[main](../../../cli_scripts/batch/manage-pool/manage-pool-linux.sh "Manage Linux Virtual Machine Pool")]
30+
```azurecli
31+
az batch node reboot \
32+
--pool-id mypool-linux \
33+
--node-id tvm-123_1-20170316t000000z
34+
```
35+
36+
### To delete a batch node
37+
38+
One or more compute nodes can be deleted from the pool, and any work already assigned to it can be re-allocated to another node.
39+
40+
```azurecli
41+
az batch node delete \
42+
--pool-id mypool-linux \
43+
--node-list tvm-123_1-20170316t000000z tvm-123_2-20170316t000000z \
44+
--node-deallocation-option requeue
45+
```
2146

22-
## Clean up deployment
47+
## Clean up resources
2348

24-
Run the following command to remove the
25-
resource group and all resources associated with it.
49+
[!INCLUDE [cli-clean-up-resources.md](../../../includes/cli-clean-up-resources.md)]
2650

27-
```azurecli-interactive
28-
az group delete --name myResourceGroup
51+
```azurecli
52+
az group delete --name $resourceGroup
2953
```
3054

31-
## Script explanation
55+
## Sample reference
3256

3357
This script uses the following commands. Each command in the table links to command-specific documentation.
3458

articles/batch/scripts/batch-cli-sample-manage-windows-pool.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,37 @@
22
title: Azure CLI Script Example - Windows Pool in Batch | Microsoft Docs
33
description: Learn some of the commands available in the Azure CLI to create and manage a pool of Windows compute nodes in Azure Batch.
44
ms.topic: sample
5-
ms.date: 09/17/2021
5+
ms.date: 05/24/2022
66
ms.custom: devx-track-azurecli, seo-azure-cli
77
keywords: windows pool, azure cli samples, azure cli code samples, azure cli script samples
88
---
99

1010
# CLI example: Create and manage a Windows pool in Azure Batch
1111

1212
This script demonstrates some of the commands available in the Azure CLI to create and
13-
manage a pool of Windows compute nodes in Azure Batch. A Windows pool can be configured in two ways, with either a Cloud Services configuration
14-
or a Virtual Machine configuration. This example shows how to create a Windows pool with the Cloud Services configuration.
13+
manage a pool of Windows compute nodes in Azure Batch. A Windows pool can be configured in two ways, with either a Cloud Services configuration or a Virtual Machine configuration. This example shows how to create a Windows pool with the Cloud Services configuration.
14+
15+
[!INCLUDE [quickstarts-free-trial-note](../../../includes/quickstarts-free-trial-note.md)]
1516

1617
[!INCLUDE [azure-cli-prepare-your-environment.md](../../../includes/azure-cli-prepare-your-environment.md)]
1718

18-
- This tutorial requires version 2.0.20 or later of the Azure CLI. If using Azure Cloud Shell, the latest version is already installed.
19+
## Sample script
20+
21+
[!INCLUDE [cli-launch-cloud-shell-sign-in.md](../../../includes/cli-launch-cloud-shell-sign-in.md)]
1922

20-
## Example script
23+
### Run the script
2124

22-
[!code-azurecli-interactive[main](../../../cli_scripts/batch/manage-pool/manage-pool-windows.sh "Manage Windows Cloud Services Pool")]
25+
:::code language="azurecli" source="~/azure_cli_scripts/batch/manage-pool/manage-pool-windows.sh" id="FullScript":::
2326

24-
## Clean up deployment
27+
## Clean up resources
2528

26-
Run the following command to remove the
27-
resource group and all resources associated with it.
29+
[!INCLUDE [cli-clean-up-resources.md](../../../includes/cli-clean-up-resources.md)]
2830

29-
```azurecli-interactive
30-
az group delete --name myResourceGroup
31+
```azurecli
32+
az group delete --name $resourceGroup
3133
```
3234

33-
## Script explanation
35+
## Sample reference
3436

3537
This script uses the following commands. Each command in the table links to command-specific documentation.
3638

articles/batch/scripts/batch-cli-sample-run-job.md

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,70 @@
22
title: Azure CLI Script Example - Run a Batch job | Microsoft Docs
33
description: Learn how to create a Batch job and add a series of tasks to the job using the Azure CLI. This article also shows how to monitor a job and its tasks.
44
ms.topic: sample
5-
ms.date: 09/17/2021
5+
ms.date: 05/24/2022
66
ms.custom: devx-track-azurecli, seo-azure-cli
77
keywords: batch, batch job, monitor job, azure cli samples, azure cli code samples, azure cli script samples
88
---
99

1010
# CLI example: Run a job and tasks with Azure Batch
1111

12-
This script creates a Batch job and adds a series of tasks to the job. It also demonstrates
13-
how to monitor a job and its tasks.
12+
This script creates a Batch job and adds a series of tasks to the job. It also demonstrates how to monitor a job and its tasks.
13+
14+
[!INCLUDE [quickstarts-free-trial-note](../../../includes/quickstarts-free-trial-note.md)]
1415

1516
[!INCLUDE [azure-cli-prepare-your-environment.md](../../../includes/azure-cli-prepare-your-environment.md)]
1617

17-
- This tutorial requires version 2.0.20 or later of the Azure CLI. If using Azure Cloud Shell, the latest version is already installed.
18+
## Sample script
19+
20+
[!INCLUDE [cli-launch-cloud-shell-sign-in.md](../../../includes/cli-launch-cloud-shell-sign-in.md)]
21+
22+
### Create a Batch account in Batch service mode
23+
24+
:::code language="azurecli" source="~/azure_cli_scripts/batch/run-job/run-job.sh" id="FullScript":::
25+
26+
### To add many tasks at once
27+
28+
To add many tasks at once, specify the tasks in a JSON file, and pass it to the command. For format, see https://github.com/Azure/azure-docs-cli-python-samples/blob/master/batch/run-job/tasks.json. Provide the absolute path to the JSON file. For an example JSON file, see https://github.com/Azure-Samples/azure-cli-samples/blob/master/batch/run-job/tasks.json.
29+
30+
```azurecli
31+
az batch task create \
32+
--job-id myjob \
33+
--json-file tasks.json
34+
```
35+
36+
### To update the job
37+
38+
Update the job so that it is automatically marked as completed once all the tasks are finished.
39+
40+
```azurecli
41+
az batch job set \
42+
--job-id myjob \
43+
--on-all-tasks-complete terminatejob
44+
```
45+
46+
### To monitor the status of the job
47+
48+
```azurecli
49+
az batch job show --job-id myjob
50+
```
1851

19-
## Example script
52+
### To monitor the status of a task
2053

21-
[!code-azurecli-interactive[main](../../../cli_scripts/batch/run-job/run-job.sh "Run Job")]
54+
```azurecli
55+
az batch task show \
56+
--job-id myjob \
57+
--task-id task1
58+
```
2259

23-
## Clean up deployment
60+
## Clean up resources
2461

25-
Run the following command to remove the
26-
resource group and all resources associated with it.
62+
[!INCLUDE [cli-clean-up-resources.md](../../../includes/cli-clean-up-resources.md)]
2763

28-
```azurecli-interactive
29-
az group delete --name myResourceGroup
64+
```azurecli
65+
az group delete --name $resourceGroup
3066
```
3167

32-
## Script explanation
68+
## Sample reference
3369

3470
This script uses the following commands. Each command in the table links to command-specific documentation.
3571

0 commit comments

Comments
 (0)