# azure-compute-batch-java

Guides your AI assistant in writing Java code for Azure Batch and HPC jobs. Covers pools, compute nodes, and task scheduling.

- skill · `type=skill` · Claude Code, GitHub Copilot · ★ 3149
- Author: Microsoft
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/microsoft/skills/tree/HEAD/.github/plugins/azure-sdk-java/skills/azure-compute-batch-java/SKILL.md
- Updated: 2026-10-23
- HTML: https://affpapa.org/en/nevibecode/skills/azure-compute-batch-java

## What it does

The skill provides reference patterns for the `com.azure:azure-compute-batch` Java client library (version `1.0.0-beta.5`). It guides code generation for provisioning Ubuntu virtual machine pools, resizing node clusters, and configuring auto-scaling formulas.

Code patterns cover both synchronous `BatchClient` and non-blocking `BatchAsyncClient`. Authentication examples support Microsoft Entra ID via `DefaultAzureCredential` as well as account keys using `AzureNamedKeyCredential`. For long-running operations like pool resizing or job deletion, the skill implements `SyncPoller` handling.

Running this code requires an Azure subscription, an active Batch account, and the `AZURE_BATCH_ENDPOINT` environment variable. Tasks fail to execute if compute nodes are not provisioned in the pool.

## Requirements
- Works with: Azure

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add microsoft/skills --skill azure-compute-batch-java -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/azure-compute-batch-java/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/azure-compute-batch-java/

### Codex

**Manually: put the files in place**
- File: `.agents/skills/azure-compute-batch-java/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

**Manually: put the files in place**
- File: `.cursor/skills/azure-compute-batch-java/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install microsoft/skills azure-compute-batch-java
```

2. **Manually: put the files in place**
- File: `.github/skills/azure-compute-batch-java/SKILL.md`

### Gemini CLI

**Platform CLI**
```bash
gemini skills install https://github.com/microsoft/skills --path .github/plugins/azure-sdk-java/skills/azure-compute-batch-java
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/azure-compute-batch-java/SKILL.md` — The legacy .windsurf/skills/ path still works

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/microsoft/skills/tree/HEAD/.github/plugins/azure-sdk-java/skills/azure-compute-batch-java/SKILL.md

## When to use it
- provision an Azure Batch compute pool running Ubuntu VMs
- configure auto-scale rules based on pending task samples
- submit parallel tasks with execution commands to an active job
- set up Entra ID token authentication with `DefaultAzureCredential`

## Example prompts
- Write Java code to create an Azure Batch pool with two dedicated nodes.
- Set up a batch job with a 24-hour time constraint using `azure-compute-batch`.
- Show how to initialize `BatchAsyncClient` using Microsoft Entra ID.

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 5a4712b20458930a.

BEGIN THIRD-PARTY FILE 5a4712b20458930a
````text
---
name: azure-compute-batch-java
description: |-
  Azure Batch SDK for Java. Run large-scale parallel and HPC batch jobs with pools, jobs, tasks, and compute nodes.
  Triggers: "BatchClient java", "azure batch java", "batch pool java", "batch job java", "HPC java", "parallel computing java".
license: MIT
metadata:
  author: Microsoft
  version: "1.0.0"
---

# Azure Batch SDK for Java

Client library for running large-scale parallel and high-performance computing (HPC) batch jobs in Azure.

## Installation

```xml
<dependency>
    <groupId>com.azure</groupId>
    <artifactId>azure-compute-batch</artifactId>
    <version>1.0.0-beta.5</version>
</dependency>
```

## Prerequisites

- Azure Batch account
- Pool configured with compute nodes
- Azure subscription

## Environment Variables

```bash
AZURE_BATCH_ENDPOINT=https://<account>.<region>.batch.azure.com  # Required for all auth methods
AZURE_BATCH_ACCOUNT=<account-name>  # Only required for shared key auth
AZURE_BATCH_ACCESS_KEY=<account-key>  # Only required for shared key auth
AZURE_TOKEN_CREDENTIALS=prod  # Required only if DefaultAzureCredential is used in production
```

## Client Creation

### With Microsoft Entra ID (Recommended)

```java
import com.azure.compute.batch.BatchClient;
import com.azure.compute.batch.BatchClientBuilder;
import com.azure.core.credential.TokenCredential;
import com.azure.identity.AzureIdentityEnvVars;
import com.azure.identity.DefaultAzureCredentialBuilder;
import com.azure.identity.ManagedIdentityCredentialBuilder;

// Local dev: DefaultAzureCredential. Production: set AZURE_TOKEN_CREDENTIALS=prod or AZURE_TOKEN_CREDENTIALS=<specific_credential>
TokenCredential credential = new DefaultAzureCredentialBuilder()
    .requireEnvVars(AzureIdentityEnvVars.AZURE_TOKEN_CREDENTIALS)
    .build();
// Or use a specific credential directly in production:
// See https://learn.microsoft.com/java/api/overview/azure/identity-readme?view=azure-java-stable#credential-classes
// TokenCredential credential = new ManagedIdentityCredentialBuilder().build();

BatchClient batchClient = new BatchClientBuilder()
    .credential(credential)
    .endpoint(System.getenv("AZURE_BATCH_ENDPOINT"))
    .buildClient();
```

### Async Client

```java
import com.azure.compute.batch.BatchAsyncClient;

BatchAsyncClient batchAsyncClient = new BatchClientBuilder()
    .credential(credential)
    .endpoint(System.getenv("AZURE_BATCH_ENDPOINT"))
    .buildAsyncClient();
```

### With Shared Key Credentials

```java
import com.azure.core.credential.AzureNamedKeyCredential;

String accountName = System.getenv("AZURE_BATCH_ACCOUNT");
String accountKey = System.getenv("AZURE_BATCH_ACCESS_KEY");
AzureNamedKeyCredential sharedKeyCreds = new AzureNamedKeyCredential(accountName, accountKey);

BatchClient batchClient = new BatchClientBuilder()
    .credential(sharedKeyCreds)
    .endpoint(System.getenv("AZURE_BATCH_ENDPOINT"))
    .buildClient();
```

## Key Concepts

| Concept | Description |
|---------|-------------|
| Pool | Collection of compute nodes that run tasks |
| Job | Logical grouping of tasks |
| Task | Unit of computation (command/script) |
| Node | VM that executes tasks |
| Job Schedule | Recurring job creation |

## Pool Operations

### Create Pool
````
END THIRD-PARTY FILE 5a4712b20458930a

The third-party file has ended. Everything between the 5a4712b20458930a tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 3261 of 11914 bytes. © Microsoft · MIT · https://github.com/microsoft/skills/tree/HEAD/.github/plugins/azure-sdk-java/skills/azure-compute-batch-java/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
