Share via


Task class

Class representing a Task.

Constructors

Task(BatchServiceClientContext)

Create a Task.

Methods

add(string, TaskAddParameter, ServiceCallback<void>)
add(string, TaskAddParameter, TaskAddOptionalParams)

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.

add(string, TaskAddParameter, TaskAddOptionalParams, ServiceCallback<void>)
addCollection(string, TaskAddParameter[], ServiceCallback<TaskAddCollectionResult>)
addCollection(string, TaskAddParameter[], TaskAddCollectionOptionalParams)

Note that each Task must have a unique ID. The Batch service may not return the results for each Task in the same order the Tasks were submitted in this request. If the server times out or the connection is closed during the request, the request may have been partially or fully processed, or not at all. In such cases, the user should re-issue the request. Note that it is up to the user to correctly handle failures when re-issuing a request. For example, you should use the same Task IDs during a retry so that if the prior operation succeeded, the retry will not create extra Tasks unexpectedly. If the response contains any Tasks which failed to add, a client can retry the request. In a retry, it is most efficient to resubmit only Tasks that failed to add, and to omit Tasks that were successfully added on the first attempt. 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.

addCollection(string, TaskAddParameter[], TaskAddCollectionOptionalParams, ServiceCallback<TaskAddCollectionResult>)
deleteMethod(string, string, ServiceCallback<void>)
deleteMethod(string, string, TaskDeleteMethodOptionalParams)

When a Task is deleted, all of the files in its directory on the Compute Node where it ran are also deleted (regardless of the retention time). For multi-instance Tasks, the delete Task operation applies synchronously to the primary task; subtasks and their files are then deleted asynchronously in the background.

deleteMethod(string, string, TaskDeleteMethodOptionalParams, ServiceCallback<void>)
get(string, string, ServiceCallback<CloudTask>)
get(string, string, TaskGetOptionalParams)

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(string, string, TaskGetOptionalParams, ServiceCallback<CloudTask>)
list(string, ServiceCallback<CloudTaskListResult>)
list(string, TaskListOptionalParams)

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.

list(string, TaskListOptionalParams, ServiceCallback<CloudTaskListResult>)
listNext(string, ServiceCallback<CloudTaskListResult>)
listNext(string, TaskListNextOptionalParams)

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.

listNext(string, TaskListNextOptionalParams, ServiceCallback<CloudTaskListResult>)
listSubtasks(string, string, ServiceCallback<CloudTaskListSubtasksResult>)
listSubtasks(string, string, TaskListSubtasksOptionalParams)

If the Task is not a multi-instance Task then this returns an empty collection.

listSubtasks(string, string, TaskListSubtasksOptionalParams, ServiceCallback<CloudTaskListSubtasksResult>)
reactivate(string, string, ServiceCallback<void>)
reactivate(string, string, TaskReactivateOptionalParams)

Reactivation makes a Task eligible to be retried again up to its maximum retry count. The Task's state is changed to active. As the Task is no longer in the completed state, any previous exit code or failure information is no longer available after reactivation. Each time a Task is reactivated, its retry count is reset to 0. Reactivation will fail for Tasks that are not completed or that previously completed successfully (with an exit code of 0). Additionally, it will fail if the Job has completed (or is terminating or deleting).

reactivate(string, string, TaskReactivateOptionalParams, ServiceCallback<void>)
terminate(string, string, ServiceCallback<void>)
terminate(string, string, TaskTerminateOptionalParams)

When the Task has been terminated, it moves to the completed state. For multi-instance Tasks, the terminate Task operation applies synchronously to the primary task; subtasks are then terminated asynchronously in the background.

terminate(string, string, TaskTerminateOptionalParams, ServiceCallback<void>)
update(string, string, ServiceCallback<void>)
update(string, string, TaskUpdateOptionalParams)

Updates the properties of the specified Task.

update(string, string, TaskUpdateOptionalParams, ServiceCallback<void>)

Constructor Details

Task(BatchServiceClientContext)

Create a Task.

new Task(client: BatchServiceClientContext)

Parameters

client
BatchServiceClientContext

Reference to the service client.

Method Details

add(string, TaskAddParameter, ServiceCallback<void>)

function add(jobId: string, task: TaskAddParameter, callback: ServiceCallback<void>)

Parameters

jobId

string

The ID of the Job to which the Task is to be added.

task
TaskAddParameter

The Task to be added.

callback

ServiceCallback<void>

The callback

add(string, TaskAddParameter, TaskAddOptionalParams)

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.

function add(jobId: string, task: TaskAddParameter, options?: TaskAddOptionalParams): Promise<TaskAddResponse>

Parameters

jobId

string

The ID of the Job to which the Task is to be added.

task
TaskAddParameter

The Task to be added.

options
TaskAddOptionalParams

The optional parameters

Returns

Promise<TaskAddResponse>

Promise<Models.TaskAddResponse>

add(string, TaskAddParameter, TaskAddOptionalParams, ServiceCallback<void>)

function add(jobId: string, task: TaskAddParameter, options: TaskAddOptionalParams, callback: ServiceCallback<void>)

Parameters

jobId

string

The ID of the Job to which the Task is to be added.

task
TaskAddParameter

The Task to be added.

options
TaskAddOptionalParams

The optional parameters

callback

ServiceCallback<void>

The callback

addCollection(string, TaskAddParameter[], ServiceCallback<TaskAddCollectionResult>)

function addCollection(jobId: string, value: TaskAddParameter[], callback: ServiceCallback<TaskAddCollectionResult>)

Parameters

jobId

string

The ID of the Job to which the Task collection is to be added.

value

TaskAddParameter[]

The collection of Tasks to add. The maximum count of Tasks is 100. The total serialized size of this collection must be less than 1MB. If it is greater than 1MB (for example if each Task has 100's of resource files or environment variables), the request will fail with code 'RequestBodyTooLarge' and should be retried again with fewer Tasks.

callback

ServiceCallback<TaskAddCollectionResult>

The callback

addCollection(string, TaskAddParameter[], TaskAddCollectionOptionalParams)

Note that each Task must have a unique ID. The Batch service may not return the results for each Task in the same order the Tasks were submitted in this request. If the server times out or the connection is closed during the request, the request may have been partially or fully processed, or not at all. In such cases, the user should re-issue the request. Note that it is up to the user to correctly handle failures when re-issuing a request. For example, you should use the same Task IDs during a retry so that if the prior operation succeeded, the retry will not create extra Tasks unexpectedly. If the response contains any Tasks which failed to add, a client can retry the request. In a retry, it is most efficient to resubmit only Tasks that failed to add, and to omit Tasks that were successfully added on the first attempt. 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.

function addCollection(jobId: string, value: TaskAddParameter[], options?: TaskAddCollectionOptionalParams): Promise<TaskAddCollectionResponse>

Parameters

jobId

string

The ID of the Job to which the Task collection is to be added.

value

TaskAddParameter[]

The collection of Tasks to add. The maximum count of Tasks is 100. The total serialized size of this collection must be less than 1MB. If it is greater than 1MB (for example if each Task has 100's of resource files or environment variables), the request will fail with code 'RequestBodyTooLarge' and should be retried again with fewer Tasks.

options
TaskAddCollectionOptionalParams

The optional parameters

Returns

Promise<Models.TaskAddCollectionResponse>

addCollection(string, TaskAddParameter[], TaskAddCollectionOptionalParams, ServiceCallback<TaskAddCollectionResult>)

function addCollection(jobId: string, value: TaskAddParameter[], options: TaskAddCollectionOptionalParams, callback: ServiceCallback<TaskAddCollectionResult>)

Parameters

jobId

string

The ID of the Job to which the Task collection is to be added.

value

TaskAddParameter[]

The collection of Tasks to add. The maximum count of Tasks is 100. The total serialized size of this collection must be less than 1MB. If it is greater than 1MB (for example if each Task has 100's of resource files or environment variables), the request will fail with code 'RequestBodyTooLarge' and should be retried again with fewer Tasks.

options
TaskAddCollectionOptionalParams

The optional parameters

callback

ServiceCallback<TaskAddCollectionResult>

The callback

deleteMethod(string, string, ServiceCallback<void>)

function deleteMethod(jobId: string, taskId: string, callback: ServiceCallback<void>)

Parameters

jobId

string

The ID of the Job from which to delete the Task.

taskId

string

The ID of the Task to delete.

callback

ServiceCallback<void>

The callback

deleteMethod(string, string, TaskDeleteMethodOptionalParams)

When a Task is deleted, all of the files in its directory on the Compute Node where it ran are also deleted (regardless of the retention time). For multi-instance Tasks, the delete Task operation applies synchronously to the primary task; subtasks and their files are then deleted asynchronously in the background.

function deleteMethod(jobId: string, taskId: string, options?: TaskDeleteMethodOptionalParams): Promise<TaskDeleteResponse>

Parameters

jobId

string

The ID of the Job from which to delete the Task.

taskId

string

The ID of the Task to delete.

options
TaskDeleteMethodOptionalParams

The optional parameters

Returns

Promise<Models.TaskDeleteResponse>

deleteMethod(string, string, TaskDeleteMethodOptionalParams, ServiceCallback<void>)

function deleteMethod(jobId: string, taskId: string, options: TaskDeleteMethodOptionalParams, callback: ServiceCallback<void>)

Parameters

jobId

string

The ID of the Job from which to delete the Task.

taskId

string

The ID of the Task to delete.

options
TaskDeleteMethodOptionalParams

The optional parameters

callback

ServiceCallback<void>

The callback

get(string, string, ServiceCallback<CloudTask>)

function get(jobId: string, taskId: string, callback: ServiceCallback<CloudTask>)

Parameters

jobId

string

The ID of the Job that contains the Task.

taskId

string

The ID of the Task to get information about.

callback

ServiceCallback<CloudTask>

The callback

get(string, string, TaskGetOptionalParams)

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.

function get(jobId: string, taskId: string, options?: TaskGetOptionalParams): Promise<TaskGetResponse>

Parameters

jobId

string

The ID of the Job that contains the Task.

taskId

string

The ID of the Task to get information about.

options
TaskGetOptionalParams

The optional parameters

Returns

Promise<TaskGetResponse>

Promise<Models.TaskGetResponse>

get(string, string, TaskGetOptionalParams, ServiceCallback<CloudTask>)

function get(jobId: string, taskId: string, options: TaskGetOptionalParams, callback: ServiceCallback<CloudTask>)

Parameters

jobId

string

The ID of the Job that contains the Task.

taskId

string

The ID of the Task to get information about.

options
TaskGetOptionalParams

The optional parameters

callback

ServiceCallback<CloudTask>

The callback

list(string, ServiceCallback<CloudTaskListResult>)

function list(jobId: string, callback: ServiceCallback<CloudTaskListResult>)

Parameters

jobId

string

The ID of the Job.

callback

ServiceCallback<CloudTaskListResult>

The callback

list(string, TaskListOptionalParams)

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.

function list(jobId: string, options?: TaskListOptionalParams): Promise<TaskListResponse>

Parameters

jobId

string

The ID of the Job.

options
TaskListOptionalParams

The optional parameters

Returns

Promise<TaskListResponse>

Promise<Models.TaskListResponse>

list(string, TaskListOptionalParams, ServiceCallback<CloudTaskListResult>)

function list(jobId: string, options: TaskListOptionalParams, callback: ServiceCallback<CloudTaskListResult>)

Parameters

jobId

string

The ID of the Job.

options
TaskListOptionalParams

The optional parameters

callback

ServiceCallback<CloudTaskListResult>

The callback

listNext(string, ServiceCallback<CloudTaskListResult>)

function listNext(nextPageLink: string, callback: ServiceCallback<CloudTaskListResult>)

Parameters

nextPageLink

string

The NextLink from the previous successful call to List operation.

callback

ServiceCallback<CloudTaskListResult>

The callback

listNext(string, TaskListNextOptionalParams)

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.

function listNext(nextPageLink: string, options?: TaskListNextOptionalParams): Promise<TaskListResponse>

Parameters

nextPageLink

string

The NextLink from the previous successful call to List operation.

options
TaskListNextOptionalParams

The optional parameters

Returns

Promise<TaskListResponse>

Promise<Models.TaskListResponse>

listNext(string, TaskListNextOptionalParams, ServiceCallback<CloudTaskListResult>)

function listNext(nextPageLink: string, options: TaskListNextOptionalParams, callback: ServiceCallback<CloudTaskListResult>)

Parameters

nextPageLink

string

The NextLink from the previous successful call to List operation.

options
TaskListNextOptionalParams

The optional parameters

callback

ServiceCallback<CloudTaskListResult>

The callback

listSubtasks(string, string, ServiceCallback<CloudTaskListSubtasksResult>)

function listSubtasks(jobId: string, taskId: string, callback: ServiceCallback<CloudTaskListSubtasksResult>)

Parameters

jobId

string

The ID of the Job.

taskId

string

The ID of the Task.

listSubtasks(string, string, TaskListSubtasksOptionalParams)

If the Task is not a multi-instance Task then this returns an empty collection.

function listSubtasks(jobId: string, taskId: string, options?: TaskListSubtasksOptionalParams): Promise<TaskListSubtasksResponse>

Parameters

jobId

string

The ID of the Job.

taskId

string

The ID of the Task.

options
TaskListSubtasksOptionalParams

The optional parameters

Returns

Promise<Models.TaskListSubtasksResponse>

listSubtasks(string, string, TaskListSubtasksOptionalParams, ServiceCallback<CloudTaskListSubtasksResult>)

function listSubtasks(jobId: string, taskId: string, options: TaskListSubtasksOptionalParams, callback: ServiceCallback<CloudTaskListSubtasksResult>)

Parameters

jobId

string

The ID of the Job.

taskId

string

The ID of the Task.

options
TaskListSubtasksOptionalParams

The optional parameters

reactivate(string, string, ServiceCallback<void>)

function reactivate(jobId: string, taskId: string, callback: ServiceCallback<void>)

Parameters

jobId

string

The ID of the Job containing the Task.

taskId

string

The ID of the Task to reactivate.

callback

ServiceCallback<void>

The callback

reactivate(string, string, TaskReactivateOptionalParams)

Reactivation makes a Task eligible to be retried again up to its maximum retry count. The Task's state is changed to active. As the Task is no longer in the completed state, any previous exit code or failure information is no longer available after reactivation. Each time a Task is reactivated, its retry count is reset to 0. Reactivation will fail for Tasks that are not completed or that previously completed successfully (with an exit code of 0). Additionally, it will fail if the Job has completed (or is terminating or deleting).

function reactivate(jobId: string, taskId: string, options?: TaskReactivateOptionalParams): Promise<TaskReactivateResponse>

Parameters

jobId

string

The ID of the Job containing the Task.

taskId

string

The ID of the Task to reactivate.

options
TaskReactivateOptionalParams

The optional parameters

Returns

Promise<Models.TaskReactivateResponse>

reactivate(string, string, TaskReactivateOptionalParams, ServiceCallback<void>)

function reactivate(jobId: string, taskId: string, options: TaskReactivateOptionalParams, callback: ServiceCallback<void>)

Parameters

jobId

string

The ID of the Job containing the Task.

taskId

string

The ID of the Task to reactivate.

options
TaskReactivateOptionalParams

The optional parameters

callback

ServiceCallback<void>

The callback

terminate(string, string, ServiceCallback<void>)

function terminate(jobId: string, taskId: string, callback: ServiceCallback<void>)

Parameters

jobId

string

The ID of the Job containing the Task.

taskId

string

The ID of the Task to terminate.

callback

ServiceCallback<void>

The callback

terminate(string, string, TaskTerminateOptionalParams)

When the Task has been terminated, it moves to the completed state. For multi-instance Tasks, the terminate Task operation applies synchronously to the primary task; subtasks are then terminated asynchronously in the background.

function terminate(jobId: string, taskId: string, options?: TaskTerminateOptionalParams): Promise<TaskTerminateResponse>

Parameters

jobId

string

The ID of the Job containing the Task.

taskId

string

The ID of the Task to terminate.

options
TaskTerminateOptionalParams

The optional parameters

Returns

Promise<Models.TaskTerminateResponse>

terminate(string, string, TaskTerminateOptionalParams, ServiceCallback<void>)

function terminate(jobId: string, taskId: string, options: TaskTerminateOptionalParams, callback: ServiceCallback<void>)

Parameters

jobId

string

The ID of the Job containing the Task.

taskId

string

The ID of the Task to terminate.

options
TaskTerminateOptionalParams

The optional parameters

callback

ServiceCallback<void>

The callback

update(string, string, ServiceCallback<void>)

function update(jobId: string, taskId: string, callback: ServiceCallback<void>)

Parameters

jobId

string

The ID of the Job containing the Task.

taskId

string

The ID of the Task to update.

callback

ServiceCallback<void>

The callback

update(string, string, TaskUpdateOptionalParams)

Updates the properties of the specified Task.

function update(jobId: string, taskId: string, options?: TaskUpdateOptionalParams): Promise<TaskUpdateResponse>

Parameters

jobId

string

The ID of the Job containing the Task.

taskId

string

The ID of the Task to update.

options
TaskUpdateOptionalParams

The optional parameters

Returns

Promise<Models.TaskUpdateResponse>

update(string, string, TaskUpdateOptionalParams, ServiceCallback<void>)

function update(jobId: string, taskId: string, options: TaskUpdateOptionalParams, callback: ServiceCallback<void>)

Parameters

jobId

string

The ID of the Job containing the Task.

taskId

string

The ID of the Task to update.

options
TaskUpdateOptionalParams

The optional parameters

callback

ServiceCallback<void>

The callback