---
title: "Gets information about the specified Task."
method: GET
path: "/jobs/{jobId}/tasks/{taskId}"
tags: ["Tasks"]
---

# Gets information about the specified Task.

`GET /jobs/{jobId}/tasks/{taskId}`

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.

## Path parameters

- `jobId` string, required
- `taskId` string, required

## Query parameters

- `$select` string
- `$expand` string
- `timeout` integer
- `api-version` string, required

## Headers

- `client-request-id` string, uuid
- `return-client-request-id` boolean
- `ocp-date` string, date-time-rfc1123
- `If-Match` string
- `If-None-Match` string
- `If-Modified-Since` string, date-time-rfc1123
- `If-Unmodified-Since` string, date-time-rfc1123

## Response `200`

A response containing the Task.

- CloudTask — Batch will retry Tasks when a recovery operation is triggered on a Node. Examples of recovery operations include (but are not limited to) when an unhealthy Node is rebooted or a Compute Node disappeared due to host failure. Retries due to recovery operations are independent of and are not counted against the maxTaskRetryCount. Even if the maxTaskRetryCount is 0, an internal retry due to a recovery operation may occur. Because of this, all Tasks should be idempotent. This means Tasks need to tolerate being interrupted and restarted without causing any corruption or duplicate data. The best practice for long running Tasks is to use some form of checkpointing.
  - `id` string — The ID can contain any combination of alphanumeric characters including hyphens and underscores, and cannot contain more than 64 characters.
  - `displayName` string — The display name need not be unique and can contain any Unicode characters up to a maximum length of 1024.
  - `url` string
  - `eTag` string — This is an opaque string. You can use it to detect whether the Task has changed between requests. In particular, you can be pass the ETag when updating a Task to specify that your changes should take effect only if nobody else has modified the Task in the meantime.
  - `lastModified` string, date-time
  - `creationTime` string, date-time
  - `exitConditions` ExitConditions
    - `exitCodes` ExitCodeMapping[]
      - `code` integer, required
      - `exitOptions` ExitOptions, required
        - `jobAction` 'none' | 'disable' | 'terminate' — 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).
        - `dependencyAction` 'satisfy' | 'block' — 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.
    - `exitCodeRanges` ExitCodeRangeMapping[]
      - `start` integer, required
      - `end` integer, required
      - `exitOptions` ExitOptions, required
        - `jobAction` 'none' | 'disable' | 'terminate' — 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).
        - `dependencyAction` 'satisfy' | 'block' — 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.
    - `preProcessingError` ExitOptions
      - `jobAction` 'none' | 'disable' | 'terminate' — 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).
      - `dependencyAction` 'satisfy' | 'block' — 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.
    - `fileUploadError` ExitOptions
      - `jobAction` 'none' | 'disable' | 'terminate' — 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).
      - `dependencyAction` 'satisfy' | 'block' — 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.
    - `default` ExitOptions
      - `jobAction` 'none' | 'disable' | 'terminate' — 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).
      - `dependencyAction` 'satisfy' | 'block' — 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.
  - `state` 'active' | 'preparing' | 'running' | 'completed'
  - `stateTransitionTime` string, date-time
  - `previousState` 'active' | 'preparing' | 'running' | 'completed'
  - `previousStateTransitionTime` string, date-time — This property is not set if the Task is in its initial Active state.
  - `commandLine` string — 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://docs.microsoft.com/en-us/azure/batch/batch-compute-node-environment-variables).
  - `containerSettings` TaskContainerSettings
    - `containerRunOptions` string — These additional options are supplied as arguments to the "docker create" command, in addition to those controlled by the Batch Service.
    - `imageName` string, required — 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` ContainerRegistry
      - `registryServer` string — If omitted, the default is "docker.io".
      - `username` string, required
      - `password` string, required
    - `workingDirectory` 'taskWorkingDirectory' | 'containerImageDefault' — The default is 'taskWorkingDirectory'.
  - `resourceFiles` ResourceFile[] — 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.
    - `autoStorageContainerName` string — The autoStorageContainerName, storageContainerUrl and httpUrl properties are mutually exclusive and one of them must be specified.
    - `storageContainerUrl` string — The autoStorageContainerName, storageContainerUrl and httpUrl properties are mutually exclusive and one of them must be specified. This URL must be readable and listable using anonymous access; that is, the Batch service does not present any credentials when downloading blobs from the container. There are two 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, or set the ACL for the container to allow public access.
    - `httpUrl` string — 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 using anonymous access; that is, the Batch service does not present any credentials when downloading the blob. There are two ways to get such a URL for a blob in Azure storage: include a Shared Access Signature (SAS) granting read permissions on the blob, or set the ACL for the blob or its container to allow public access.
    - `blobPrefix` string — 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.
    - `filePath` string — 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 '..').
    - `fileMode` string — 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.
  - `outputFiles` OutputFile[] — For multi-instance Tasks, the files will only be uploaded from the Compute Node on which the primary Task is executed.
    - `filePattern` string, required — 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.
    - `destination` OutputFileDestination, required
      - `container` OutputFileBlobContainerDestination
        - `path` string — 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.
        - `containerUrl` string, required — The URL must include a Shared Access Signature (SAS) granting write permissions to the container.
    - `uploadOptions` OutputFileUploadOptions, required
      - `uploadCondition` 'tasksuccess' | 'taskfailure' | 'taskcompletion', required
  - `environmentSettings` EnvironmentSetting[]
    - `name` string, required
    - `value` string
  - `affinityInfo` AffinityInformation
    - `affinityId` string, required — 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.
  - `constraints` TaskConstraints
    - `maxWallClockTime` string, duration — If this is not specified, there is no time limit on how long the Task may run.
    - `retentionTime` string, duration — 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.
    - `maxTaskRetryCount` integer — 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.
  - `userIdentity` UserIdentity — Specify either the userName or autoUser property, but not both.
    - `username` string — The userName and autoUser properties are mutually exclusive; you must specify one but not both.
    - `autoUser` AutoUserSpecification
      - `scope` 'task' | 'pool' — 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, or if certificates have been specified on the pool which should not be accessible by normal tasks but should be accessible by StartTasks.
      - `elevationLevel` 'nonadmin' | 'admin'
  - `executionInfo` TaskExecutionInformation
    - `startTime` string, date-time — 'Running' corresponds to the running state, so if the Task specifies resource files or Packages, then the start time reflects the time at which the Task started downloading or deploying these. If the Task has been restarted or retried, this is the most recent time at which the Task started running. This property is present only for Tasks that are in the running or completed state.
    - `endTime` string, date-time — This property is set only if the Task is in the Completed state.
    - `exitCode` integer — This property is set only if the Task is in the completed state. In general, the exit code for a process reflects the specific convention implemented by the application developer for that process. If you use the exit code value to make decisions in your code, be sure that you know the exit code convention used by the application process. However, if the Batch service terminates the Task (due to timeout, or user termination via the API) you may see an operating system-defined exit code.
    - `containerInfo` TaskContainerExecutionInformation
      - `containerId` string
      - `state` string — This is the state of the container according to the Docker service. It is equivalent to the status field returned by "docker inspect".
      - `error` string — This is the detailed error string from the Docker service, if available. It is equivalent to the error field returned by "docker inspect".
    - `failureInfo` TaskFailureInformation
      - `category` 'usererror' | 'servererror', required
      - `code` string
      - `message` string
      - `details` NameValuePair[]
        - `name` string
        - `value` string
    - `retryCount` integer, required — Task application failures (non-zero exit code) are retried, pre-processing errors (the Task could not be run) and file upload errors are not retried. The Batch service will retry the Task up to the limit specified by the constraints.
    - `lastRetryTime` string, date-time — This element is present only if the Task was retried (i.e. retryCount is nonzero). If present, this is typically the same as startTime, but may be different if the Task has been restarted for reasons other than retry; for example, if the Compute Node was rebooted during a retry, then the startTime is updated but the lastRetryTime is not.
    - `requeueCount` integer, required — When the user removes Compute Nodes from a Pool (by resizing/shrinking the pool) or when the Job is being disabled, the user can specify that running Tasks on the Compute Nodes be requeued for execution. This count tracks how many times the Task has been requeued for these reasons.
    - `lastRequeueTime` string, date-time — This property is set only if the requeueCount is nonzero.
    - `result` 'success' | 'failure'
  - `nodeInfo` ComputeNodeInformation
    - `affinityId` string
    - `nodeUrl` string
    - `poolId` string
    - `nodeId` string
    - `taskRootDirectory` string
    - `taskRootDirectoryUrl` string
  - `multiInstanceSettings` 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.
    - `numberOfInstances` integer — If omitted, the default is 1.
    - `coordinationCommandLine` string, required — A typical coordination command line launches a background service and verifies that the service is ready to process inter-node messages.
    - `commonResourceFiles` ResourceFile[] — 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.
      - `autoStorageContainerName` string — The autoStorageContainerName, storageContainerUrl and httpUrl properties are mutually exclusive and one of them must be specified.
      - `storageContainerUrl` string — The autoStorageContainerName, storageContainerUrl and httpUrl properties are mutually exclusive and one of them must be specified. This URL must be readable and listable using anonymous access; that is, the Batch service does not present any credentials when downloading blobs from the container. There are two 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, or set the ACL for the container to allow public access.
      - `httpUrl` string — 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 using anonymous access; that is, the Batch service does not present any credentials when downloading the blob. There are two ways to get such a URL for a blob in Azure storage: include a Shared Access Signature (SAS) granting read permissions on the blob, or set the ACL for the blob or its container to allow public access.
      - `blobPrefix` string — 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.
      - `filePath` string — 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 '..').
      - `fileMode` string — 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.
  - `stats` TaskStatistics
    - `url` string, required
    - `startTime` string, date-time, required
    - `lastUpdateTime` string, date-time, required
    - `userCPUTime` string, duration, required
    - `kernelCPUTime` string, duration, required
    - `wallClockTime` string, duration, required — The wall clock time is the elapsed time from when the Task started running on a Compute Node to when it finished (or to the last time the statistics were updated, if the Task had not finished by then). If the Task was retried, this includes the wall clock time of all the Task retries.
    - `readIOps` integer, required
    - `writeIOps` integer, required
    - `readIOGiB` number, double, required
    - `writeIOGiB` number, double, required
    - `waitTime` string, duration, required
  - `dependsOn` TaskDependencies
    - `taskIds` string[] — 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.
    - `taskIdRanges` TaskIdRange[]
      - `start` integer, required
      - `end` integer, required
  - `applicationPackageReferences` ApplicationPackageReference[] — 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.
    - `applicationId` string, required
    - `version` string — 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.
  - `authenticationTokenSettings` AuthenticationTokenSettings
    - `access` string[] — 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.

## Other responses

- `default` — The error from the Batch service.

---

[API](https://skmtc.net/azure/apis/batchservice.md) · [All operations](https://skmtc.net/azure/apis/batchservice/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/azure/batchservice/versions/4c9161203dbe/schema)
