Skip to main content

tasks

Creates, updates, deletes, gets or lists a tasks resource.

Overview

Nametasks
TypeResource
Idazure.batch_dataplane.tasks

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstringA 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. Required.
affinityInfoobjectA locality hint that can be used by the Batch service to select a Compute Node on which to start the new Task.
applicationPackageReferencesarrayA 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.
commandLinestringThe 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 _). Required.
constraintsobjectThe execution constraints that apply to this Task.
containerSettingsobjectThe 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.
creationTimestring (date-time)The creation time of the Task. Required.
dependsOnobjectThe 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.
displayNamestringA 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.
eTagstringThe ETag of the Task. 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. Required.
environmentSettingsarrayA list of environment variable settings for the Task.
executionInfoobjectInformation about the execution of the Task.
exitConditionsobjectHow the Batch service should respond when the Task completes.
lastModifiedstring (date-time)The last modified time of the Task. Required.
multiInstanceSettingsobjectAn object that indicates that the Task is a multi-instance Task, and contains information about how to run the multi-instance Task.
nodeInfoobjectInformation about the Compute Node on which the Task ran.
outputFilesarrayA 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.
previousStatestringThe previous state of the Task. This property is not set if the Task is in its initial Active state. Known values are: "active", "preparing", "running", and "completed". (active, preparing, running, completed)
previousStateTransitionTimestring (date-time)The time at which the Task entered its previous state. This property is not set if the Task is in its initial Active state.
requiredSlotsintegerThe number of scheduling slots that the Task requires 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.
resourceFilesarrayA 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.
statestringThe current state of the Task. Required. Known values are: "active", "preparing", "running", and "completed". (active, preparing, running, completed)
stateTransitionTimestring (date-time)The time at which the Task entered its current state. Required.
statsobjectResource usage statistics for the Task.
urlstringThe URL of the Task. Required.
userIdentityobjectThe user identity under which the Task runs. If omitted, the Task runs as a non-administrative user unique to the Task.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_taskselectjob_id, task_id, endpointtimeOut, ocp-date, If-Modified-Since, If-Unmodified-Since, $select, $expandGets 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.
list_tasksselectjob_id, endpointtimeOut, ocp-date, maxresults, $filter, $select, $expandLists all of the Tasks that are associated with the specified Job. 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.
create_taskinsertjob_id, endpoint, id, commandLinetimeOut, ocp-dateCreates 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.
delete_taskdeletejob_id, task_id, endpointtimeOut, ocp-date, If-Modified-Since, If-Unmodified-SinceDeletes a Task from the specified Job. 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.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
endpointstringThe service endpoint host (no scheme), e.g. myaccount.table.cosmos.azure.com:443 - value of the client endpoint parameter. (default: )
job_idstringThe ID of the Job from which to delete the Task. Required.
task_idstringThe ID of the Task to delete. Required.
$expandarrayAn OData $expand clause. Default value is None.
$filterstringAn OData $filter clause. For more information on constructing this filter, see https://learn.microsoft.com/rest/api/batchservice/odata-filters-in-batch#list-tasks _. Default value is None.
$selectarrayAn OData $select clause. Default value is None.
If-Modified-SincestringA 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. Default value is None.
If-Unmodified-SincestringA 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. Default value is None.
maxresultsintegerThe maximum number of items to return in the response. A maximum of 1000 applications can be returned. Default value is None.
ocp-datestringThe 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. Default value is None.
timeOutintegerThe 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.". Default value is None.

SELECT examples

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.

SELECT
id,
affinityInfo,
applicationPackageReferences,
commandLine,
constraints,
containerSettings,
creationTime,
dependsOn,
displayName,
eTag,
environmentSettings,
executionInfo,
exitConditions,
lastModified,
multiInstanceSettings,
nodeInfo,
outputFiles,
previousState,
previousStateTransitionTime,
requiredSlots,
resourceFiles,
state,
stateTransitionTime,
stats,
url,
userIdentity
FROM azure.batch_dataplane.tasks
WHERE job_id = '{{ job_id }}' -- required
AND task_id = '{{ task_id }}' -- required
AND endpoint = '{{ endpoint }}' -- required
AND timeOut = '{{ timeOut }}'
AND ocp-date = '{{ ocp-date }}'
AND If-Modified-Since = '{{ If-Modified-Since }}'
AND If-Unmodified-Since = '{{ If-Unmodified-Since }}'
AND $select = '{{ $select }}'
AND $expand = '{{ $expand }}'
;

INSERT examples

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.

INSERT INTO azure.batch_dataplane.tasks (
id,
displayName,
exitConditions,
commandLine,
containerSettings,
resourceFiles,
outputFiles,
environmentSettings,
affinityInfo,
constraints,
requiredSlots,
userIdentity,
multiInstanceSettings,
dependsOn,
applicationPackageReferences,
job_id,
endpoint,
timeOut,
ocp-date
)
SELECT
'{{ id }}' /* required */,
'{{ displayName }}',
'{{ exitConditions }}',
'{{ commandLine }}' /* required */,
'{{ containerSettings }}',
'{{ resourceFiles }}',
'{{ outputFiles }}',
'{{ environmentSettings }}',
'{{ affinityInfo }}',
'{{ constraints }}',
{{ requiredSlots }},
'{{ userIdentity }}',
'{{ multiInstanceSettings }}',
'{{ dependsOn }}',
'{{ applicationPackageReferences }}',
'{{ job_id }}',
'{{ endpoint }}',
'{{ timeOut }}',
'{{ ocp-date }}'
;

DELETE examples

Deletes a Task from the specified Job. 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.

DELETE FROM azure.batch_dataplane.tasks
WHERE job_id = '{{ job_id }}' --required
AND task_id = '{{ task_id }}' --required
AND endpoint = '{{ endpoint }}' --required
AND timeOut = '{{ timeOut }}'
AND ocp-date = '{{ ocp-date }}'
AND If-Modified-Since = '{{ If-Modified-Since }}'
AND If-Unmodified-Since = '{{ If-Unmodified-Since }}'
;