你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

BatchClient.GetTasks Method

Definition

Overloads

GetTasks(String, Nullable<Int32>, Nullable<DateTimeOffset>, Nullable<Int32>, String, IEnumerable<String>, IEnumerable<String>, RequestContext)

[Protocol Method] Lists all of the Tasks that are associated with the specified Job.

GetTasks(String, Nullable<Int32>, Nullable<DateTimeOffset>, Nullable<Int32>, String, IEnumerable<String>, IEnumerable<String>, CancellationToken)

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

GetTasks(String, Nullable<Int32>, Nullable<DateTimeOffset>, Nullable<Int32>, String, IEnumerable<String>, IEnumerable<String>, RequestContext)

Source:
BatchClient.cs

[Protocol Method] Lists all of the Tasks that are associated with the specified Job.

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

Parameters

jobId
String

The ID of the Job.

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.

maxresults
Nullable<Int32>

The maximum number of items to return in the response. A maximum of 1000 applications can be returned.

filter
String

An OData $filter clause. For more information on constructing this filter, see https://docs.microsoft.com/en-us/rest/api/batchservice/odata-filters-in-batch#list-tasks.

select
IEnumerable<String>

An OData $select clause.

expand
IEnumerable<String>

An OData $expand clause.

context
RequestContext

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

Returns

The Pageable<T> from the service containing a list of BinaryData objects. Details of the body schema for each item in the collection are in the Remarks section below.

Exceptions

jobId is null.

jobId 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 GetTasks and parse the result.

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

foreach (BinaryData item in client.GetTasks("<jobId>", null, null, null, null, null, null, null))
{
    JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement;
    Console.WriteLine(result.ToString());
}

This sample shows how to call GetTasks 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);

foreach (BinaryData item in client.GetTasks("<jobId>", 1234, DateTimeOffset.Parse("Tue, 10 May 2022 18:57:31 GMT"), 1234, "<filter>", new string[] { "<select>" }, new string[] { "<expand>" }, null))
{
    JsonElement result = JsonDocument.Parse(item.ToStream()).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

GetTasks(String, Nullable<Int32>, Nullable<DateTimeOffset>, Nullable<Int32>, String, IEnumerable<String>, IEnumerable<String>, CancellationToken)

Source:
BatchClient.cs

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

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

Parameters

jobId
String

The ID of the Job.

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.

maxresults
Nullable<Int32>

The maximum number of items to return in the response. A maximum of 1000 applications can be returned.

filter
String

An OData $filter clause. For more information on constructing this filter, see https://docs.microsoft.com/en-us/rest/api/batchservice/odata-filters-in-batch#list-tasks.

select
IEnumerable<String>

An OData $select clause.

expand
IEnumerable<String>

An OData $expand clause.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

jobId is null.

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

Examples

This sample shows how to call GetTasks.

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

foreach (BatchTask item in client.GetTasks("<jobId>"))
{
}

This sample shows how to call GetTasks with all parameters.

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

foreach (BatchTask item in client.GetTasks("<jobId>", timeOutInSeconds: 1234, ocpdate: DateTimeOffset.Parse("Tue, 10 May 2022 18:57:31 GMT"), maxresults: 1234, filter: "<filter>", select: new string[] { "<select>" }, expand: new string[] { "<expand>" }))
{
}

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