Tasks - Create Task
Creates a Task to the specified Job.
The maximum lifetime of a Task from addition to completion is 180 days. If a
Task has not completed within 180 days of being added it will be terminated by
the Batch service and left in whatever state it was in at that time.
POST {endpoint}/jobs/{jobId}/tasks?api-version=2025-06-01
POST {endpoint}/jobs/{jobId}/tasks?api-version=2025-06-01&timeOut={timeOut}
URI Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
|
endpoint
|
path | True |
string (uri) |
Batch account endpoint (for example: https://batchaccount.eastus2.batch.azure.com). |
|
job
|
path | True |
string |
The ID of the Job to which the Task is to be created. |
|
api-version
|
query | True |
string minLength: 1 |
The API version to use for this operation. |
|
time
|
query |
integer (int32) |
The maximum time that the server can spend processing the request, in seconds. The default is 30 seconds. If the value is larger than 30, the default will be used instead.". |
Request Header
Media Types: "application/json; odata=minimalmetadata"
| Name | Required | Type | Description |
|---|---|---|---|
| client-request-id |
string |
The caller-generated request identity, in the form of a GUID with no decoration such as curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. |
|
| return-client-request-id |
boolean |
Whether the server should return the client-request-id in the response. |
|
| ocp-date |
string (date-time-rfc7231) |
The time the request was issued. Client libraries typically set this to the current system clock time; set it explicitly if you are calling the REST API directly. |
Request Body
Media Types: "application/json; odata=minimalmetadata"
| Name | Required | Type | Description |
|---|---|---|---|
| commandLine | True |
string |
The command line of the Task. For multi-instance Tasks, the command line is executed as the primary Task, after the primary Task and all subtasks have finished executing the coordination command line. The command line does not run under a shell, and therefore cannot take advantage of shell features such as environment variable expansion. If you want to take advantage of such features, you should invoke the shell in the command line, for example using "cmd /c MyCommand" in Windows or "/bin/sh -c MyCommand" in Linux. If the command line refers to file paths, it should use a relative path (relative to the Task working directory), or use the Batch provided environment variable (https://learn.microsoft.com/azure/batch/batch-compute-node-environment-variables). |
| id | True |
string |
A string that uniquely identifies the Task within the Job. The ID can contain any combination of alphanumeric characters including hyphens and underscores, and cannot contain more than 64 characters. The ID is case-preserving and case-insensitive (that is, you may not have two IDs within a Job that differ only by case). |
| affinityInfo |
A locality hint that can be used by the Batch service to select a Compute Node on which to start the new Task. |
||
| applicationPackageReferences |
A list of Packages that the Batch service will deploy to the Compute Node before running the command line. Application packages are downloaded and deployed to a shared directory, not the Task working directory. Therefore, if a referenced package is already on the Node, and is up to date, then it is not re-downloaded; the existing copy on the Compute Node is used. If a referenced Package cannot be installed, for example because the package has been deleted or because download failed, the Task fails. |
||
| authenticationTokenSettings |
The settings for an authentication token that the Task can use to perform Batch service operations. If this property is set, the Batch service provides the Task with an authentication token which can be used to authenticate Batch service operations without requiring an Account access key. The token is provided via the AZ_BATCH_AUTHENTICATION_TOKEN environment variable. The operations that the Task can carry out using the token depend on the settings. For example, a Task can request Job permissions in order to add other Tasks to the Job, or check the status of the Job or of other Tasks under the Job. |
||
| constraints |
The execution constraints that apply to this Task. If you do not specify constraints, the maxTaskRetryCount is the maxTaskRetryCount specified for the Job, the maxWallClockTime is infinite, and the retentionTime is 7 days. |
||
| containerSettings |
The settings for the container under which the Task runs. If the Pool that will run this Task has containerConfiguration set, this must be set as well. If the Pool that will run this Task doesn't have containerConfiguration set, this must not be set. When this is specified, all directories recursively below the AZ_BATCH_NODE_ROOT_DIR (the root of Azure Batch directories on the node) are mapped into the container, all Task environment variables are mapped into the container, and the Task command line is executed in the container. Files produced in the container outside of AZ_BATCH_NODE_ROOT_DIR might not be reflected to the host disk, meaning that Batch file APIs will not be able to access those files. |
||
| dependsOn |
The Tasks that this Task depends on. This Task will not be scheduled until all Tasks that it depends on have completed successfully. If any of those Tasks fail and exhaust their retry counts, this Task will never be scheduled. If the Job does not have usesTaskDependencies set to true, and this element is present, the request fails with error code TaskDependenciesNotSpecifiedOnJob. |
||
| displayName |
string |
A display name for the Task. The display name need not be unique and can contain any Unicode characters up to a maximum length of 1024. |
|
| environmentSettings |
A list of environment variable settings for the Task. |
||
| exitConditions |
How the Batch service should respond when the Task completes. |
||
| multiInstanceSettings |
An object that indicates that the Task is a multi-instance Task, and contains information about how to run the multi-instance Task. |
||
| outputFiles |
A list of files that the Batch service will upload from the Compute Node after running the command line. For multi-instance Tasks, the files will only be uploaded from the Compute Node on which the primary Task is executed. |
||
| requiredSlots |
integer (int32) |
The number of scheduling slots that the Task required to run. The default is 1. A Task can only be scheduled to run on a compute node if the node has enough free scheduling slots available. For multi-instance Tasks, this must be 1. |
|
| resourceFiles |
A list of files that the Batch service will download to the Compute Node before running the command line. For multi-instance Tasks, the resource files will only be downloaded to the Compute Node on which the primary Task is executed. There is a maximum size for the list of resource files. When the max size is exceeded, the request will fail and the response error code will be RequestEntityTooLarge. If this occurs, the collection of ResourceFiles must be reduced in size. This can be achieved using .zip files, Application Packages, or Docker Containers. |
||
| userIdentity |
The user identity under which the Task runs. If omitted, the Task runs as a non-administrative user unique to the Task. |
Responses
| Name | Type | Description |
|---|---|---|
| 201 Created |
The request has succeeded and a new resource has been created as a result. Headers
|
|
| Other Status Codes |
An unexpected error response. |
Security
OAuth2Auth
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/v2.0/authorize
Scopes
| Name | Description |
|---|---|
| https://batch.core.windows.net//.default |
Examples
Creates a basic task
Sample request
POST {endpoint}/jobs/jobId/tasks?api-version=2025-06-01
{
"id": "task1",
"commandLine": "cmd /c echo task1"
}
Sample response
Creates a task with container settings
Sample request
POST {endpoint}/jobs/jobId/tasks?api-version=2025-06-01
{
"id": "taskId",
"commandLine": "bash -c 'echo hello'",
"containerSettings": {
"imageName": "ubuntu",
"containerRunOptions": "--rm"
},
"userIdentity": {
"autoUser": {
"scope": "task",
"elevationLevel": "nonadmin"
}
}
}
Sample response
Creates a task with container settings with data isolation
Sample request
POST {endpoint}/jobs/jobId/tasks?api-version=2025-06-01
{
"id": "taskId",
"commandLine": "bash -c 'echo hello'",
"containerSettings": {
"imageName": "ubuntu",
"containerHostBatchBindMounts": [
{
"source": "Task",
"isReadOnly": true
}
]
},
"userIdentity": {
"autoUser": {
"scope": "task",
"elevationLevel": "nonadmin"
}
}
}
Sample response
Creates a task with container settings with duplicate source
Sample request
POST {endpoint}/jobs/jobId/tasks?api-version=2025-06-01
{
"id": "taskId",
"commandLine": "bash -c 'echo hello'",
"containerSettings": {
"imageName": "ubuntu",
"containerHostBatchBindMounts": [
{
"source": "Task",
"isReadOnly": true
},
{
"source": "Task",
"isReadOnly": true
}
]
},
"userIdentity": {
"autoUser": {
"scope": "task",
"elevationLevel": "nonadmin"
}
}
}
Sample response
Creates a task with exit conditions
Sample request
POST {endpoint}/jobs/jobId/tasks?api-version=2025-06-01
{
"id": "taskId",
"commandLine": "cmd /c exit 3",
"exitConditions": {
"exitCodeRanges": [
{
"start": 2,
"end": 4,
"exitOptions": {
"jobAction": "terminate"
}
}
]
},
"userIdentity": {
"autoUser": {
"scope": "task",
"elevationLevel": "nonadmin"
}
}
}
Sample response
Creates a task with extra slot requirement
Sample request
POST {endpoint}/jobs/jobId/tasks?api-version=2025-06-01
{
"id": "task1",
"requiredSlots": 2,
"commandLine": "cmd /c echo task1"
}
Sample response
Definitions
| Name | Description |
|---|---|
|
Authentication |
The settings for an authentication token that the Task can use to perform Batch service operations. |
|
Auto |
AutoUserScope enums |
|
Auto |
Specifies the options for the auto user that runs an Azure Batch Task. |
|
Batch |
BatchAccessScope enums |
|
Batch |
A locality hint that can be used by the Batch service to select a Compute Node on which to start a Task. |
|
Batch |
A reference to an Package to be deployed to Compute Nodes. |
|
Batch |
An error response received from the Azure Batch service. |
|
Batch |
An item of additional information included in an Azure Batch error response. |
|
Batch |
An error message received in an Azure Batch error response. |
|
Batch |
BatchJobAction enums |
|
Batch |
The reference to a user assigned identity associated with the Batch pool which a compute node will use. |
|
Batch |
Execution constraints to apply to a Task. |
|
Batch |
The container settings for a Task. |
|
Batch |
Parameters for creating an Azure Batch Task. |
|
Batch |
Specifies any dependencies of a Task. Any Task that is explicitly specified or within a dependency range must complete before the dependant Task will be scheduled. |
|
Batch |
The start and end of the range are inclusive. For example, if a range has start 9 and end 12, then it represents Tasks '9', '10', '11' and '12'. |
|
Container |
The entry of path and mount mode you want to mount into task container. |
|
Container |
The paths which will be mounted to container task's container. |
|
Container |
A private container registry. |
|
Container |
ContainerWorkingDirectory enums |
|
Dependency |
DependencyAction enums |
|
Elevation |
ElevationLevel enums |
|
Environment |
An environment variable to be set on a Task process. |
|
Exit |
How the Batch service should respond if a Task exits with a particular exit code. |
|
Exit |
A range of exit codes and how the Batch service should respond to exit codes within that range. |
|
Exit |
Specifies how the Batch service should respond when the Task completes. |
|
Exit |
Specifies how the Batch service responds to a particular exit condition. |
|
Multi |
Multi-instance Tasks are commonly used to support MPI Tasks. In the MPI case, if any of the subtasks fail (for example due to exiting with a non-zero exit code) the entire multi-instance Task fails. The multi-instance Task is then terminated and retried, up to its retry limit. |
|
Output |
On every file uploads, Batch service writes two log files to the compute node, 'fileuploadout.txt' and 'fileuploaderr.txt'. These log files are used to learn more about a specific failure. |
|
Output |
Specifies a file upload destination within an Azure blob storage container. |
|
Output |
The destination to which a file should be uploaded. |
|
Output |
OutputFileUploadCondition enums |
|
Output |
Options for an output file upload operation, including under what conditions to perform the upload. |
|
Output |
An HTTP header name-value pair |
|
Resource |
A single file or multiple files to be downloaded to a Compute Node. |
|
User |
The definition of the user identity under which the Task is run. Specify either the userName or autoUser property, but not both. |
AuthenticationTokenSettings
The settings for an authentication token that the Task can use to perform Batch service operations.
| Name | Type | Description |
|---|---|---|
| access |
The Batch resources to which the token grants access. The authentication token grants access to a limited set of Batch service operations. Currently the only supported value for the access property is 'job', which grants access to all operations related to the Job which contains the Task. |
AutoUserScope
AutoUserScope enums
| Value | Description |
|---|---|
| task |
Specifies that the service should create a new user for the Task. |
| pool |
Specifies that the Task runs as the common auto user Account which is created on every Compute Node in a Pool. |
AutoUserSpecification
Specifies the options for the auto user that runs an Azure Batch Task.
| Name | Type | Description |
|---|---|---|
| elevationLevel |
The elevation level of the auto user. The default value is nonAdmin. |
|
| scope |
The scope for the auto user. The default value is pool. If the pool is running Windows a value of Task should be specified if stricter isolation between tasks is required. For example, if the task mutates the registry in a way which could impact other tasks. |
BatchAccessScope
BatchAccessScope enums
| Value | Description |
|---|---|
| job |
Grants access to perform all operations on the Job containing the Task. |
BatchAffinityInfo
A locality hint that can be used by the Batch service to select a Compute Node on which to start a Task.
| Name | Type | Description |
|---|---|---|
| affinityId |
string |
An opaque string representing the location of a Compute Node or a Task that has run previously. You can pass the affinityId of a Node to indicate that this Task needs to run on that Compute Node. Note that this is just a soft affinity. If the target Compute Node is busy or unavailable at the time the Task is scheduled, then the Task will be scheduled elsewhere. |
BatchApplicationPackageReference
A reference to an Package to be deployed to Compute Nodes.
| Name | Type | Description |
|---|---|---|
| applicationId |
string |
The ID of the application to deploy. When creating a pool, the package's application ID must be fully qualified (/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/applications/{applicationName}). |
| version |
string |
The version of the application to deploy. If omitted, the default version is deployed. If this is omitted on a Pool, and no default version is specified for this application, the request fails with the error code InvalidApplicationPackageReferences and HTTP status code 409. If this is omitted on a Task, and no default version is specified for this application, the Task fails with a pre-processing error. |
BatchError
An error response received from the Azure Batch service.
| Name | Type | Description |
|---|---|---|
| code |
string |
An identifier for the error. Codes are invariant and are intended to be consumed programmatically. |
| message |
A message describing the error, intended to be suitable for display in a user interface. |
|
| values |
A collection of key-value pairs containing additional details about the error. |
BatchErrorDetail
An item of additional information included in an Azure Batch error response.
| Name | Type | Description |
|---|---|---|
| key |
string |
An identifier specifying the meaning of the Value property. |
| value |
string |
The additional information included with the error response. |
BatchErrorMessage
An error message received in an Azure Batch error response.
| Name | Type | Description |
|---|---|---|
| lang |
string |
The language code of the error message. |
| value |
string |
The text of the message. |
BatchJobActionKind
BatchJobAction enums
| Value | Description |
|---|---|
| none |
Take no action. |
| disable |
Disable the Job. This is equivalent to calling the disable Job API, with a disableTasks value of requeue. |
| terminate |
Terminate the Job. The terminationReason in the Job's executionInfo is set to "TaskFailed". |
BatchNodeIdentityReference
The reference to a user assigned identity associated with the Batch pool which a compute node will use.
| Name | Type | Description |
|---|---|---|
| resourceId |
string (arm-id) |
The ARM resource id of the user assigned identity. |
BatchTaskConstraints
Execution constraints to apply to a Task.
| Name | Type | Description |
|---|---|---|
| maxTaskRetryCount |
integer (int32) |
The maximum number of times the Task may be retried. The Batch service retries a Task if its exit code is nonzero. Note that this value specifically controls the number of retries for the Task executable due to a nonzero exit code. The Batch service will try the Task once, and may then retry up to this limit. For example, if the maximum retry count is 3, Batch tries the Task up to 4 times (one initial try and 3 retries). If the maximum retry count is 0, the Batch service does not retry the Task after the first attempt. If the maximum retry count is -1, the Batch service retries the Task without limit, however this is not recommended for a start task or any task. The default value is 0 (no retries). |
| maxWallClockTime |
string (duration) |
The maximum elapsed time that the Task may run, measured from the time the Task starts. If the Task does not complete within the time limit, the Batch service terminates it. If this is not specified, there is no time limit on how long the Task may run. |
| retentionTime |
string (duration) |
The minimum time to retain the Task directory on the Compute Node where it ran, from the time it completes execution. After this time, the Batch service may delete the Task directory and all its contents. The default is 7 days, i.e. the Task directory will be retained for 7 days unless the Compute Node is removed or the Job is deleted. |
BatchTaskContainerSettings
The container settings for a Task.
| Name | Type | Description |
|---|---|---|
| containerHostBatchBindMounts |
The paths you want to mounted to container task. If this array is null or be not present, container task will mount entire temporary disk drive in windows (or AZ_BATCH_NODE_ROOT_DIR in Linux). It won't' mount any data paths into container if this array is set as empty. |
|
| containerRunOptions |
string |
Additional options to the container create command. These additional options are supplied as arguments to the "docker create" command, in addition to those controlled by the Batch Service. |
| imageName |
string |
The Image to use to create the container in which the Task will run. This is the full Image reference, as would be specified to "docker pull". If no tag is provided as part of the Image name, the tag ":latest" is used as a default. |
| registry |
The private registry which contains the container Image. This setting can be omitted if was already provided at Pool creation. |
|
| workingDirectory |
The location of the container Task working directory. The default is 'taskWorkingDirectory'. |
BatchTaskCreateOptions
Parameters for creating an Azure Batch Task.
| Name | Type | Description |
|---|---|---|
| affinityInfo |
A locality hint that can be used by the Batch service to select a Compute Node on which to start the new Task. |
|
| applicationPackageReferences |
A list of Packages that the Batch service will deploy to the Compute Node before running the command line. Application packages are downloaded and deployed to a shared directory, not the Task working directory. Therefore, if a referenced package is already on the Node, and is up to date, then it is not re-downloaded; the existing copy on the Compute Node is used. If a referenced Package cannot be installed, for example because the package has been deleted or because download failed, the Task fails. |
|
| authenticationTokenSettings |
The settings for an authentication token that the Task can use to perform Batch service operations. If this property is set, the Batch service provides the Task with an authentication token which can be used to authenticate Batch service operations without requiring an Account access key. The token is provided via the AZ_BATCH_AUTHENTICATION_TOKEN environment variable. The operations that the Task can carry out using the token depend on the settings. For example, a Task can request Job permissions in order to add other Tasks to the Job, or check the status of the Job or of other Tasks under the Job. |
|
| commandLine |
string |
The command line of the Task. For multi-instance Tasks, the command line is executed as the primary Task, after the primary Task and all subtasks have finished executing the coordination command line. The command line does not run under a shell, and therefore cannot take advantage of shell features such as environment variable expansion. If you want to take advantage of such features, you should invoke the shell in the command line, for example using "cmd /c MyCommand" in Windows or "/bin/sh -c MyCommand" in Linux. If the command line refers to file paths, it should use a relative path (relative to the Task working directory), or use the Batch provided environment variable (https://learn.microsoft.com/azure/batch/batch-compute-node-environment-variables). |
| constraints |
The execution constraints that apply to this Task. If you do not specify constraints, the maxTaskRetryCount is the maxTaskRetryCount specified for the Job, the maxWallClockTime is infinite, and the retentionTime is 7 days. |
|
| containerSettings |
The settings for the container under which the Task runs. If the Pool that will run this Task has containerConfiguration set, this must be set as well. If the Pool that will run this Task doesn't have containerConfiguration set, this must not be set. When this is specified, all directories recursively below the AZ_BATCH_NODE_ROOT_DIR (the root of Azure Batch directories on the node) are mapped into the container, all Task environment variables are mapped into the container, and the Task command line is executed in the container. Files produced in the container outside of AZ_BATCH_NODE_ROOT_DIR might not be reflected to the host disk, meaning that Batch file APIs will not be able to access those files. |
|
| dependsOn |
The Tasks that this Task depends on. This Task will not be scheduled until all Tasks that it depends on have completed successfully. If any of those Tasks fail and exhaust their retry counts, this Task will never be scheduled. If the Job does not have usesTaskDependencies set to true, and this element is present, the request fails with error code TaskDependenciesNotSpecifiedOnJob. |
|
| displayName |
string |
A display name for the Task. The display name need not be unique and can contain any Unicode characters up to a maximum length of 1024. |
| environmentSettings |
A list of environment variable settings for the Task. |
|
| exitConditions |
How the Batch service should respond when the Task completes. |
|
| id |
string |
A string that uniquely identifies the Task within the Job. The ID can contain any combination of alphanumeric characters including hyphens and underscores, and cannot contain more than 64 characters. The ID is case-preserving and case-insensitive (that is, you may not have two IDs within a Job that differ only by case). |
| multiInstanceSettings |
An object that indicates that the Task is a multi-instance Task, and contains information about how to run the multi-instance Task. |
|
| outputFiles |
A list of files that the Batch service will upload from the Compute Node after running the command line. For multi-instance Tasks, the files will only be uploaded from the Compute Node on which the primary Task is executed. |
|
| requiredSlots |
integer (int32) |
The number of scheduling slots that the Task required to run. The default is 1. A Task can only be scheduled to run on a compute node if the node has enough free scheduling slots available. For multi-instance Tasks, this must be 1. |
| resourceFiles |
A list of files that the Batch service will download to the Compute Node before running the command line. For multi-instance Tasks, the resource files will only be downloaded to the Compute Node on which the primary Task is executed. There is a maximum size for the list of resource files. When the max size is exceeded, the request will fail and the response error code will be RequestEntityTooLarge. If this occurs, the collection of ResourceFiles must be reduced in size. This can be achieved using .zip files, Application Packages, or Docker Containers. |
|
| userIdentity |
The user identity under which the Task runs. If omitted, the Task runs as a non-administrative user unique to the Task. |
BatchTaskDependencies
Specifies any dependencies of a Task. Any Task that is explicitly specified or within a dependency range must complete before the dependant Task will be scheduled.
| Name | Type | Description |
|---|---|---|
| taskIdRanges |
The list of Task ID ranges that this Task depends on. All Tasks in all ranges must complete successfully before the dependent Task can be scheduled. |
|
| taskIds |
string[] |
The list of Task IDs that this Task depends on. All Tasks in this list must complete successfully before the dependent Task can be scheduled. The taskIds collection is limited to 64000 characters total (i.e. the combined length of all Task IDs). If the taskIds collection exceeds the maximum length, the Add Task request fails with error code TaskDependencyListTooLong. In this case consider using Task ID ranges instead. |
BatchTaskIdRange
The start and end of the range are inclusive. For example, if a range has start 9 and end 12, then it represents Tasks '9', '10', '11' and '12'.
| Name | Type | Description |
|---|---|---|
| end |
integer (int32) |
The last Task ID in the range. |
| start |
integer (int32) |
The first Task ID in the range. |
ContainerHostBatchBindMountEntry
The entry of path and mount mode you want to mount into task container.
| Name | Type | Description |
|---|---|---|
| isReadOnly |
boolean |
Mount this source path as read-only mode or not. Default value is false (read/write mode). For Linux, if you mount this path as a read/write mode, this does not mean that all users in container have the read/write access for the path, it depends on the access in host VM. If this path is mounted read-only, all users within the container will not be able to modify the path. |
| source |
The path which be mounted to container customer can select. |
ContainerHostDataPath
The paths which will be mounted to container task's container.
| Value | Description |
|---|---|
| Shared |
The path for multi-instances task to shared their files. |
| Startup |
The path for start task. |
| VfsMounts |
The path contains all virtual file systems are mounted on this node. |
| Task |
The task path. |
| JobPrep |
The job-prep task path. |
| Applications |
The applications path. |
ContainerRegistryReference
A private container registry.
| Name | Type | Description |
|---|---|---|
| identityReference |
The reference to the user assigned identity to use to access an Azure Container Registry instead of username and password. |
|
| password |
string (password) |
The password to log into the registry server. |
| registryServer |
string (uri) |
The registry URL. If omitted, the default is "docker.io". |
| username |
string |
The user name to log into the registry server. |
ContainerWorkingDirectory
ContainerWorkingDirectory enums
| Value | Description |
|---|---|
| taskWorkingDirectory |
Use the standard Batch service Task working directory, which will contain the Task Resource Files populated by Batch. |
| containerImageDefault |
Use the working directory defined in the container Image. Beware that this directory will not contain the Resource Files downloaded by Batch. |
DependencyAction
DependencyAction enums
| Value | Description |
|---|---|
| satisfy |
Satisfy tasks waiting on this task; once all dependencies are satisfied, the task will be scheduled to run. |
| block |
Blocks tasks waiting on this task, preventing them from being scheduled. |
ElevationLevel
ElevationLevel enums
| Value | Description |
|---|---|
| nonadmin |
The user is a standard user without elevated access. |
| admin |
The user is a user with elevated access and operates with full Administrator permissions. |
EnvironmentSetting
An environment variable to be set on a Task process.
| Name | Type | Description |
|---|---|---|
| name |
string |
The name of the environment variable. |
| value |
string |
The value of the environment variable. |
ExitCodeMapping
How the Batch service should respond if a Task exits with a particular exit code.
| Name | Type | Description |
|---|---|---|
| code |
integer (int32) |
A process exit code. |
| exitOptions |
How the Batch service should respond if the Task exits with this exit code. |
ExitCodeRangeMapping
A range of exit codes and how the Batch service should respond to exit codes within that range.
| Name | Type | Description |
|---|---|---|
| end |
integer (int32) |
The last exit code in the range. |
| exitOptions |
How the Batch service should respond if the Task exits with an exit code in the range start to end (inclusive). |
|
| start |
integer (int32) |
The first exit code in the range. |
ExitConditions
Specifies how the Batch service should respond when the Task completes.
| Name | Type | Description |
|---|---|---|
| default |
How the Batch service should respond if the Task fails with an exit condition not covered by any of the other properties. This value is used if the Task exits with any nonzero exit code not listed in the exitCodes or exitCodeRanges collection, with a pre-processing error if the preProcessingError property is not present, or with a file upload error if the fileUploadError property is not present. If you want non-default behavior on exit code 0, you must list it explicitly using the exitCodes or exitCodeRanges collection. |
|
| exitCodeRanges |
A list of Task exit code ranges and how the Batch service should respond to them. |
|
| exitCodes |
A list of individual Task exit codes and how the Batch service should respond to them. |
|
| fileUploadError |
How the Batch service should respond if a file upload error occurs. If the Task exited with an exit code that was specified via exitCodes or exitCodeRanges, and then encountered a file upload error, then the action specified by the exit code takes precedence. |
|
| preProcessingError |
How the Batch service should respond if the Task fails to start due to an error. |
ExitOptions
Specifies how the Batch service responds to a particular exit condition.
| Name | Type | Description |
|---|---|---|
| dependencyAction |
An action that the Batch service performs on Tasks that depend on this Task. Possible values are 'satisfy' (allowing dependent tasks to progress) and 'block' (dependent tasks continue to wait). Batch does not yet support cancellation of dependent tasks. |
|
| jobAction |
An action to take on the Job containing the Task, if the Task completes with the given exit condition and the Job's onTaskFailed property is 'performExitOptionsJobAction'. The default is none for exit code 0 and terminate for all other exit conditions. If the Job's onTaskFailed property is noaction, then specifying this property returns an error and the add Task request fails with an invalid property value error; if you are calling the REST API directly, the HTTP status code is 400 (Bad Request). |
MultiInstanceSettings
Multi-instance Tasks are commonly used to support MPI Tasks. In the MPI case, if any of the subtasks fail (for example due to exiting with a non-zero exit code) the entire multi-instance Task fails. The multi-instance Task is then terminated and retried, up to its retry limit.
| Name | Type | Description |
|---|---|---|
| commonResourceFiles |
A list of files that the Batch service will download before running the coordination command line. The difference between common resource files and Task resource files is that common resource files are downloaded for all subtasks including the primary, whereas Task resource files are downloaded only for the primary. Also note that these resource files are not downloaded to the Task working directory, but instead are downloaded to the Task root directory (one directory above the working directory). There is a maximum size for the list of resource files. When the max size is exceeded, the request will fail and the response error code will be RequestEntityTooLarge. If this occurs, the collection of ResourceFiles must be reduced in size. This can be achieved using .zip files, Application Packages, or Docker Containers. |
|
| coordinationCommandLine |
string |
The command line to run on all the Compute Nodes to enable them to coordinate when the primary runs the main Task command. A typical coordination command line launches a background service and verifies that the service is ready to process inter-node messages. |
| numberOfInstances |
integer (int32) |
The number of Compute Nodes required by the Task. If omitted, the default is 1. |
OutputFile
On every file uploads, Batch service writes two log files to the compute node, 'fileuploadout.txt' and 'fileuploaderr.txt'. These log files are used to learn more about a specific failure.
| Name | Type | Description |
|---|---|---|
| destination |
The destination for the output file(s). |
|
| filePattern |
string |
A pattern indicating which file(s) to upload. Both relative and absolute paths are supported. Relative paths are relative to the Task working directory. The following wildcards are supported: * matches 0 or more characters (for example pattern abc* would match abc or abcdef), ** matches any directory, ? matches any single character, [abc] matches one character in the brackets, and [a-c] matches one character in the range. Brackets can include a negation to match any character not specified (for example [!abc] matches any character but a, b, or c). If a file name starts with "." it is ignored by default but may be matched by specifying it explicitly (for example .gif will not match .a.gif, but ..gif will). A simple example: ***.txt matches any file that does not start in '.' and ends with .txt in the Task working directory or any subdirectory. If the filename contains a wildcard character it can be escaped using brackets (for example abc[] would match a file named abc). Note that both \ and / are treated as directory separators on Windows, but only / is on Linux. Environment variables (%var% on Windows or $var on Linux) are expanded prior to the pattern being applied. |
| uploadOptions |
Additional options for the upload operation, including under what conditions to perform the upload. |
OutputFileBlobContainerDestination
Specifies a file upload destination within an Azure blob storage container.
| Name | Type | Description |
|---|---|---|
| containerUrl |
string (uri) |
The URL of the container within Azure Blob Storage to which to upload the file(s). If not using a managed identity, the URL must include a Shared Access Signature (SAS) granting write permissions to the container. |
| identityReference |
The reference to the user assigned identity to use to access Azure Blob Storage specified by containerUrl. The identity must have write access to the Azure Blob Storage container. |
|
| path |
string |
The destination blob or virtual directory within the Azure Storage container. If filePattern refers to a specific file (i.e. contains no wildcards), then path is the name of the blob to which to upload that file. If filePattern contains one or more wildcards (and therefore may match multiple files), then path is the name of the blob virtual directory (which is prepended to each blob name) to which to upload the file(s). If omitted, file(s) are uploaded to the root of the container with a blob name matching their file name. |
| uploadHeaders |
A list of name-value pairs for headers to be used in uploading output files. These headers will be specified when uploading files to Azure Storage. Official document on allowed headers when uploading blobs: https://learn.microsoft.com/rest/api/storageservices/put-blob#request-headers-all-blob-types. |
OutputFileDestination
The destination to which a file should be uploaded.
| Name | Type | Description |
|---|---|---|
| container |
A location in Azure blob storage to which files are uploaded. |
OutputFileUploadCondition
OutputFileUploadCondition enums
| Value | Description |
|---|---|
| tasksuccess |
Upload the file(s) only after the Task process exits with an exit code of 0. |
| taskfailure |
Upload the file(s) only after the Task process exits with a nonzero exit code. |
| taskcompletion |
Upload the file(s) after the Task process exits, no matter what the exit code was. |
OutputFileUploadConfig
Options for an output file upload operation, including under what conditions to perform the upload.
| Name | Type | Description |
|---|---|---|
| uploadCondition |
The conditions under which the Task output file or set of files should be uploaded. The default is taskcompletion. |
OutputFileUploadHeader
An HTTP header name-value pair
| Name | Type | Description |
|---|---|---|
| name |
string |
The case-insensitive name of the header to be used while uploading output files. |
| value |
string |
The value of the header to be used while uploading output files. |
ResourceFile
A single file or multiple files to be downloaded to a Compute Node.
| Name | Type | Description |
|---|---|---|
| autoStorageContainerName |
string |
The storage container name in the auto storage Account. The autoStorageContainerName, storageContainerUrl and httpUrl properties are mutually exclusive and one of them must be specified. |
| blobPrefix |
string |
The blob prefix to use when downloading blobs from an Azure Storage container. Only the blobs whose names begin with the specified prefix will be downloaded. The property is valid only when autoStorageContainerName or storageContainerUrl is used. This prefix can be a partial filename or a subdirectory. If a prefix is not specified, all the files in the container will be downloaded. |
| fileMode |
string |
The file permission mode attribute in octal format. This property applies only to files being downloaded to Linux Compute Nodes. It will be ignored if it is specified for a resourceFile which will be downloaded to a Windows Compute Node. If this property is not specified for a Linux Compute Node, then a default value of 0770 is applied to the file. |
| filePath |
string |
The location on the Compute Node to which to download the file(s), relative to the Task's working directory. If the httpUrl property is specified, the filePath is required and describes the path which the file will be downloaded to, including the filename. Otherwise, if the autoStorageContainerName or storageContainerUrl property is specified, filePath is optional and is the directory to download the files to. In the case where filePath is used as a directory, any directory structure already associated with the input data will be retained in full and appended to the specified filePath directory. The specified relative path cannot break out of the Task's working directory (for example by using '..'). |
| httpUrl |
string (uri) |
The URL of the file to download. The autoStorageContainerName, storageContainerUrl and httpUrl properties are mutually exclusive and one of them must be specified. If the URL points to Azure Blob Storage, it must be readable from compute nodes. There are three ways to get such a URL for a blob in Azure storage: include a Shared Access Signature (SAS) granting read permissions on the blob, use a managed identity with read permission, or set the ACL for the blob or its container to allow public access. |
| identityReference |
The reference to the user assigned identity to use to access Azure Blob Storage specified by storageContainerUrl or httpUrl. |
|
| storageContainerUrl |
string (uri) |
The URL of the blob container within Azure Blob Storage. The autoStorageContainerName, storageContainerUrl and httpUrl properties are mutually exclusive and one of them must be specified. This URL must be readable and listable from compute nodes. There are three ways to get such a URL for a container in Azure storage: include a Shared Access Signature (SAS) granting read and list permissions on the container, use a managed identity with read and list permissions, or set the ACL for the container to allow public access. |
UserIdentity
The definition of the user identity under which the Task is run. Specify either the userName or autoUser property, but not both.
| Name | Type | Description |
|---|---|---|
| autoUser |
The auto user under which the Task is run. The userName and autoUser properties are mutually exclusive; you must specify one but not both. |
|
| username |
string |
The name of the user identity under which the Task is run. The userName and autoUser properties are mutually exclusive; you must specify one but not both. |