Scale out an Azure Batch pool
In this tutorial you will learn how to configure an Azure Batch pool to automatically scale out based on the number of pending tasks. We'll use the Azure CLI and a simple .NET Core application.
Prerequisites
- An Azure subscription
- Azure CLI installed (
az) - .NET 6.0 SDK
Step 1 – Create a Batch account
az batch account create \
--name myBatchAccount \
--resource-group MyResourceGroup \
--location eastus
Step 2 – Create a pool with auto‑scale formula
# Auto‑scale formula: 1 node per 5 pending tasks, minimum 2 nodes
az batch pool create \
--account-name myBatchAccount \
--id myPool \
--vm-size Standard_D2_v2 \
--target-dedicated-nodes 2 \
--auto-scale-enabled true \
--auto-scale-formula "$pendingTasks = $PendingTasks.GetSample(180); \\
$target = max(2, $pendingTasks / 5); \\
$target = min(20, $target); \\
$TargetDedicated = $target;"
Step 3 – Submit tasks
Use the sample .NET console app to submit tasks to the pool. The app is available in the samples section.
Step 4 – Monitor scaling
Run the following command to watch the pool size change as tasks are queued.
az batch pool show \
--account-name myBatchAccount \
--pool-id myPool \
--query "{Allocated:$AllocationState, Nodes:$CurrentDedicatedNodes}" \
--output table
What’s next?
Explore advanced scaling strategies such as custom formulas, low‑priority nodes, and multi‑region pools.