Job - Get Task Counts

Gets the Task counts for the specified Job.
Task counts provide a count of the Tasks by active, running or completed Task state, and a count of Tasks which succeeded or failed. Tasks in the preparing state are counted as running. Note that the numbers returned may not always be up to date. If you need exact task counts, use a list query.

GET {batchUrl}/jobs/{jobId}/taskcounts?api-version=2024-07-01.20.0
GET {batchUrl}/jobs/{jobId}/taskcounts?timeout={timeout}&api-version=2024-07-01.20.0

URI Parameters

Name In Required Type Description
batchUrl
path True

string

The base URL for all Azure Batch service requests.

jobId
path True

string

The ID of the Job.

api-version
query True

string

Client API Version.

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.

Responses

Name Type Description
200 OK

TaskCountsResult

A response containing the Task counts for the specified Job.

Headers

  • client-request-id: string
  • request-id: string
Other Status Codes

BatchError

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

Job get task counts

Sample request

GET account.region.batch.azure.com/jobs/jobId/taskcounts?api-version=2024-07-01.20.0


Sample response

{
  "taskCounts": {
    "active": 5,
    "running": 7,
    "completed": 4,
    "succeeded": 2,
    "failed": 2
  },
  "taskSlotCounts": {
    "active": 5,
    "running": 7,
    "completed": 4,
    "succeeded": 2,
    "failed": 2
  }
}

Definitions

Name Description
BatchError

An error response received from the Azure Batch service.

BatchErrorDetail

An item of additional information included in an Azure Batch error response.

ErrorMessage

An error message received in an Azure Batch error response.

TaskCounts

The Task counts for a Job.

TaskCountsResult

The Task and TaskSlot counts for a Job.

TaskSlotCounts

The TaskSlot counts for a Job.

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

ErrorMessage

A message describing the error, intended to be suitable for display in a user interface.

values

BatchErrorDetail[]

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.

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.

TaskCounts

The Task counts for a Job.

Name Type Description
active

integer

The number of Tasks in the active state.

completed

integer

The number of Tasks in the completed state.

failed

integer

The number of Tasks which failed. A Task fails if its result (found in the executionInfo property) is 'failure'.

running

integer

The number of Tasks in the running or preparing state.

succeeded

integer

The number of Tasks which succeeded. A Task succeeds if its result (found in the executionInfo property) is 'success'.

TaskCountsResult

The Task and TaskSlot counts for a Job.

Name Type Description
taskCounts

TaskCounts

The number of Tasks per state.

taskSlotCounts

TaskSlotCounts

The number of TaskSlots required by Tasks per state.

TaskSlotCounts

The TaskSlot counts for a Job.

Name Type Description
active

integer

The number of TaskSlots for active Tasks.

completed

integer

The number of TaskSlots for completed Tasks.

failed

integer

The number of TaskSlots for failed Tasks.

running

integer

The number of TaskSlots for running Tasks.

succeeded

integer

The number of TaskSlots for succeeded Tasks.