Share via


BatchClient.GetTask Method

Definition

Overloads

GetTask(String, String, Nullable<Int32>, Nullable<DateTimeOffset>, IEnumerable<String>, IEnumerable<String>, RequestConditions, RequestContext)

[Protocol Method] Gets information about the specified Task.

GetTask(String, String, Nullable<Int32>, Nullable<DateTimeOffset>, IEnumerable<String>, IEnumerable<String>, RequestConditions, CancellationToken)

Gets information about the specified Task.

GetTask(String, String, Nullable<Int32>, Nullable<DateTimeOffset>, IEnumerable<String>, IEnumerable<String>, RequestConditions, RequestContext)

[Protocol Method] Gets information about the specified Task.

public virtual Azure.Response GetTask (string jobId, string taskId, int? timeOutInSeconds, DateTimeOffset? ocpdate, System.Collections.Generic.IEnumerable<string> select, System.Collections.Generic.IEnumerable<string> expand, Azure.RequestConditions requestConditions, Azure.RequestContext context);
abstract member GetTask : string * string * Nullable<int> * Nullable<DateTimeOffset> * seq<string> * seq<string> * Azure.RequestConditions * Azure.RequestContext -> Azure.Response
override this.GetTask : string * string * Nullable<int> * Nullable<DateTimeOffset> * seq<string> * seq<string> * Azure.RequestConditions * Azure.RequestContext -> Azure.Response
Public Overridable Function GetTask (jobId As String, taskId As String, timeOutInSeconds As Nullable(Of Integer), ocpdate As Nullable(Of DateTimeOffset), select As IEnumerable(Of String), expand As IEnumerable(Of String), requestConditions As RequestConditions, context As RequestContext) As Response

Parameters

jobId
String

The ID of the Job that contains the Task.

taskId
String

The ID of the Task to get information about.

timeOutInSeconds
Nullable<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.".

ocpdate
Nullable<DateTimeOffset>

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.

select
IEnumerable<String>

An OData $select clause.

expand
IEnumerable<String>

An OData $expand clause.

requestConditions
RequestConditions

The content to send as the request conditions of the request.

context
RequestContext

The request context, which can override default behaviors of the client pipeline on a per-call basis.

Returns

The response returned from the service.

Exceptions

jobId or taskId is null.

jobId or taskId is an empty string, and was expected to be non-empty.

Service returned a non-success status code.

Examples

This sample shows how to call GetTask and parse the result.

Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
BatchClient client = new BatchClient(endpoint, credential);

Response response = client.GetTask("<jobId>", "<taskId>", null, null, null, null, null, null);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.ToString());

This sample shows how to call GetTask with all parameters and parse the result.

Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
BatchClient client = new BatchClient(endpoint, credential);

Response response = client.GetTask("<jobId>", "<taskId>", 1234, DateTimeOffset.Parse("Tue, 10 May 2022 18:57:31 GMT"), new string[] { "<select>" }, new string[] { "<expand>" }, null, null);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("id").ToString());
Console.WriteLine(result.GetProperty("displayName").ToString());
Console.WriteLine(result.GetProperty("url").ToString());
Console.WriteLine(result.GetProperty("eTag").ToString());
Console.WriteLine(result.GetProperty("lastModified").ToString());
Console.WriteLine(result.GetProperty("creationTime").ToString());
Console.WriteLine(result.GetProperty("exitConditions").GetProperty("exitCodes")[0].GetProperty("code").ToString());
Console.WriteLine(result.GetProperty("exitConditions").GetProperty("exitCodes")[0].GetProperty("exitOptions").GetProperty("jobAction").ToString());
Console.WriteLine(result.GetProperty("exitConditions").GetProperty("exitCodes")[0].GetProperty("exitOptions").GetProperty("dependencyAction").ToString());
Console.WriteLine(result.GetProperty("exitConditions").GetProperty("exitCodeRanges")[0].GetProperty("start").ToString());
Console.WriteLine(result.GetProperty("exitConditions").GetProperty("exitCodeRanges")[0].GetProperty("end").ToString());
Console.WriteLine(result.GetProperty("exitConditions").GetProperty("exitCodeRanges")[0].GetProperty("exitOptions").GetProperty("jobAction").ToString());
Console.WriteLine(result.GetProperty("exitConditions").GetProperty("exitCodeRanges")[0].GetProperty("exitOptions").GetProperty("dependencyAction").ToString());
Console.WriteLine(result.GetProperty("exitConditions").GetProperty("preProcessingError").GetProperty("jobAction").ToString());
Console.WriteLine(result.GetProperty("exitConditions").GetProperty("preProcessingError").GetProperty("dependencyAction").ToString());
Console.WriteLine(result.GetProperty("exitConditions").GetProperty("fileUploadError").GetProperty("jobAction").ToString());
Console.WriteLine(result.GetProperty("exitConditions").GetProperty("fileUploadError").GetProperty("dependencyAction").ToString());
Console.WriteLine(result.GetProperty("exitConditions").GetProperty("default").GetProperty("jobAction").ToString());
Console.WriteLine(result.GetProperty("exitConditions").GetProperty("default").GetProperty("dependencyAction").ToString());
Console.WriteLine(result.GetProperty("state").ToString());
Console.WriteLine(result.GetProperty("stateTransitionTime").ToString());
Console.WriteLine(result.GetProperty("previousState").ToString());
Console.WriteLine(result.GetProperty("previousStateTransitionTime").ToString());
Console.WriteLine(result.GetProperty("commandLine").ToString());
Console.WriteLine(result.GetProperty("containerSettings").GetProperty("containerRunOptions").ToString());
Console.WriteLine(result.GetProperty("containerSettings").GetProperty("imageName").ToString());
Console.WriteLine(result.GetProperty("containerSettings").GetProperty("registry").GetProperty("username").ToString());
Console.WriteLine(result.GetProperty("containerSettings").GetProperty("registry").GetProperty("password").ToString());
Console.WriteLine(result.GetProperty("containerSettings").GetProperty("registry").GetProperty("registryServer").ToString());
Console.WriteLine(result.GetProperty("containerSettings").GetProperty("registry").GetProperty("identityReference").GetProperty("resourceId").ToString());
Console.WriteLine(result.GetProperty("containerSettings").GetProperty("workingDirectory").ToString());
Console.WriteLine(result.GetProperty("resourceFiles")[0].GetProperty("autoStorageContainerName").ToString());
Console.WriteLine(result.GetProperty("resourceFiles")[0].GetProperty("storageContainerUrl").ToString());
Console.WriteLine(result.GetProperty("resourceFiles")[0].GetProperty("httpUrl").ToString());
Console.WriteLine(result.GetProperty("resourceFiles")[0].GetProperty("blobPrefix").ToString());
Console.WriteLine(result.GetProperty("resourceFiles")[0].GetProperty("filePath").ToString());
Console.WriteLine(result.GetProperty("resourceFiles")[0].GetProperty("fileMode").ToString());
Console.WriteLine(result.GetProperty("resourceFiles")[0].GetProperty("identityReference").GetProperty("resourceId").ToString());
Console.WriteLine(result.GetProperty("outputFiles")[0].GetProperty("filePattern").ToString());
Console.WriteLine(result.GetProperty("outputFiles")[0].GetProperty("destination").GetProperty("container").GetProperty("path").ToString());
Console.WriteLine(result.GetProperty("outputFiles")[0].GetProperty("destination").GetProperty("container").GetProperty("containerUrl").ToString());
Console.WriteLine(result.GetProperty("outputFiles")[0].GetProperty("destination").GetProperty("container").GetProperty("identityReference").GetProperty("resourceId").ToString());
Console.WriteLine(result.GetProperty("outputFiles")[0].GetProperty("destination").GetProperty("container").GetProperty("uploadHeaders")[0].GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("outputFiles")[0].GetProperty("destination").GetProperty("container").GetProperty("uploadHeaders")[0].GetProperty("value").ToString());
Console.WriteLine(result.GetProperty("outputFiles")[0].GetProperty("uploadOptions").GetProperty("uploadCondition").ToString());
Console.WriteLine(result.GetProperty("environmentSettings")[0].GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("environmentSettings")[0].GetProperty("value").ToString());
Console.WriteLine(result.GetProperty("affinityInfo").GetProperty("affinityId").ToString());
Console.WriteLine(result.GetProperty("constraints").GetProperty("maxWallClockTime").ToString());
Console.WriteLine(result.GetProperty("constraints").GetProperty("retentionTime").ToString());
Console.WriteLine(result.GetProperty("constraints").GetProperty("maxTaskRetryCount").ToString());
Console.WriteLine(result.GetProperty("requiredSlots").ToString());
Console.WriteLine(result.GetProperty("userIdentity").GetProperty("username").ToString());
Console.WriteLine(result.GetProperty("userIdentity").GetProperty("autoUser").GetProperty("scope").ToString());
Console.WriteLine(result.GetProperty("userIdentity").GetProperty("autoUser").GetProperty("elevationLevel").ToString());
Console.WriteLine(result.GetProperty("executionInfo").GetProperty("startTime").ToString());
Console.WriteLine(result.GetProperty("executionInfo").GetProperty("endTime").ToString());
Console.WriteLine(result.GetProperty("executionInfo").GetProperty("exitCode").ToString());
Console.WriteLine(result.GetProperty("executionInfo").GetProperty("containerInfo").GetProperty("containerId").ToString());
Console.WriteLine(result.GetProperty("executionInfo").GetProperty("containerInfo").GetProperty("state").ToString());
Console.WriteLine(result.GetProperty("executionInfo").GetProperty("containerInfo").GetProperty("error").ToString());
Console.WriteLine(result.GetProperty("executionInfo").GetProperty("failureInfo").GetProperty("category").ToString());
Console.WriteLine(result.GetProperty("executionInfo").GetProperty("failureInfo").GetProperty("code").ToString());
Console.WriteLine(result.GetProperty("executionInfo").GetProperty("failureInfo").GetProperty("message").ToString());
Console.WriteLine(result.GetProperty("executionInfo").GetProperty("failureInfo").GetProperty("details")[0].GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("executionInfo").GetProperty("failureInfo").GetProperty("details")[0].GetProperty("value").ToString());
Console.WriteLine(result.GetProperty("executionInfo").GetProperty("retryCount").ToString());
Console.WriteLine(result.GetProperty("executionInfo").GetProperty("lastRetryTime").ToString());
Console.WriteLine(result.GetProperty("executionInfo").GetProperty("requeueCount").ToString());
Console.WriteLine(result.GetProperty("executionInfo").GetProperty("lastRequeueTime").ToString());
Console.WriteLine(result.GetProperty("executionInfo").GetProperty("result").ToString());
Console.WriteLine(result.GetProperty("nodeInfo").GetProperty("affinityId").ToString());
Console.WriteLine(result.GetProperty("nodeInfo").GetProperty("nodeUrl").ToString());
Console.WriteLine(result.GetProperty("nodeInfo").GetProperty("poolId").ToString());
Console.WriteLine(result.GetProperty("nodeInfo").GetProperty("nodeId").ToString());
Console.WriteLine(result.GetProperty("nodeInfo").GetProperty("taskRootDirectory").ToString());
Console.WriteLine(result.GetProperty("nodeInfo").GetProperty("taskRootDirectoryUrl").ToString());
Console.WriteLine(result.GetProperty("multiInstanceSettings").GetProperty("numberOfInstances").ToString());
Console.WriteLine(result.GetProperty("multiInstanceSettings").GetProperty("coordinationCommandLine").ToString());
Console.WriteLine(result.GetProperty("multiInstanceSettings").GetProperty("commonResourceFiles")[0].GetProperty("autoStorageContainerName").ToString());
Console.WriteLine(result.GetProperty("multiInstanceSettings").GetProperty("commonResourceFiles")[0].GetProperty("storageContainerUrl").ToString());
Console.WriteLine(result.GetProperty("multiInstanceSettings").GetProperty("commonResourceFiles")[0].GetProperty("httpUrl").ToString());
Console.WriteLine(result.GetProperty("multiInstanceSettings").GetProperty("commonResourceFiles")[0].GetProperty("blobPrefix").ToString());
Console.WriteLine(result.GetProperty("multiInstanceSettings").GetProperty("commonResourceFiles")[0].GetProperty("filePath").ToString());
Console.WriteLine(result.GetProperty("multiInstanceSettings").GetProperty("commonResourceFiles")[0].GetProperty("fileMode").ToString());
Console.WriteLine(result.GetProperty("multiInstanceSettings").GetProperty("commonResourceFiles")[0].GetProperty("identityReference").GetProperty("resourceId").ToString());
Console.WriteLine(result.GetProperty("stats").GetProperty("url").ToString());
Console.WriteLine(result.GetProperty("stats").GetProperty("startTime").ToString());
Console.WriteLine(result.GetProperty("stats").GetProperty("lastUpdateTime").ToString());
Console.WriteLine(result.GetProperty("stats").GetProperty("userCPUTime").ToString());
Console.WriteLine(result.GetProperty("stats").GetProperty("kernelCPUTime").ToString());
Console.WriteLine(result.GetProperty("stats").GetProperty("wallClockTime").ToString());
Console.WriteLine(result.GetProperty("stats").GetProperty("readIOps").ToString());
Console.WriteLine(result.GetProperty("stats").GetProperty("writeIOps").ToString());
Console.WriteLine(result.GetProperty("stats").GetProperty("readIOGiB").ToString());
Console.WriteLine(result.GetProperty("stats").GetProperty("writeIOGiB").ToString());
Console.WriteLine(result.GetProperty("stats").GetProperty("waitTime").ToString());
Console.WriteLine(result.GetProperty("dependsOn").GetProperty("taskIds")[0].ToString());
Console.WriteLine(result.GetProperty("dependsOn").GetProperty("taskIdRanges")[0].GetProperty("start").ToString());
Console.WriteLine(result.GetProperty("dependsOn").GetProperty("taskIdRanges")[0].GetProperty("end").ToString());
Console.WriteLine(result.GetProperty("applicationPackageReferences")[0].GetProperty("applicationId").ToString());
Console.WriteLine(result.GetProperty("applicationPackageReferences")[0].GetProperty("version").ToString());
Console.WriteLine(result.GetProperty("authenticationTokenSettings").GetProperty("access")[0].ToString());

Applies to

GetTask(String, String, Nullable<Int32>, Nullable<DateTimeOffset>, IEnumerable<String>, IEnumerable<String>, RequestConditions, CancellationToken)

Gets information about the specified Task.

public virtual Azure.Response<Azure.Compute.Batch.BatchTask> GetTask (string jobId, string taskId, int? timeOutInSeconds = default, DateTimeOffset? ocpdate = default, System.Collections.Generic.IEnumerable<string> select = default, System.Collections.Generic.IEnumerable<string> expand = default, Azure.RequestConditions requestConditions = default, System.Threading.CancellationToken cancellationToken = default);
abstract member GetTask : string * string * Nullable<int> * Nullable<DateTimeOffset> * seq<string> * seq<string> * Azure.RequestConditions * System.Threading.CancellationToken -> Azure.Response<Azure.Compute.Batch.BatchTask>
override this.GetTask : string * string * Nullable<int> * Nullable<DateTimeOffset> * seq<string> * seq<string> * Azure.RequestConditions * System.Threading.CancellationToken -> Azure.Response<Azure.Compute.Batch.BatchTask>
Public Overridable Function GetTask (jobId As String, taskId As String, Optional timeOutInSeconds As Nullable(Of Integer) = Nothing, Optional ocpdate As Nullable(Of DateTimeOffset) = Nothing, Optional select As IEnumerable(Of String) = Nothing, Optional expand As IEnumerable(Of String) = Nothing, Optional requestConditions As RequestConditions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Response(Of BatchTask)

Parameters

jobId
String

The ID of the Job that contains the Task.

taskId
String

The ID of the Task to get information about.

timeOutInSeconds
Nullable<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.".

ocpdate
Nullable<DateTimeOffset>

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.

select
IEnumerable<String>

An OData $select clause.

expand
IEnumerable<String>

An OData $expand clause.

requestConditions
RequestConditions

The content to send as the request conditions of the request.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

jobId or taskId is null.

jobId or taskId is an empty string, and was expected to be non-empty.

Examples

This sample shows how to call GetTask.

Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
BatchClient client = new BatchClient(endpoint, credential);

Response<BatchTask> response = client.GetTask("<jobId>", "<taskId>");

This sample shows how to call GetTask with all parameters.

Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
BatchClient client = new BatchClient(endpoint, credential);

Response<BatchTask> response = client.GetTask("<jobId>", "<taskId>", timeOutInSeconds: 1234, ocpdate: DateTimeOffset.Parse("Tue, 10 May 2022 18:57:31 GMT"), select: new string[] { "<select>" }, expand: new string[] { "<expand>" }, requestConditions: null);

Remarks

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.

Applies to