Azure Batch quickstart
This tutorial shows you how to create an Azure Batch account, configure a pool, and run a simple job that runs a hello‑world application on the cloud.
Prerequisites
- Azure subscription – free account works.
- Azure CLI 2.0 or later installed.
- .NET 6.0 SDK (or any supported language SDK).
- Visual Studio 2022 (optional) or VS Code.
Step 1 – Create a Batch account
Run the following Azure CLI commands:
az group create --name MyBatchRG --location eastus
az batch account create --name MyBatchAccount --resource-group MyBatchRG --location eastus
az batch account login --name MyBatchAccount --resource-group MyBatchRG
Step 2 – Create a pool
A pool provides the compute nodes on which tasks run.
az batch pool create --id mypool --vm-size Standard_D2_v2 --target-dedicated-nodes 2 --image "Canonical:UbuntuServer:18.04-LTS:latest"
Step 3 – Submit a job
Use the .NET SDK to submit a job that runs a simple script.
C# sample
using Azure.Identity;
using Azure.Batch;
using Azure.Batch.Auth;
using Azure.Batch.Common;
var batchUri = new Uri("https://mybatchaccount.region.batch.azure.com");
var cred = new DefaultAzureCredential();
var client = new BatchClient(batchUri, cred);
string poolId = "mypool";
string jobId = "hello-world-job";
await client.JobOperations.CreateJobAsync(new CloudJob
{
Id = jobId,
PoolInformation = new PoolInformation { PoolId = poolId }
});
var task = new CloudTask("hello-world-task", "/bin/bash -c \"echo Hello from Azure Batch!\"");
await client.TaskOperations.AddTaskAsync(jobId, task);
Console.WriteLine("Task submitted. Check the portal for output.");
Step 4 – View results
Navigate to the Azure portal, open your Batch account, and inspect the job and task. The task output should contain Hello from Azure Batch!.