你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
Task - Get
Gets information about the specified Task.
For multi-instance Tasks, information such as affinityId, executionInfo and nodeInfo refer to the primary Task. Use the list subtasks API to retrieve information about subtasks.
GET {batchUrl}/jobs/{jobId}/tasks/{taskId}?api-version=2024-07-01.20.0
GET {batchUrl}/jobs/{jobId}/tasks/{taskId}?$select={$select}&$expand={$expand}&timeout={timeout}&api-version=2024-07-01.20.0
URI Parameters
Name | In | Required | Type | Description |
---|---|---|---|---|
batch
|
path | True |
string |
The base URL for all Azure Batch service requests. |
job
|
path | True |
string |
The ID of the Job that contains the Task. |
task
|
path | True |
string |
The ID of the Task to get information about. |
api-version
|
query | True |
string |
Client API Version. |
$expand
|
query |
string |
An OData $expand clause. |
|
$select
|
query |
string |
An OData $select clause. |
|
timeout
|
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 uuid |
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-rfc1123 |
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. |
|
If-Match |
string |
An ETag value associated with the version of the resource known to the client. The operation will be performed only if the resource's current ETag on the service exactly matches the value specified by the client. |
|
If-None-Match |
string |
An ETag value associated with the version of the resource known to the client. The operation will be performed only if the resource's current ETag on the service does not match the value specified by the client. |
|
If-Modified-Since |
string date-time-rfc1123 |
A timestamp indicating the last modified time of the resource known to the client. The operation will be performed only if the resource on the service has been modified since the specified time. |
|
If-Unmodified-Since |
string date-time-rfc1123 |
A timestamp indicating the last modified time of the resource known to the client. The operation will be performed only if the resource on the service has not been modified since the specified time. |
Responses
Name | Type | Description |
---|---|---|
200 OK |
A response containing the Task. Headers
|
|
Other Status Codes |
The error from the Batch service. |
Security
azure_auth
Microsoft Entra OAuth 2.0 auth code flow
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
Name | Description |
---|---|
user_impersonation | Impersonate your user account |
Authorization
Type:
apiKey
In:
header
Examples
Task get
Sample request
GET account.region.batch.azure.com/jobs/jobId/tasks/taskId?api-version=2024-07-01.20.0
Sample response
{
"id": "testTask",
"url": "https://account.region.batch.azure.com/jobs/jobId/tasks/taskId",
"eTag": "0x8D3D62350711C55",
"creationTime": "2016-09-06T06:59:15.1161429Z",
"lastModified": "2016-09-06T06:59:15.1161429Z",
"state": "active",
"stateTransitionTime": "2016-09-06T06:59:15.1161429Z",
"commandLine": "cmd /c hostname",
"userIdentity": {
"autoUser": {
"scope": "task",
"elevationLevel": "nonadmin"
}
},
"multiInstanceSettings": {
"numberOfInstances": 3,
"coordinationCommandLine": "cmd /c echo coordinating"
},
"constraints": {
"maxWallClockTime": "P10675199DT2H48M5.4775807S",
"retentionTime": "P10675199DT2H48M5.4775807S",
"maxTaskRetryCount": 0
},
"requiredSlots": 2,
"executionInfo": {
"retryCount": 0,
"requeueCount": 0
}
}
Definitions
Name | Description |
---|---|
Access |
The Batch resources to which the token grants access. |
Affinity |
A locality hint that can be used by the Batch service to select a Compute Node on which to start a Task. |
Application |
A reference to an Package to be deployed to Compute Nodes. |
Authentication |
The settings for an authentication token that the Task can use to perform Batch service operations. |
Auto |
The scope for the auto user |
Auto |
Specifies the parameters for the auto user that runs a Task on the Batch service. |
Batch |
An error response received from the Azure Batch service. |
Batch |
An item of additional information included in an Azure Batch error response. |
Cloud |
An Azure Batch Task. |
Compute |
The reference to a user assigned identity associated with the Batch pool which a compute node will use. |
Compute |
Information about the Compute Node on which a Task ran. |
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 |
The location of the container Task working directory. |
Dependency |
An action that the Batch service performs on Tasks that depend on this Task. |
Elevation |
The elevation level of the user. |
Environment |
An environment variable to be set on a Task process. |
Error |
The category of the error. |
Error |
An error message received in an Azure Batch error response. |
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. |
Http |
An HTTP header name-value pair |
Job |
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'. |
Multi |
Settings which specify how to run a multi-instance Task. |
Name |
Represents a name-value pair. |
Output |
A specification for uploading files from an Azure Batch Compute Node to another location after the Batch service has finished executing the Task process. |
Output |
Specifies a file upload destination within an Azure blob storage container. |
Output |
The destination to which a file should be uploaded. |
Output |
The conditions under which a Task output file or set of files should be uploaded. |
Output |
Details about an output file upload operation, including under what conditions to perform the upload. |
Resource |
A single file or multiple files to be downloaded to a Compute Node. |
Task |
Execution constraints to apply to a Task. |
Task |
Contains information about the container which a Task is executing. |
Task |
The container settings for a Task. |
Task |
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. |
Task |
Information about the execution of a Task. |
Task |
The result of Task execution. |
Task |
Information about a Task failure. |
Task |
A range of Task IDs that a Task can depend on. All Tasks with IDs in the range must complete successfully before the dependent Task can be scheduled. |
Task |
The state of the Task. |
Task |
Resource usage statistics for a Task. |
User |
The definition of the user identity under which the Task is run. |
AccessScope
The Batch resources to which the token grants access.
Name | Type | Description |
---|---|---|
job |
string |
Grants access to perform all operations on the Job containing the Task. |
AffinityInformation
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. |
ApplicationPackageReference
A reference to an Package to be deployed to Compute Nodes.
Name | Type | Description |
---|---|---|
applicationId |
string |
The ID of the application to deploy. |
version |
string |
The version of the application to deploy. If omitted, the default version is deployed. |
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. |
AutoUserScope
The scope for the auto user
Name | Type | Description |
---|---|---|
pool |
string |
Specifies that the Task runs as the common auto user Account which is created on every Compute Node in a Pool. |
task |
string |
Specifies that the service should create a new user for the Task. |
AutoUserSpecification
Specifies the parameters for the auto user that runs a Task on the Batch service.
Name | Type | Description |
---|---|---|
elevationLevel |
The elevation level of the auto user. |
|
scope |
The scope for the auto user |
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. |
CloudTask
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. |
|
authenticationTokenSettings |
The settings for an authentication token that the Task can use to perform Batch service operations. |
|
commandLine |
string |
The command line of the Task. |
constraints |
The execution constraints that apply to this Task. |
|
containerSettings |
The settings for the container under which the Task runs. |
|
creationTime |
string |
The creation time of the Task. |
dependsOn |
The Tasks that this Task depends on. |
|
displayName |
string |
A display name for the Task. |
eTag |
string |
The ETag of the Task. |
environmentSettings |
A list of environment variable settings for the Task. |
|
executionInfo |
Information about the execution of the Task. |
|
exitConditions |
Specifies how the Batch service should respond when the Task completes. |
|
id |
string |
A string that uniquely identifies the Task within the Job. |
lastModified |
string |
The last modified time of the Task. |
multiInstanceSettings |
An object that indicates that the Task is a multi-instance Task, and contains information about how to run the multi-instance Task. |
|
nodeInfo |
Information about the Compute Node on which the Task ran. |
|
outputFiles |
A list of files that the Batch service will upload from the Compute Node after running the command line. |
|
previousState |
The previous state of the Task. |
|
previousStateTransitionTime |
string |
The time at which the Task entered its previous state. |
requiredSlots |
integer |
The number of scheduling slots that the Task requires to run. |
resourceFiles |
A list of files that the Batch service will download to the Compute Node before running the command line. |
|
state |
The current state of the Task. |
|
stateTransitionTime |
string |
The time at which the Task entered its current state. |
stats |
Resource usage statistics for the Task. |
|
url |
string |
The URL of the Task. |
userIdentity |
The user identity under which the Task runs. |
ComputeNodeIdentityReference
The reference to a user assigned identity associated with the Batch pool which a compute node will use.
Name | Type | Description |
---|---|---|
resourceId |
string |
The ARM resource id of the user assigned identity. |
ComputeNodeInformation
Information about the Compute Node on which a Task ran.
Name | Type | Description |
---|---|---|
affinityId |
string |
An identifier for the Node on which the Task ran, which can be passed when adding a Task to request that the Task be scheduled on this Compute Node. |
nodeId |
string |
The ID of the Compute Node on which the Task ran. |
nodeUrl |
string |
The URL of the Compute Node on which the Task ran. |
poolId |
string |
The ID of the Pool on which the Task ran. |
taskRootDirectory |
string |
The root directory of the Task on the Compute Node. |
taskRootDirectoryUrl |
string |
The URL to the root directory of the Task on the Compute Node. |
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). |
source |
The path which be mounted to container customer can select. |
ContainerHostDataPath
The paths which will be mounted to container task's container.
Name | Type | Description |
---|---|---|
Applications |
string |
The applications path. |
JobPrep |
string |
The job-prep task path. |
Shared |
string |
The path for multi-instances task to shared their files. |
Startup |
string |
The path for start task. |
Task |
string |
The task path. |
VfsMounts |
string |
The path contains all virtual file systems are mounted on this node. |
ContainerRegistry
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 |
The password to log into the registry server. |
registryServer |
string |
The registry URL. |
username |
string |
The user name to log into the registry server. |
ContainerWorkingDirectory
The location of the container Task working directory.
Name | Type | Description |
---|---|---|
containerImageDefault |
string |
Use the working directory defined in the container Image. Beware that this directory will not contain the Resource Files downloaded by Batch. |
taskWorkingDirectory |
string |
Use the standard Batch service Task working directory, which will contain the Task Resource Files populated by Batch. |
DependencyAction
An action that the Batch service performs on Tasks that depend on this Task.
Name | Type | Description |
---|---|---|
block |
string |
Blocks tasks waiting on this task, preventing them from being scheduled. |
satisfy |
string |
Satisfy tasks waiting on this task; once all dependencies are satisfied, the task will be scheduled to run. |
ElevationLevel
The elevation level of the user.
Name | Type | Description |
---|---|---|
admin |
string |
The user is a user with elevated access and operates with full Administrator permissions. |
nonadmin |
string |
The user is a standard user without elevated access. |
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. |
ErrorCategory
The category of the error.
Name | Type | Description |
---|---|---|
servererror |
string |
The error is due to an internal server issue. |
usererror |
string |
The error is due to a user issue, such as misconfiguration. |
ErrorMessage
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. |
ExitCodeMapping
How the Batch service should respond if a Task exits with a particular exit code.
Name | Type | Description |
---|---|---|
code |
integer |
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 |
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 |
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. |
|
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. |
|
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. |
|
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'. |
HttpHeader
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 |
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'.
Name | Type | Description |
---|---|---|
disable |
string |
Disable the Job. This is equivalent to calling the disable Job API, with a disableTasks value of requeue. |
none |
string |
Take no action. |
terminate |
string |
Terminate the Job. The terminateReason in the Job's executionInfo is set to "TaskFailed". |
MultiInstanceSettings
Settings which specify how to run a multi-instance Task.
Name | Type | Description |
---|---|---|
commonResourceFiles |
A list of files that the Batch service will download before running the coordination command line. |
|
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. |
numberOfInstances |
integer |
The number of Compute Nodes required by the Task. |
NameValuePair
Represents a name-value pair.
Name | Type | Description |
---|---|---|
name |
string |
The name in the name-value pair. |
value |
string |
The value in the name-value pair. |
OutputFile
A specification for uploading files from an Azure Batch Compute Node to another location after the Batch service has finished executing the Task process.
Name | Type | Description |
---|---|---|
destination |
The destination for the output file(s). |
|
filePattern |
string |
A pattern indicating which file(s) to upload. |
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 |
The URL of the container within Azure Blob Storage to which to upload the file(s). |
identityReference |
The reference to the user assigned identity to use to access Azure Blob Storage specified by containerUrl |
|
path |
string |
The destination blob or virtual directory within the Azure Storage container. |
uploadHeaders |
A list of name-value pairs for headers to be used in uploading output files |
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
The conditions under which a Task output file or set of files should be uploaded.
Name | Type | Description |
---|---|---|
taskcompletion |
string |
Upload the file(s) after the Task process exits, no matter what the exit code was. |
taskfailure |
string |
Upload the file(s) only after the Task process exits with a nonzero exit code. |
tasksuccess |
string |
Upload the file(s) only after the Task process exits with an exit code of 0. |
OutputFileUploadOptions
Details about 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. |
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. |
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. |
fileMode |
string |
The file permission mode attribute in octal format. |
filePath |
string |
The location on the Compute Node to which to download the file(s), relative to the Task's working directory. |
httpUrl |
string |
The URL of the file to download. |
identityReference |
The reference to the user assigned identity to use to access Azure Blob Storage specified by storageContainerUrl or httpUrl |
|
storageContainerUrl |
string |
The URL of the blob container within Azure Blob Storage. |
TaskConstraints
Execution constraints to apply to a Task.
Name | Type | Description |
---|---|---|
maxTaskRetryCount |
integer |
The maximum number of times the Task may be retried. The Batch service retries a Task if its exit code is nonzero. |
maxWallClockTime |
string |
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. |
retentionTime |
string |
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. |
TaskContainerExecutionInformation
Contains information about the container which a Task is executing.
Name | Type | Description |
---|---|---|
containerId |
string |
The ID of the container. |
error |
string |
Detailed error information about the container. |
state |
string |
The state of the container. |
TaskContainerSettings
The container settings for a Task.
Name | Type | Description |
---|---|---|
containerHostBatchBindMounts |
The paths you want to mounted to container task. |
|
containerRunOptions |
string |
Additional options to the container create command. |
imageName |
string |
The Image to use to create the container in which the Task will run. |
registry |
The private registry which contains the container Image. |
|
workingDirectory |
The location of the container Task working directory. |
TaskDependencies
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. |
TaskExecutionInformation
Information about the execution of a Task.
Name | Type | Description |
---|---|---|
containerInfo |
Information about the container under which the Task is executing. |
|
endTime |
string |
The time at which the Task completed. |
exitCode |
integer |
The exit code of the program specified on the Task command line. |
failureInfo |
Information describing the Task failure, if any. |
|
lastRequeueTime |
string |
The most recent time at which the Task has been requeued by the Batch service as the result of a user request. |
lastRetryTime |
string |
The most recent time at which a retry of the Task started running. |
requeueCount |
integer |
The number of times the Task has been requeued by the Batch service as the result of a user request. |
result |
The result of the Task execution. |
|
retryCount |
integer |
The number of times the Task has been retried by the Batch service. |
startTime |
string |
The time at which the Task started running. |
TaskExecutionResult
The result of Task execution.
Name | Type | Description |
---|---|---|
failure |
string |
There was an error during processing of the Task. The failure may have occurred before the Task process was launched, while the Task process was executing, or after the Task process exited. |
success |
string |
The Task ran successfully. |
TaskFailureInformation
Information about a Task failure.
Name | Type | Description |
---|---|---|
category |
The category of the Task error. |
|
code |
string |
An identifier for the Task error. Codes are invariant and are intended to be consumed programmatically. |
details |
A list of additional details related to the error. |
|
message |
string |
A message describing the Task error, intended to be suitable for display in a user interface. |
TaskIdRange
A range of Task IDs that a Task can depend on. All Tasks with IDs in the range must complete successfully before the dependent Task can be scheduled.
Name | Type | Description |
---|---|---|
end |
integer |
The last Task ID in the range. |
start |
integer |
The first Task ID in the range. |
TaskState
The state of the Task.
Name | Type | Description |
---|---|---|
active |
string |
The Task is queued and able to run, but is not currently assigned to a Compute Node. A Task enters this state when it is created, when it is enabled after being disabled, or when it is awaiting a retry after a failed run. |
completed |
string |
The Task is no longer eligible to run, usually because the Task has finished successfully, or the Task has finished unsuccessfully and has exhausted its retry limit. A Task is also marked as completed if an error occurred launching the Task, or when the Task has been terminated. |
preparing |
string |
The Task has been assigned to a Compute Node, but is waiting for a required Job Preparation Task to complete on the Compute Node. If the Job Preparation Task succeeds, the Task will move to running. If the Job Preparation Task fails, the Task will return to active and will be eligible to be assigned to a different Compute Node. |
running |
string |
The Task is running on a Compute Node. This includes task-level preparation such as downloading resource files or deploying Packages specified on the Task - it does not necessarily mean that the Task command line has started executing. |
TaskStatistics
Resource usage statistics for a Task.
Name | Type | Description |
---|---|---|
kernelCPUTime |
string |
The total kernel mode CPU time (summed across all cores and all Compute Nodes) consumed by the Task. |
lastUpdateTime |
string |
The time at which the statistics were last updated. All statistics are limited to the range between startTime and lastUpdateTime. |
readIOGiB |
number |
The total gibibytes read from disk by the Task. |
readIOps |
integer |
The total number of disk read operations made by the Task. |
startTime |
string |
The start time of the time range covered by the statistics. |
url |
string |
The URL of the statistics. |
userCPUTime |
string |
The total user mode CPU time (summed across all cores and all Compute Nodes) consumed by the Task. |
waitTime |
string |
The total wait time of the Task. The wait time for a Task is defined as the elapsed time between the creation of the Task and the start of Task execution. (If the Task is retried due to failures, the wait time is the time to the most recent Task execution.) |
wallClockTime |
string |
The total wall clock time of the Task. |
writeIOGiB |
number |
The total gibibytes written to disk by the Task. |
writeIOps |
integer |
The total number of disk write operations made by the Task. |
UserIdentity
The definition of the user identity under which the Task is run.
Name | Type | Description |
---|---|---|
autoUser |
The auto user under which the Task is run. |
|
username |
string |
The name of the user identity under which the Task is run. |