Share via


az batch task

Manage Batch tasks.

Commands

Name Description Type Status
az batch task create

Create Batch tasks.

Core GA
az batch task delete

Deletes a Task from the specified Job.

Core GA
az batch task file

Manage Batch task files.

Core GA
az batch task file delete

Deletes the specified Task file from the Compute Node where the Task ran.

Core GA
az batch task file download

Download the content of a Batch task file.

Core GA
az batch task file list

Lists the files in a Task's directory on its Compute Node.

Core GA
az batch task file show

Gets the properties of the specified Task file.

Core GA
az batch task list

Lists all of the Tasks that are associated with the specified Job.

Core GA
az batch task reactivate

Reactivates a Task, allowing it to run again even if its retry count has been exhausted.

Core GA
az batch task reset

Reset the properties of a Batch task.

Core GA
az batch task show

Gets information about the specified Task.

Core GA
az batch task stop

Terminates the specified Task.

Core GA
az batch task subtask

Manage subtask information of a Batch task.

Core GA
az batch task subtask list

Lists all of the subtasks that are associated with the specified multi-instance Task.

Core GA

az batch task create

Create Batch tasks.

az batch task create --job-id
                     [--account-endpoint]
                     [--account-key]
                     [--account-name]
                     [--affinity-id]
                     [--application-package-references]
                     [--command-line]
                     [--environment-settings]
                     [--json-file]
                     [--max-task-retry-count]
                     [--max-wall-clock-time]
                     [--resource-files]
                     [--retention-time]
                     [--task-id]

Examples

Create a task which sleeps for 1 minute.

az batch task create --task-id task1 --job-id job1 --command-line "sleep 60"

Required Parameters

--job-id

The ID of the job containing the task.

Optional Parameters

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--account-endpoint

Batch service endpoint. Alternatively, set by environment variable: AZURE_BATCH_ENDPOINT.

Property Value
Parameter group: Batch Account Arguments
--account-key

The Batch account key. Alternatively, set by environment variable: AZURE_BATCH_ACCESS_KEY.

Property Value
Parameter group: Batch Account Arguments
--account-name

The Batch account name. Only needed Alternatively, set by environment variable: AZURE_BATCH_ACCOUNT.

Property Value
Parameter group: Batch Account Arguments
--affinity-id

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.

--application-package-references

The space-separated list of IDs specifying the application packages to be installed. Space-separated application IDs with optional version in 'id[#version]' format.

--command-line

The command line of the task. 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.

--environment-settings

A list of environment variable settings for the task. Space-separated values in 'key=value' format.

--json-file

The file containing the task(s) to create in JSON(formatted to match REST API request body). When submitting multiple tasks, accepts either an array of tasks or a TaskAddCollectionParamater. If this parameter is specified, all other parameters are ignored.

--max-task-retry-count

The maximum number of times the Task may be retried. The Batch service retries a Task if its exit code is nonzero. 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, however this is not recommended for a start task or any task. The default value is 0 (no retries).

--max-wall-clock-time

If this is not specified, there is no time limit on how long the Task may run.

--resource-files

A list of files that the Batch service will download to the compute node before running the command line. Space-separated resource references in filename=httpurl format, with httpurl being any HTTP url with public access or a SAS url with read access.

--retention-time

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.

--task-id

The ID of the task.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

Property Value
Default value: False
--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

Property Value
Default value: False
--output -o

Output format.

Property Value
Default value: json
Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

Property Value
Default value: False

az batch task delete

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.

az batch task delete --job-id
                     --task-id
                     [--account-endpoint]
                     [--account-key]
                     [--account-name]
                     [--if-match]
                     [--if-modified-since]
                     [--if-none-match]
                     [--if-unmodified-since]
                     [--yes]

Required Parameters

--job-id

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

--task-id

The ID of the Task to delete. Required.

Optional Parameters

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--account-endpoint

Batch service endpoint. Alternatively, set by environment variable: AZURE_BATCH_ENDPOINT.

Property Value
Parameter group: Batch Account Arguments
--account-key

Batch account key. Alternatively, set by environment variable: AZURE_BATCH_ACCESS_KEY.

Property Value
Parameter group: Batch Account Arguments
--account-name

Batch account name. Alternatively, set by environment variable: AZURE_BATCH_ACCOUNT.

Property Value
Parameter group: Batch Account Arguments
--if-match

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.

Property Value
Parameter group: Pre-condition and Query Arguments
--if-modified-since

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.

Property Value
Parameter group: Pre-condition and Query Arguments
--if-none-match

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.

Property Value
Parameter group: Pre-condition and Query Arguments
--if-unmodified-since

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.

Property Value
Parameter group: Pre-condition and Query Arguments
--yes -y

Do not prompt for confirmation.

Property Value
Default value: False
Global Parameters
--debug

Increase logging verbosity to show all debug logs.

Property Value
Default value: False
--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

Property Value
Default value: False
--output -o

Output format.

Property Value
Default value: json
Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

Property Value
Default value: False

az batch task list

Lists 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.

az batch task list --job-id
                   [--account-endpoint]
                   [--account-key]
                   [--account-name]
                   [--expand]
                   [--filter]
                   [--select]

Required Parameters

--job-id

The ID of the Job. Required.

Optional Parameters

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--account-endpoint

Batch service endpoint. Alternatively, set by environment variable: AZURE_BATCH_ENDPOINT.

Property Value
Parameter group: Batch Account Arguments
--account-key

Batch account key. Alternatively, set by environment variable: AZURE_BATCH_ACCESS_KEY.

Property Value
Parameter group: Batch Account Arguments
--account-name

Batch account name. Alternatively, set by environment variable: AZURE_BATCH_ACCOUNT.

Property Value
Parameter group: Batch Account Arguments
--expand

An OData $expand clause.

Property Value
Parameter group: Pre-condition and Query Arguments
--filter

An OData $filter clause. For more information on constructing this filter,see https://learn.microsoft.com/rest/api/batchservice/odata-filters-in-batch.

Property Value
Parameter group: Pre-condition and Query Arguments
--select

An OData $select clause.

Property Value
Parameter group: Pre-condition and Query Arguments
Global Parameters
--debug

Increase logging verbosity to show all debug logs.

Property Value
Default value: False
--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

Property Value
Default value: False
--output -o

Output format.

Property Value
Default value: json
Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

Property Value
Default value: False

az batch task reactivate

Reactivates a Task, allowing it to run again even if its retry count has been exhausted.

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).

az batch task reactivate --job-id
                         --task-id
                         [--account-endpoint]
                         [--account-key]
                         [--account-name]
                         [--if-match]
                         [--if-modified-since]
                         [--if-none-match]
                         [--if-unmodified-since]

Required Parameters

--job-id

The ID of the Job containing the Task. Required.

--task-id

The ID of the Task to reactivate. Required.

Optional Parameters

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--account-endpoint

Batch service endpoint. Alternatively, set by environment variable: AZURE_BATCH_ENDPOINT.

Property Value
Parameter group: Batch Account Arguments
--account-key

Batch account key. Alternatively, set by environment variable: AZURE_BATCH_ACCESS_KEY.

Property Value
Parameter group: Batch Account Arguments
--account-name

Batch account name. Alternatively, set by environment variable: AZURE_BATCH_ACCOUNT.

Property Value
Parameter group: Batch Account Arguments
--if-match

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.

Property Value
Parameter group: Pre-condition and Query Arguments
--if-modified-since

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.

Property Value
Parameter group: Pre-condition and Query Arguments
--if-none-match

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.

Property Value
Parameter group: Pre-condition and Query Arguments
--if-unmodified-since

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.

Property Value
Parameter group: Pre-condition and Query Arguments
Global Parameters
--debug

Increase logging verbosity to show all debug logs.

Property Value
Default value: False
--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

Property Value
Default value: False
--output -o

Output format.

Property Value
Default value: json
Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

Property Value
Default value: False

az batch task reset

Reset the properties of a Batch task.

az batch task reset --job-id
                    --task-id
                    [--account-endpoint]
                    [--account-key]
                    [--account-name]
                    [--if-match]
                    [--if-modified-since]
                    [--if-none-match]
                    [--if-unmodified-since]
                    [--json-file]
                    [--max-task-retry-count]
                    [--max-wall-clock-time]
                    [--retention-time]

Examples

Set max retry count to 3 and reset other properties to their defaults

az batch task reset --task-id task1 --job-id job1 --max-task-retry-count 3

Required Parameters

--job-id

The ID of the Job containing the Task.

--task-id

The ID of the Task to update.

Optional Parameters

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--account-endpoint

Batch service endpoint. Alternatively, set by environment variable: AZURE_BATCH_ENDPOINT.

Property Value
Parameter group: Batch Account Arguments
--account-key

The Batch account key. Alternatively, set by environment variable: AZURE_BATCH_ACCESS_KEY.

Property Value
Parameter group: Batch Account Arguments
--account-name

The Batch account name. Only needed Alternatively, set by environment variable: AZURE_BATCH_ACCOUNT.

Property Value
Parameter group: Batch Account Arguments
--if-match

The operation will be performed only if the resource's current ETag exactly matches the specified value.

Property Value
Parameter group: Pre-condition and Query Arguments
--if-modified-since

The operation will be performed only if the resource has been modified since the specified timestamp.

Property Value
Parameter group: Pre-condition and Query Arguments
--if-none-match

The operation will not be performed only if the resource's current ETag exactly matches the specified value.

Property Value
Parameter group: Pre-condition and Query Arguments
--if-unmodified-since

The operation will not be performed only if the resource has been modified since the specified timestamp.

Property Value
Parameter group: Pre-condition and Query Arguments
--json-file

The file containing pool update properties parameter specification in JSON(formatted to match REST API request body). If this parameter is specified, all 'Pool Update Properties Parameter Arguments' are ignored.

--max-task-retry-count

The maximum number of times the Task may be retried. The Batch service retries a Task if its exit code is nonzero. 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, however this is not recommended for a start task or any task. The default value is 0 (no retries).

Property Value
Parameter group: Constraints Arguments
--max-wall-clock-time

If this is not specified, there is no time limit on how long the Task may run. Expected format is an ISO-8601 duration.

Property Value
Parameter group: Constraints Arguments
--retention-time

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. Expected format is an ISO-8601 duration.

Property Value
Parameter group: Constraints Arguments
Global Parameters
--debug

Increase logging verbosity to show all debug logs.

Property Value
Default value: False
--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

Property Value
Default value: False
--output -o

Output format.

Property Value
Default value: json
Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

Property Value
Default value: False

az batch task show

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.

az batch task show --job-id
                   --task-id
                   [--account-endpoint]
                   [--account-key]
                   [--account-name]
                   [--expand]
                   [--if-match]
                   [--if-modified-since]
                   [--if-none-match]
                   [--if-unmodified-since]
                   [--select]

Required Parameters

--job-id

The ID of the Job that contains the Task. Required.

--task-id

The ID of the Task to get information about. Required.

Optional Parameters

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--account-endpoint

Batch service endpoint. Alternatively, set by environment variable: AZURE_BATCH_ENDPOINT.

Property Value
Parameter group: Batch Account Arguments
--account-key

Batch account key. Alternatively, set by environment variable: AZURE_BATCH_ACCESS_KEY.

Property Value
Parameter group: Batch Account Arguments
--account-name

Batch account name. Alternatively, set by environment variable: AZURE_BATCH_ACCOUNT.

Property Value
Parameter group: Batch Account Arguments
--expand

An OData $expand clause.

Property Value
Parameter group: Pre-condition and Query Arguments
--if-match

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.

Property Value
Parameter group: Pre-condition and Query Arguments
--if-modified-since

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.

Property Value
Parameter group: Pre-condition and Query Arguments
--if-none-match

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.

Property Value
Parameter group: Pre-condition and Query Arguments
--if-unmodified-since

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.

Property Value
Parameter group: Pre-condition and Query Arguments
--select

An OData $select clause.

Property Value
Parameter group: Pre-condition and Query Arguments
Global Parameters
--debug

Increase logging verbosity to show all debug logs.

Property Value
Default value: False
--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

Property Value
Default value: False
--output -o

Output format.

Property Value
Default value: json
Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

Property Value
Default value: False

az batch task stop

Terminates the specified Task.

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.

az batch task stop --job-id
                   --task-id
                   [--account-endpoint]
                   [--account-key]
                   [--account-name]
                   [--if-match]
                   [--if-modified-since]
                   [--if-none-match]
                   [--if-unmodified-since]

Required Parameters

--job-id

The ID of the Job containing the Task. Required.

--task-id

The ID of the Task to terminate. Required.

Optional Parameters

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--account-endpoint

Batch service endpoint. Alternatively, set by environment variable: AZURE_BATCH_ENDPOINT.

Property Value
Parameter group: Batch Account Arguments
--account-key

Batch account key. Alternatively, set by environment variable: AZURE_BATCH_ACCESS_KEY.

Property Value
Parameter group: Batch Account Arguments
--account-name

Batch account name. Alternatively, set by environment variable: AZURE_BATCH_ACCOUNT.

Property Value
Parameter group: Batch Account Arguments
--if-match

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.

Property Value
Parameter group: Pre-condition and Query Arguments
--if-modified-since

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.

Property Value
Parameter group: Pre-condition and Query Arguments
--if-none-match

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.

Property Value
Parameter group: Pre-condition and Query Arguments
--if-unmodified-since

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.

Property Value
Parameter group: Pre-condition and Query Arguments
Global Parameters
--debug

Increase logging verbosity to show all debug logs.

Property Value
Default value: False
--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

Property Value
Default value: False
--output -o

Output format.

Property Value
Default value: json
Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

Property Value
Default value: False