Share via


DurableTaskClient.TerminateInstanceAsync Method

Definition

Overloads

TerminateInstanceAsync(String, CancellationToken)

Terminates a running orchestration instance and updates its runtime status to Terminated.

TerminateInstanceAsync(String, Object, CancellationToken)

Terminates a running orchestration instance and updates its runtime status to Terminated.

TerminateInstanceAsync(String, CancellationToken)

Terminates a running orchestration instance and updates its runtime status to Terminated.

public virtual System.Threading.Tasks.Task TerminateInstanceAsync (string instanceId, System.Threading.CancellationToken cancellation);
abstract member TerminateInstanceAsync : string * System.Threading.CancellationToken -> System.Threading.Tasks.Task
override this.TerminateInstanceAsync : string * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Overridable Function TerminateInstanceAsync (instanceId As String, cancellation As CancellationToken) As Task

Parameters

instanceId
String

The ID of the orchestration instance to terminate.

cancellation
CancellationToken

The cancellation token. This only cancels enqueueing the termination request to the backend. Does not abort termination of the orchestration once enqueued.

Returns

A task that completes when the terminate message is enqueued.

Applies to

TerminateInstanceAsync(String, Object, CancellationToken)

Terminates a running orchestration instance and updates its runtime status to Terminated.

public abstract System.Threading.Tasks.Task TerminateInstanceAsync (string instanceId, object? output = default, System.Threading.CancellationToken cancellation = default);
abstract member TerminateInstanceAsync : string * obj * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public MustOverride Function TerminateInstanceAsync (instanceId As String, Optional output As Object = Nothing, Optional cancellation As CancellationToken = Nothing) As Task

Parameters

instanceId
String

The ID of the orchestration instance to terminate.

output
Object

The optional output to set for the terminated orchestration instance.

cancellation
CancellationToken

The cancellation token. This only cancels enqueueing the termination request to the backend. Does not abort termination of the orchestration once enqueued.

Returns

A task that completes when the terminate message is enqueued.

Remarks

This method internally enqueues a "terminate" message in the task hub. When the task hub worker processes this message, it will update the runtime status of the target instance to Terminated. You can use the WaitForInstanceCompletionAsync(String, Boolean, CancellationToken) to wait for the instance to reach the terminated state.

Terminating an orchestration instance has no effect on any in-flight activity function executions or sub-orchestrations that were started by the terminated instance. Those actions will continue to run without interruption. However, their results will be discarded. If you want to terminate sub-orchestrations, you must issue separate terminate commands for each sub-orchestration instance.

At the time of writing, there is no way to terminate an in-flight activity execution.

Attempting to terminate a completed or non-existent orchestration instance will fail silently.

Applies to