你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
BatchClient.GetJobTaskCountsAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
GetJobTaskCountsAsync(String, Nullable<Int32>, Nullable<DateTimeOffset>, CancellationToken) |
Gets the Task counts for the specified Job. |
GetJobTaskCountsAsync(String, Nullable<Int32>, Nullable<DateTimeOffset>, RequestContext) |
[Protocol Method] Gets the Task counts for the specified Job.
|
GetJobTaskCountsAsync(String, Nullable<Int32>, Nullable<DateTimeOffset>, CancellationToken)
- Source:
- BatchClientCustom.cs
Gets the Task counts for the specified Job.
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Compute.Batch.BatchTaskCountsResult>> GetJobTaskCountsAsync (string jobId, int? timeOutInSeconds = default, DateTimeOffset? ocpdate = default, System.Threading.CancellationToken cancellationToken = default);
abstract member GetJobTaskCountsAsync : string * Nullable<int> * Nullable<DateTimeOffset> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Compute.Batch.BatchTaskCountsResult>>
override this.GetJobTaskCountsAsync : string * Nullable<int> * Nullable<DateTimeOffset> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Compute.Batch.BatchTaskCountsResult>>
Public Overridable Function GetJobTaskCountsAsync (jobId As String, Optional timeOutInSeconds As Nullable(Of Integer) = Nothing, Optional ocpdate As Nullable(Of DateTimeOffset) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of BatchTaskCountsResult))
Parameters
- jobId
- String
The ID of the Job.
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.
- 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 GetJobTaskCountsAsync.
Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
BatchClient client = new BatchClient(endpoint, credential);
Response<BatchTaskCountsResult> response = await client.GetJobTaskCountsAsync("<jobId>");
This sample shows how to call GetJobTaskCountsAsync with all parameters.
Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
BatchClient client = new BatchClient(endpoint, credential);
Response<BatchTaskCountsResult> response = await client.GetJobTaskCountsAsync("<jobId>", timeOutInSeconds: 1234, ocpdate: DateTimeOffset.Parse("Tue, 10 May 2022 18:57:31 GMT"));
Remarks
Task counts provide a count of the Tasks by active, running or completed Task state, and a count of Tasks which succeeded or failed. Tasks in the preparing state are counted as running. Note that the numbers returned may not always be up to date. If you need exact task counts, use a list query.
Applies to
GetJobTaskCountsAsync(String, Nullable<Int32>, Nullable<DateTimeOffset>, RequestContext)
- Source:
- BatchClientCustom.cs
[Protocol Method] Gets the Task counts for the specified Job.
- This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
- Please try the simpler GetJobTaskCountsAsync(String, Nullable<Int32>, Nullable<DateTimeOffset>, CancellationToken) convenience overload with strongly typed models first.
public virtual System.Threading.Tasks.Task<Azure.Response> GetJobTaskCountsAsync (string jobId, int? timeOutInSeconds, DateTimeOffset? ocpdate, Azure.RequestContext context);
abstract member GetJobTaskCountsAsync : string * Nullable<int> * Nullable<DateTimeOffset> * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.GetJobTaskCountsAsync : string * Nullable<int> * Nullable<DateTimeOffset> * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function GetJobTaskCountsAsync (jobId As String, timeOutInSeconds As Nullable(Of Integer), ocpdate As Nullable(Of DateTimeOffset), context As RequestContext) As Task(Of Response)
Parameters
- jobId
- String
The ID of the Job.
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.
- 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
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 GetJobTaskCountsAsync 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 = await client.GetJobTaskCountsAsync("<jobId>", null, null, null);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("taskCounts").GetProperty("active").ToString());
Console.WriteLine(result.GetProperty("taskCounts").GetProperty("running").ToString());
Console.WriteLine(result.GetProperty("taskCounts").GetProperty("completed").ToString());
Console.WriteLine(result.GetProperty("taskCounts").GetProperty("succeeded").ToString());
Console.WriteLine(result.GetProperty("taskCounts").GetProperty("failed").ToString());
Console.WriteLine(result.GetProperty("taskSlotCounts").GetProperty("active").ToString());
Console.WriteLine(result.GetProperty("taskSlotCounts").GetProperty("running").ToString());
Console.WriteLine(result.GetProperty("taskSlotCounts").GetProperty("completed").ToString());
Console.WriteLine(result.GetProperty("taskSlotCounts").GetProperty("succeeded").ToString());
Console.WriteLine(result.GetProperty("taskSlotCounts").GetProperty("failed").ToString());
This sample shows how to call GetJobTaskCountsAsync 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 = await client.GetJobTaskCountsAsync("<jobId>", 1234, DateTimeOffset.Parse("Tue, 10 May 2022 18:57:31 GMT"), null);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("taskCounts").GetProperty("active").ToString());
Console.WriteLine(result.GetProperty("taskCounts").GetProperty("running").ToString());
Console.WriteLine(result.GetProperty("taskCounts").GetProperty("completed").ToString());
Console.WriteLine(result.GetProperty("taskCounts").GetProperty("succeeded").ToString());
Console.WriteLine(result.GetProperty("taskCounts").GetProperty("failed").ToString());
Console.WriteLine(result.GetProperty("taskSlotCounts").GetProperty("active").ToString());
Console.WriteLine(result.GetProperty("taskSlotCounts").GetProperty("running").ToString());
Console.WriteLine(result.GetProperty("taskSlotCounts").GetProperty("completed").ToString());
Console.WriteLine(result.GetProperty("taskSlotCounts").GetProperty("succeeded").ToString());
Console.WriteLine(result.GetProperty("taskSlotCounts").GetProperty("failed").ToString());