Azure Batch

Overview

Azure Batch enables large-scale parallel and high-performance computing (HPC) applications to run efficiently on Azure. It manages the allocation of compute resources, job scheduling, and task execution, allowing developers to focus on the application logic rather than infrastructure.

Key Concepts

Getting Started

Below is a quick example using the Azure Batch .NET SDK to create a pool, submit a job, and add a task.

using Microsoft.Azure.Batch;
using Microsoft.Azure.Batch.Auth;

string batchAccountName = "mybatchaccount";
string batchAccountKey = "YOUR_ACCOUNT_KEY";
string batchAccountUrl = "https://mybatchaccount.region.batch.azure.com";

BatchSharedKeyCredentials cred = new BatchSharedKeyCredentials(batchAccountUrl, batchAccountName, batchAccountKey);
using BatchClient client = BatchClient.Open(cred);

// Create a pool
string poolId = "myPool";
CloudPool pool = client.PoolOperations.CreatePool(
    poolId,
    targetDedicatedComputeNodes: 2,
    virtualMachineSize: "STANDARD_D2_V2",
    cloudServiceConfiguration: new CloudServiceConfiguration(osFamily: "5"));
await pool.CommitAsync();

// Create a job
string jobId = "myJob";
CloudJob job = client.JobOperations.CreateJob();
job.Id = jobId;
job.PoolInformation = new PoolInformation { PoolId = poolId };
await job.CommitAsync();

// Add a task
CloudTask task = new CloudTask("myTask", "cmd /c echo Hello Azure Batch!");
await client.TaskOperations.AddTaskAsync(jobId, task);

Resources