Partilhar via


BatchClient.TerminateJob Method

Definition

Overloads

TerminateJob(String, BatchJobTerminateContent, Nullable<Int32>, Nullable<DateTimeOffset>, RequestConditions, CancellationToken)

Terminates the specified Job, marking it as completed.

TerminateJob(String, RequestContent, Nullable<Int32>, Nullable<DateTimeOffset>, RequestConditions, RequestContext)

[Protocol Method] Terminates the specified Job, marking it as completed.

TerminateJob(String, BatchJobTerminateContent, Nullable<Int32>, Nullable<DateTimeOffset>, RequestConditions, CancellationToken)

Source:
BatchClient.cs

Terminates the specified Job, marking it as completed.

public virtual Azure.Response TerminateJob (string jobId, Azure.Compute.Batch.BatchJobTerminateContent parameters = default, int? timeOutInSeconds = default, DateTimeOffset? ocpdate = default, Azure.RequestConditions requestConditions = default, System.Threading.CancellationToken cancellationToken = default);
abstract member TerminateJob : string * Azure.Compute.Batch.BatchJobTerminateContent * Nullable<int> * Nullable<DateTimeOffset> * Azure.RequestConditions * System.Threading.CancellationToken -> Azure.Response
override this.TerminateJob : string * Azure.Compute.Batch.BatchJobTerminateContent * Nullable<int> * Nullable<DateTimeOffset> * Azure.RequestConditions * System.Threading.CancellationToken -> Azure.Response
Public Overridable Function TerminateJob (jobId As String, Optional parameters As BatchJobTerminateContent = Nothing, Optional timeOutInSeconds As Nullable(Of Integer) = Nothing, Optional ocpdate As Nullable(Of DateTimeOffset) = Nothing, Optional requestConditions As RequestConditions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Response

Parameters

jobId
String

The ID of the Job to terminate.

parameters
BatchJobTerminateContent

The options to use for terminating 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.

requestConditions
RequestConditions

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

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

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

Response response = client.TerminateJob("<jobId>");

This sample shows how to call TerminateJob with all parameters.

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

BatchJobTerminateContent parameters = new BatchJobTerminateContent
{
    TerminationReason = "<terminateReason>",
};
Response response = client.TerminateJob("<jobId>", parameters: parameters, timeOutInSeconds: 1234, ocpdate: DateTimeOffset.Parse("Tue, 10 May 2022 18:57:31 GMT"), requestConditions: null);

Remarks

When a Terminate Job request is received, the Batch service sets the Job to the terminating state. The Batch service then terminates any running Tasks associated with the Job and runs any required Job release Tasks. Then the Job moves into the completed state. If there are any Tasks in the Job in the active state, they will remain in the active state. Once a Job is terminated, new Tasks cannot be added and any remaining active Tasks will not be scheduled.

Applies to

TerminateJob(String, RequestContent, Nullable<Int32>, Nullable<DateTimeOffset>, RequestConditions, RequestContext)

Source:
BatchClient.cs

[Protocol Method] Terminates the specified Job, marking it as completed.

public virtual Azure.Response TerminateJob (string jobId, Azure.Core.RequestContent content, int? timeOutInSeconds = default, DateTimeOffset? ocpdate = default, Azure.RequestConditions requestConditions = default, Azure.RequestContext context = default);
abstract member TerminateJob : string * Azure.Core.RequestContent * Nullable<int> * Nullable<DateTimeOffset> * Azure.RequestConditions * Azure.RequestContext -> Azure.Response
override this.TerminateJob : string * Azure.Core.RequestContent * Nullable<int> * Nullable<DateTimeOffset> * Azure.RequestConditions * Azure.RequestContext -> Azure.Response
Public Overridable Function TerminateJob (jobId As String, content As RequestContent, Optional timeOutInSeconds As Nullable(Of Integer) = Nothing, Optional ocpdate As Nullable(Of DateTimeOffset) = Nothing, Optional requestConditions As RequestConditions = Nothing, Optional context As RequestContext = Nothing) As Response

Parameters

jobId
String

The ID of the Job to terminate.

content
RequestContent

The content to send as the body of the request.

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.

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

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

using RequestContent content = null;
Response response = client.TerminateJob("<jobId>", content);

Console.WriteLine(response.Status);

This sample shows how to call TerminateJob with all parameters and request content.

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

using RequestContent content = RequestContent.Create(new
{
    terminateReason = "<terminateReason>",
});
Response response = client.TerminateJob("<jobId>", content, timeOutInSeconds: 1234, ocpdate: DateTimeOffset.Parse("Tue, 10 May 2022 18:57:31 GMT"), requestConditions: null);

Console.WriteLine(response.Status);

Applies to