[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-e43a44f4-dc81-4cda-8ad0-6522b0dc243e":3,"$fJ4qGN3jIZScPzhAVASwz1Pvw6EUmEQ0VLzVFD43BWMA":43},{"id":4,"title":5,"description":6,"categoryId":7,"moduleId":8,"tags":9,"prompt":10,"icon":11,"source":12,"sourceUrl":13,"authorId":14,"authorName":15,"isPublic":16,"stars":17,"runs":18,"createdAt":19,"updatedAt":19,"module":20,"category":27,"packages":34},"e43a44f4-dc81-4cda-8ad0-6522b0dc243e","azure-compute-batch-java","Azure Batch SDK for Java。使用池、作业、任务和计算节点运行大规模并行和高性能计算批处理作业。","cat_coding_devops","mod_coding","sickn33,coding","---\nname: azure-compute-batch-java\ndescription: Azure Batch SDK for Java. Run large-scale parallel and HPC batch jobs with pools, jobs, tasks, and compute nodes.\nrisk: unknown\nsource: community\ndate_added: '2026-02-27'\n---\n\n# Azure Batch SDK for Java\n\nClient library for running large-scale parallel and high-performance computing (HPC) batch jobs in Azure.\n\n## Installation\n\n```xml\n\u003Cdependency>\n    \u003CgroupId>com.azure\u003C\u002FgroupId>\n    \u003CartifactId>azure-compute-batch\u003C\u002FartifactId>\n    \u003Cversion>1.0.0-beta.5\u003C\u002Fversion>\n\u003C\u002Fdependency>\n```\n\n## Prerequisites\n\n- Azure Batch account\n- Pool configured with compute nodes\n- Azure subscription\n\n## Environment Variables\n\n```bash\nAZURE_BATCH_ENDPOINT=https:\u002F\u002F\u003Caccount>.\u003Cregion>.batch.azure.com\nAZURE_BATCH_ACCOUNT=\u003Caccount-name>\nAZURE_BATCH_ACCESS_KEY=\u003Caccount-key>\n```\n\n## Client Creation\n\n### With Microsoft Entra ID (Recommended)\n\n```java\nimport com.azure.compute.batch.BatchClient;\nimport com.azure.compute.batch.BatchClientBuilder;\nimport com.azure.identity.DefaultAzureCredentialBuilder;\n\nBatchClient batchClient = new BatchClientBuilder()\n    .credential(new DefaultAzureCredentialBuilder().build())\n    .endpoint(System.getenv(\"AZURE_BATCH_ENDPOINT\"))\n    .buildClient();\n```\n\n### Async Client\n\n```java\nimport com.azure.compute.batch.BatchAsyncClient;\n\nBatchAsyncClient batchAsyncClient = new BatchClientBuilder()\n    .credential(new DefaultAzureCredentialBuilder().build())\n    .endpoint(System.getenv(\"AZURE_BATCH_ENDPOINT\"))\n    .buildAsyncClient();\n```\n\n### With Shared Key Credentials\n\n```java\nimport com.azure.core.credential.AzureNamedKeyCredential;\n\nString accountName = System.getenv(\"AZURE_BATCH_ACCOUNT\");\nString accountKey = System.getenv(\"AZURE_BATCH_ACCESS_KEY\");\nAzureNamedKeyCredential sharedKeyCreds = new AzureNamedKeyCredential(accountName, accountKey);\n\nBatchClient batchClient = new BatchClientBuilder()\n    .credential(sharedKeyCreds)\n    .endpoint(System.getenv(\"AZURE_BATCH_ENDPOINT\"))\n    .buildClient();\n```\n\n## Key Concepts\n\n| Concept | Description |\n|---------|-------------|\n| Pool | Collection of compute nodes that run tasks |\n| Job | Logical grouping of tasks |\n| Task | Unit of computation (command\u002Fscript) |\n| Node | VM that executes tasks |\n| Job Schedule | Recurring job creation |\n\n## Pool Operations\n\n### Create Pool\n\n```java\nimport com.azure.compute.batch.models.*;\n\nbatchClient.createPool(new BatchPoolCreateParameters(\"myPoolId\", \"STANDARD_DC2s_V2\")\n    .setVirtualMachineConfiguration(\n        new VirtualMachineConfiguration(\n            new BatchVmImageReference()\n                .setPublisher(\"Canonical\")\n                .setOffer(\"UbuntuServer\")\n                .setSku(\"22_04-lts\")\n                .setVersion(\"latest\"),\n            \"batch.node.ubuntu 22.04\"))\n    .setTargetDedicatedNodes(2)\n    .setTargetLowPriorityNodes(0), null);\n```\n\n### Get Pool\n\n```java\nBatchPool pool = batchClient.getPool(\"myPoolId\");\nSystem.out.println(\"Pool state: \" + pool.getState());\nSystem.out.println(\"Current dedicated nodes: \" + pool.getCurrentDedicatedNodes());\n```\n\n### List Pools\n\n```java\nimport com.azure.core.http.rest.PagedIterable;\n\nPagedIterable\u003CBatchPool> pools = batchClient.listPools();\nfor (BatchPool pool : pools) {\n    System.out.println(\"Pool: \" + pool.getId() + \", State: \" + pool.getState());\n}\n```\n\n### Resize Pool\n\n```java\nimport com.azure.core.util.polling.SyncPoller;\n\nBatchPoolResizeParameters resizeParams = new BatchPoolResizeParameters()\n    .setTargetDedicatedNodes(4)\n    .setTargetLowPriorityNodes(2);\n\nSyncPoller\u003CBatchPool, BatchPool> poller = batchClient.beginResizePool(\"myPoolId\", resizeParams);\npoller.waitForCompletion();\nBatchPool resizedPool = poller.getFinalResult();\n```\n\n### Enable AutoScale\n\n```java\nBatchPoolEnableAutoScaleParameters autoScaleParams = new BatchPoolEnableAutoScaleParameters()\n    .setAutoScaleEvaluationInterval(Duration.ofMinutes(5))\n    .setAutoScaleFormula(\"$TargetDedicatedNodes = min(10, $PendingTasks.GetSample(TimeInterval_Minute * 5));\");\n\nbatchClient.enablePoolAutoScale(\"myPoolId\", autoScaleParams);\n```\n\n### Delete Pool\n\n```java\nSyncPoller\u003CBatchPool, Void> deletePoller = batchClient.beginDeletePool(\"myPoolId\");\ndeletePoller.waitForCompletion();\n```\n\n## Job Operations\n\n### Create Job\n\n```java\nbatchClient.createJob(\n    new BatchJobCreateParameters(\"myJobId\", new BatchPoolInfo().setPoolId(\"myPoolId\"))\n        .setPriority(100)\n        .setConstraints(new BatchJobConstraints()\n            .setMaxWallClockTime(Duration.ofHours(24))\n            .setMaxTaskRetryCount(3)),\n    null);\n```\n\n### Get Job\n\n```java\nBatchJob job = batchClient.getJob(\"myJobId\", null, null);\nSystem.out.println(\"Job state: \" + job.getState());\n```\n\n### List Jobs\n\n```java\nPagedIterable\u003CBatchJob> jobs = batchClient.listJobs(new BatchJobsListOptions());\nfor (BatchJob job : jobs) {\n    System.out.println(\"Job: \" + job.getId() + \", State: \" + job.getState());\n}\n```\n\n### Get Task Counts\n\n```java\nBatchTaskCountsResult counts = batchClient.getJobTaskCounts(\"myJobId\");\nSystem.out.println(\"Active: \" + counts.getTaskCounts().getActive());\nSystem.out.println(\"Running: \" + counts.getTaskCounts().getRunning());\nSystem.out.println(\"Completed: \" + counts.getTaskCounts().getCompleted());\n```\n\n### Terminate Job\n\n```java\nBatchJobTerminateParameters terminateParams = new BatchJobTerminateParameters()\n    .setTerminationReason(\"Manual termination\");\nBatchJobTerminateOptions options = new BatchJobTerminateOptions().setParameters(terminateParams);\n\nSyncPoller\u003CBatchJob, BatchJob> poller = batchClient.beginTerminateJob(\"myJobId\", options, null);\npoller.waitForCompletion();\n```\n\n### Delete Job\n\n```java\nSyncPoller\u003CBatchJob, Void> deletePoller = batchClient.beginDeleteJob(\"myJobId\");\ndeletePoller.waitForCompletion();\n```\n\n## Task Operations\n\n### Create Single Task\n\n```java\nBatchTaskCreateParameters task = new BatchTaskCreateParameters(\"task1\", \"echo 'Hello World'\");\nbatchClient.createTask(\"myJobId\", task);\n```\n\n### Create Task with Exit Conditions\n\n```java\nbatchClient.createTask(\"myJobId\", new BatchTaskCreateParameters(\"task2\", \"cmd \u002Fc exit 3\")\n    .setExitConditions(new ExitConditions()\n        .setExitCodeRanges(Arrays.asList(\n            new ExitCodeRangeMapping(2, 4, \n                new ExitOptions().setJobAction(BatchJobActionKind.TERMINATE)))))\n    .setUserIdentity(new UserIdentity()\n        .setAutoUser(new AutoUserSpecification()\n            .setScope(AutoUserScope.TASK)\n            .setElevationLevel(ElevationLevel.NON_ADMIN))),\n    null);\n```\n\n### Create Task Collection (up to 100)\n\n```java\nList\u003CBatchTaskCreateParameters> taskList = Arrays.asList(\n    new BatchTaskCreateParameters(\"task1\", \"echo Task 1\"),\n    new BatchTaskCreateParameters(\"task2\", \"echo Task 2\"),\n    new BatchTaskCreateParameters(\"task3\", \"echo Task 3\")\n);\nBatchTaskGroup taskGroup = new BatchTaskGroup(taskList);\nBatchCreateTaskCollectionResult result = batchClient.createTaskCollection(\"myJobId\", taskGroup);\n```\n\n### Create Many Tasks (no limit)\n\n```java\nList\u003CBatchTaskCreateParameters> tasks = new ArrayList\u003C>();\nfor (int i = 0; i \u003C 1000; i++) {\n    tasks.add(new BatchTaskCreateParameters(\"task\" + i, \"echo Task \" + i));\n}\nbatchClient.createTasks(\"myJobId\", tasks);\n```\n\n### Get Task\n\n```java\nBatchTask task = batchClient.getTask(\"myJobId\", \"task1\");\nSystem.out.println(\"Task state: \" + task.getState());\nSystem.out.println(\"Exit code: \" + task.getExecutionInfo().getExitCode());\n```\n\n### List Tasks\n\n```java\nPagedIterable\u003CBatchTask> tasks = batchClient.listTasks(\"myJobId\");\nfor (BatchTask task : tasks) {\n    System.out.println(\"Task: \" + task.getId() + \", State: \" + task.getState());\n}\n```\n\n### Get Task Output\n\n```java\nimport com.azure.core.util.BinaryData;\nimport java.nio.charset.StandardCharsets;\n\nBinaryData stdout = batchClient.getTaskFile(\"myJobId\", \"task1\", \"stdout.txt\");\nSystem.out.println(new String(stdout.toBytes(), StandardCharsets.UTF_8));\n```\n\n### Terminate Task\n\n```java\nbatchClient.terminateTask(\"myJobId\", \"task1\", null, null);\n```\n\n## Node Operations\n\n### List Nodes\n\n```java\nPagedIterable\u003CBatchNode> nodes = batchClient.listNodes(\"myPoolId\", new BatchNodesListOptions());\nfor (BatchNode node : nodes) {\n    System.out.println(\"Node: \" + node.getId() + \", State: \" + node.getState());\n}\n```\n\n### Reboot Node\n\n```java\nSyncPoller\u003CBatchNode, BatchNode> rebootPoller = batchClient.beginRebootNode(\"myPoolId\", \"nodeId\");\nrebootPoller.waitForCompletion();\n```\n\n### Get Remote Login Settings\n\n```java\nBatchNodeRemoteLoginSettings settings = batchClient.getNodeRemoteLoginSettings(\"myPoolId\", \"nodeId\");\nSystem.out.println(\"IP: \" + settings.getRemoteLoginIpAddress());\nSystem.out.println(\"Port: \" + settings.getRemoteLoginPort());\n```\n\n## Job Schedule Operations\n\n### Create Job Schedule\n\n```java\nbatchClient.createJobSchedule(new BatchJobScheduleCreateParameters(\"myScheduleId\",\n    new BatchJobScheduleConfiguration()\n        .setRecurrenceInterval(Duration.ofHours(6))\n        .setDoNotRunUntil(OffsetDateTime.now().plusDays(1)),\n    new BatchJobSpecification(new BatchPoolInfo().setPoolId(\"myPoolId\"))\n        .setPriority(50)),\n    null);\n```\n\n### Get Job Schedule\n\n```java\nBatchJobSchedule schedule = batchClient.getJobSchedule(\"myScheduleId\");\nSystem.out.println(\"Schedule state: \" + schedule.getState());\n```\n\n## Error Handling\n\n```java\nimport com.azure.compute.batch.models.BatchErrorException;\nimport com.azure.compute.batch.models.BatchError;\n\ntry {\n    batchClient.getPool(\"nonexistent-pool\");\n} catch (BatchErrorException e) {\n    BatchError error = e.getValue();\n    System.err.println(\"Error code: \" + error.getCode());\n    System.err.println(\"Message: \" + error.getMessage().getValue());\n    \n    if (\"PoolNotFound\".equals(error.getCode())) {\n        System.err.println(\"The specified pool does not exist.\");\n    }\n}\n```\n\n## Best Practices\n\n1. **Use Entra ID** — Preferred over shared key for authentication\n2. **Use management SDK for pools** — `azure-resourcemanager-batch` supports managed identities\n3. **Batch task creation** — Use `createTaskCollection` or `createTasks` for multiple tasks\n4. **Handle LRO properly** — Pool resize, delete operations are long-running\n5. **Monitor task counts** — Use `getJobTaskCounts` to track progress\n6. **Set constraints** — Configure `maxWallClockTime` and `maxTaskRetryCount`\n7. **Use low-priority nodes** — Cost savings for fault-tolerant workloads\n8. **Enable autoscale** — Dynamically adjust pool size based on workload\n\n## Reference Links\n\n| Resource | URL |\n|----------|-----|\n| Maven Package | https:\u002F\u002Fcentral.sonatype.com\u002Fartifact\u002Fcom.azure\u002Fazure-compute-batch |\n| GitHub | https:\u002F\u002Fgithub.com\u002FAzure\u002Fazure-sdk-for-java\u002Ftree\u002Fmain\u002Fsdk\u002Fbatch\u002Fazure-compute-batch |\n| API Documentation | https:\u002F\u002Flearn.microsoft.com\u002Fjava\u002Fapi\u002Fcom.azure.compute.batch |\n| Product Docs | https:\u002F\u002Flearn.microsoft.com\u002Fazure\u002Fbatch\u002F |\n| REST API | https:\u002F\u002Flearn.microsoft.com\u002Frest\u002Fapi\u002Fbatchservice\u002F |\n| Samples | https:\u002F\u002Fgithub.com\u002Fazure\u002Fazure-batch-samples |\n\n## When to Use\nThis skill is applicable to execute the workflow or actions described in the overview.\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.\n","","imported","https:\u002F\u002Fgithub.com\u002Fsickn33\u002Fantigravity-awesome-skills","user_system_seed","SkillOPIC",true,205,655,"2026-05-16 13:06:02",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"编程开发","coding","mdi-code-braces","代码生成、调试、审查，提升开发效率",2,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":32,"skillCount":33,"createdAt":26},"DevOps","devops","mdi-cog-outline","CI\u002FCD、容器化、部署运维",3,162,[35],{"id":36,"skillId":4,"version":37,"fileName":38,"fileSize":39,"filePath":40,"fileHash":41,"manifest":42,"createdAt":19},"b1fdb1b3-3303-4914-9ddf-17e9440b9a16","1.0.0","azure-compute-batch-java.zip",3746,"uploads\u002Fskills\u002Fe43a44f4-dc81-4cda-8ad0-6522b0dc243e\u002Fazure-compute-batch-java.zip","cbbe795d4772e4338b3e7c71e77b37b288f98606488ff01dff5402396f64b31e","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":11374}]",{"code":44,"message":45,"data":46},200,"success",{"items":47,"stats":48,"page":51},[],{"averageRating":49,"totalRatings":49,"ratingCounts":50},0,[49,49,49,49,49],{"limit":52,"offset":49,"hasMore":53,"nextOffset":52,"ratedOnly":16},15,false]