Table of Contents

Class TaskHubClient

Namespace
DurableTask.Core
Assembly
DurableTask.Core.dll

Client used to manage and query orchestration instances

public sealed class TaskHubClient
Inheritance
TaskHubClient
Inherited Members

Constructors

TaskHubClient(IOrchestrationServiceClient)

Create a new TaskHubClient with the given OrchestrationServiceClient

public TaskHubClient(IOrchestrationServiceClient serviceClient)

Parameters

serviceClient IOrchestrationServiceClient

Object implementing the IOrchestrationServiceClient interface

TaskHubClient(IOrchestrationServiceClient, JsonDataConverter)

Create a new TaskHubClient with the given OrchestrationServiceClient and JsonDataConverter.

public TaskHubClient(IOrchestrationServiceClient serviceClient, JsonDataConverter dataConverter)

Parameters

serviceClient IOrchestrationServiceClient

Object implementing the IOrchestrationServiceClient interface

dataConverter JsonDataConverter

The JsonDataConverter to use for message serialization.

Properties

ServiceClient

The orchestration service client for this task hub client

public IOrchestrationServiceClient ServiceClient { get; }

Property Value

IOrchestrationServiceClient

Methods

CreateOrchestrationInstanceAsync(string, string, object)

Create a new orchestration of the specified name and version

public Task<OrchestrationInstance> CreateOrchestrationInstanceAsync(string name, string version, object input)

Parameters

name string

Name of the TaskOrchestration

version string

Version of the TaskOrchestration

input object

Input parameter to the specified TaskOrchestration

Returns

Task<OrchestrationInstance>

OrchestrationInstance that represents the orchestration that was created

CreateOrchestrationInstanceAsync(string, string, string, object)

Create a new orchestration of the specified name and version

public Task<OrchestrationInstance> CreateOrchestrationInstanceAsync(string name, string version, string instanceId, object input)

Parameters

name string

Name of the orchestration as specified by the ObjectCreator

version string

Name of the orchestration as specified by the ObjectCreator

instanceId string

Instance id for the orchestration to be created, must be unique across the Task Hub

input object

Input parameter to the specified TaskOrchestration

Returns

Task<OrchestrationInstance>

OrchestrationInstance that represents the orchestration that was created

CreateOrchestrationInstanceAsync(string, string, string, object, IDictionary<string, string>)

Create a new orchestration of the specified name and version

public Task<OrchestrationInstance> CreateOrchestrationInstanceAsync(string name, string version, string instanceId, object input, IDictionary<string, string> tags)

Parameters

name string

Name of the orchestration as specified by the ObjectCreator

version string

Name of the orchestration as specified by the ObjectCreator

instanceId string

Instance id for the orchestration to be created, must be unique across the Task Hub

input object

Input parameter to the specified TaskOrchestration

tags IDictionary<string, string>

Dictionary of key/value tags associated with this instance

Returns

Task<OrchestrationInstance>

OrchestrationInstance that represents the orchestration that was created

CreateOrchestrationInstanceAsync(string, string, string, object, IDictionary<string, string>, OrchestrationStatus[])

Create a new orchestration of the specified name and version

public Task<OrchestrationInstance> CreateOrchestrationInstanceAsync(string name, string version, string instanceId, object input, IDictionary<string, string> tags, OrchestrationStatus[] dedupeStatuses)

Parameters

name string

Name of the orchestration as specified by the ObjectCreator

version string

Name of the orchestration as specified by the ObjectCreator

instanceId string

Instance id for the orchestration to be created, must be unique across the Task Hub

input object

Input parameter to the specified TaskOrchestration

tags IDictionary<string, string>

Dictionary of key/value tags associated with this instance

dedupeStatuses OrchestrationStatus[]

States of previous orchestration executions to be considered while de-duping new orchestrations on the client

Returns

Task<OrchestrationInstance>

OrchestrationInstance that represents the orchestration that was created

CreateOrchestrationInstanceAsync(Type, object)

Create a new orchestration of the specified type with an automatically generated instance id

public Task<OrchestrationInstance> CreateOrchestrationInstanceAsync(Type orchestrationType, object input)

Parameters

orchestrationType Type

Type that derives from TaskOrchestration

input object

Input parameter to the specified TaskOrchestration

Returns

Task<OrchestrationInstance>

OrchestrationInstance that represents the orchestration that was created

CreateOrchestrationInstanceAsync(Type, string, object)

Create a new orchestration of the specified type with the specified instance id

public Task<OrchestrationInstance> CreateOrchestrationInstanceAsync(Type orchestrationType, string instanceId, object input)

Parameters

orchestrationType Type

Type that derives from TaskOrchestration

instanceId string

Instance id for the orchestration to be created, must be unique across the Task Hub

input object

Input parameter to the specified TaskOrchestration

Returns

Task<OrchestrationInstance>

OrchestrationInstance that represents the orchestration that was created

CreateOrchestrationInstanceAsync(Type, string, object, OrchestrationStatus[])

Create a new orchestration of the specified type with the specified instance id

public Task<OrchestrationInstance> CreateOrchestrationInstanceAsync(Type orchestrationType, string instanceId, object input, OrchestrationStatus[] dedupeStatuses)

Parameters

orchestrationType Type

Type that derives from TaskOrchestration

instanceId string

Instance id for the orchestration to be created, must be unique across the Task Hub

input object

Input parameter to the specified TaskOrchestration

dedupeStatuses OrchestrationStatus[]

States of previous orchestration executions to be considered while de-duping new orchestrations on the client

Returns

Task<OrchestrationInstance>

OrchestrationInstance that represents the orchestration that was created

CreateOrchestrationInstanceWithRaisedEventAsync(string, string, object, string, object)

Creates an orchestration instance, and raises an event for it, which eventually causes the OnEvent() method in the orchestration to fire.

public Task<OrchestrationInstance> CreateOrchestrationInstanceWithRaisedEventAsync(string orchestrationName, string orchestrationVersion, object orchestrationInput, string eventName, object eventData)

Parameters

orchestrationName string

Name of the TaskOrchestration

orchestrationVersion string

Version of the TaskOrchestration

orchestrationInput object

Input parameter to the specified TaskOrchestration

eventName string

Name of the event

eventData object

Data for the event

Returns

Task<OrchestrationInstance>

OrchestrationInstance that represents the orchestration that was created

CreateOrchestrationInstanceWithRaisedEventAsync(string, string, string, object)

Creates an orchestration instance, and raises an event for it, which eventually causes the OnEvent() method in the orchestration to fire.

public Task<OrchestrationInstance> CreateOrchestrationInstanceWithRaisedEventAsync(string orchestrationName, string orchestrationVersion, string eventName, object eventData)

Parameters

orchestrationName string

Name of the orchestration as specified by the ObjectCreator

orchestrationVersion string

Name of the orchestration as specified by the ObjectCreator

eventName string

Name of the event

eventData object

Data for the event

Returns

Task<OrchestrationInstance>

CreateOrchestrationInstanceWithRaisedEventAsync(string, string, string, object, IDictionary<string, string>, OrchestrationStatus[], string, object)

Creates an orchestration instance, and raises an event for it, which eventually causes the OnEvent() method in the orchestration to fire.

public Task<OrchestrationInstance> CreateOrchestrationInstanceWithRaisedEventAsync(string orchestrationName, string orchestrationVersion, string instanceId, object orchestrationInput, IDictionary<string, string> orchestrationTags, OrchestrationStatus[] dedupeStatuses, string eventName, object eventData)

Parameters

orchestrationName string

Name of the TaskOrchestration

orchestrationVersion string

Version of the TaskOrchestration

instanceId string

Instance id for the orchestration to be created, must be unique across the Task Hub

orchestrationInput object

Input parameter to the specified TaskOrchestration

orchestrationTags IDictionary<string, string>

Dictionary of key/value tags associated with this instance

dedupeStatuses OrchestrationStatus[]

States of previous orchestration executions to be considered while de-duping new orchestrations on the client

eventName string

Name of the event

eventData object

Data for the event

Returns

Task<OrchestrationInstance>

OrchestrationInstance that represents the orchestration that was created

CreateOrchestrationInstanceWithRaisedEventAsync(string, string, string, object, IDictionary<string, string>, string, object)

Creates an orchestration instance, and raises an event for it, which eventually causes the OnEvent() method in the orchestration to fire.

public Task<OrchestrationInstance> CreateOrchestrationInstanceWithRaisedEventAsync(string orchestrationName, string orchestrationVersion, string instanceId, object orchestrationInput, IDictionary<string, string> orchestrationTags, string eventName, object eventData)

Parameters

orchestrationName string

Name of the TaskOrchestration

orchestrationVersion string

Version of the TaskOrchestration

instanceId string

Instance id for the orchestration to be created, must be unique across the Task Hub

orchestrationInput object

Input parameter to the specified TaskOrchestration

orchestrationTags IDictionary<string, string>

Dictionary of key/value tags associated with this instance

eventName string

Name of the event

eventData object

Data for the event

Returns

Task<OrchestrationInstance>

OrchestrationInstance that represents the orchestration that was created

CreateOrchestrationInstanceWithRaisedEventAsync(string, string, string, object, string, object)

Creates an orchestration instance, and raises an event for it, which eventually causes the OnEvent() method in the orchestration to fire.

public Task<OrchestrationInstance> CreateOrchestrationInstanceWithRaisedEventAsync(string orchestrationName, string orchestrationVersion, string instanceId, object orchestrationInput, string eventName, object eventData)

Parameters

orchestrationName string

Name of the TaskOrchestration

orchestrationVersion string

Version of the TaskOrchestration

instanceId string

Instance id for the orchestration to be created, must be unique across the Task Hub

orchestrationInput object

Input parameter to the specified TaskOrchestration

eventName string

Name of the event

eventData object

Data for the event

Returns

Task<OrchestrationInstance>

OrchestrationInstance that represents the orchestration that was created

CreateOrchestrationInstanceWithRaisedEventAsync(string, string, string, string, object)

Creates an orchestration instance, and raises an event for it, which eventually causes the OnEvent() method in the orchestration to fire.

public Task<OrchestrationInstance> CreateOrchestrationInstanceWithRaisedEventAsync(string orchestrationName, string orchestrationVersion, string instanceId, string eventName, object eventData)

Parameters

orchestrationName string

Name of the orchestration as specified by the ObjectCreator

orchestrationVersion string

Name of the orchestration as specified by the ObjectCreator

instanceId string

Instance id for the orchestration to be created, must be unique across the Task Hub

eventName string

Name of the event

eventData object

Data for the event

Returns

Task<OrchestrationInstance>

CreateOrchestrationInstanceWithRaisedEventAsync(Type, object, string, object)

Creates an orchestration instance, and raises an event for it, which eventually causes the OnEvent() method in the orchestration to fire.

public Task<OrchestrationInstance> CreateOrchestrationInstanceWithRaisedEventAsync(Type orchestrationType, object orchestrationInput, string eventName, object eventData)

Parameters

orchestrationType Type

Type that derives from TaskOrchestration

orchestrationInput object

Input parameter to the specified TaskOrchestration

eventName string

Name of the event

eventData object

Data for the event

Returns

Task<OrchestrationInstance>

OrchestrationInstance that represents the orchestration that was created

CreateOrchestrationInstanceWithRaisedEventAsync(Type, string, object, OrchestrationStatus[], string, object)

Creates an orchestration instance, and raises an event for it, which eventually causes the OnEvent() method in the orchestration to fire.

public Task<OrchestrationInstance> CreateOrchestrationInstanceWithRaisedEventAsync(Type orchestrationType, string instanceId, object orchestrationInput, OrchestrationStatus[] dedupeStatuses, string eventName, object eventData)

Parameters

orchestrationType Type

Type that derives from TaskOrchestration

instanceId string

Instance id for the orchestration to be created, must be unique across the Task Hub

orchestrationInput object

Input parameter to the specified TaskOrchestration

dedupeStatuses OrchestrationStatus[]

States of previous orchestration executions to be considered while de-duping new orchestrations on the client

eventName string

Name of the event

eventData object

Data for the event

Returns

Task<OrchestrationInstance>

OrchestrationInstance that represents the orchestration that was created

CreateOrchestrationInstanceWithRaisedEventAsync(Type, string, object, string, object)

Creates an orchestration instance, and raises an event for it, which eventually causes the OnEvent() method in the orchestration to fire.

public Task<OrchestrationInstance> CreateOrchestrationInstanceWithRaisedEventAsync(Type orchestrationType, string instanceId, object orchestrationInput, string eventName, object eventData)

Parameters

orchestrationType Type

Type that derives from TaskOrchestration

instanceId string

Instance id for the orchestration to be created, must be unique across the Task Hub

orchestrationInput object

Input parameter to the specified TaskOrchestration

eventName string

Name of the event

eventData object

Data for the event

Returns

Task<OrchestrationInstance>

OrchestrationInstance that represents the orchestration that was created

GetOrchestrationHistoryAsync(OrchestrationInstance)

Get a string dump of the execution history of the specified orchestration instance specified execution (generation) of the specified instance.

public Task<string> GetOrchestrationHistoryAsync(OrchestrationInstance instance)

Parameters

instance OrchestrationInstance

Instance

Returns

Task<string>

String with formatted JSON representing the execution history

Exceptions

InvalidOperationException

Thrown if instance store not configured

GetOrchestrationStateAsync(OrchestrationInstance)

Get a list of orchestration states from the instance storage table for the most current execution (generation) of the specified instance.

public Task<OrchestrationState> GetOrchestrationStateAsync(OrchestrationInstance instance)

Parameters

instance OrchestrationInstance

Instance

Returns

Task<OrchestrationState>

The OrchestrationState of the specified instanceId or null if not found

Exceptions

InvalidOperationException

Thrown if instance store not configured

GetOrchestrationStateAsync(string)

Get a list of orchestration states from the instance storage table for the most current execution (generation) of the specified instance.

public Task<OrchestrationState> GetOrchestrationStateAsync(string instanceId)

Parameters

instanceId string

Instance id

Returns

Task<OrchestrationState>

The OrchestrationState of the specified instanceId or null if not found

Exceptions

InvalidOperationException

Thrown if instance store not configured

GetOrchestrationStateAsync(string, bool)

Get a list of orchestration states from the instance storage table for either the most current or all executions (generations) of the specified instance.

public Task<IList<OrchestrationState>> GetOrchestrationStateAsync(string instanceId, bool allExecutions)

Parameters

instanceId string

Instance id

allExecutions bool

True if method should fetch all executions of the instance, false if the method should only fetch the most recent execution

Returns

Task<IList<OrchestrationState>>

List of OrchestrationState objects that represents the list of orchestrations in the instance store

Exceptions

InvalidOperationException

Thrown if instance store not configured

GetOrchestrationStateAsync(string, string)

Get a list of orchestration states from the instance storage table for the specified execution (generation) of the specified instance.

public Task<OrchestrationState> GetOrchestrationStateAsync(string instanceId, string executionId)

Parameters

instanceId string

Instance id

executionId string

Execution id

Returns

Task<OrchestrationState>

The OrchestrationState of the specified instanceId or null if not found

Exceptions

InvalidOperationException

Thrown if instance store not configured

PurgeOrchestrationInstanceHistoryAsync(DateTime, OrchestrationStateTimeRangeFilterType)

Purges orchestration instance state and history for orchestrations older than the specified threshold time.

public Task PurgeOrchestrationInstanceHistoryAsync(DateTime thresholdDateTimeUtc, OrchestrationStateTimeRangeFilterType timeRangeFilterType)

Parameters

thresholdDateTimeUtc DateTime

Threshold date time in UTC

timeRangeFilterType OrchestrationStateTimeRangeFilterType

What to compare the threshold date time against

Returns

Task

Exceptions

InvalidOperationException

Thrown if instance store not configured

RaiseEventAsync(OrchestrationInstance, string, object)

Raises an event in the specified orchestration instance, which eventually causes the OnEvent() method in the orchestration to fire.

public Task RaiseEventAsync(OrchestrationInstance orchestrationInstance, string eventName, object eventData)

Parameters

orchestrationInstance OrchestrationInstance

Instance in which to raise the event

eventName string

Name of the event

eventData object

Data for the event

Returns

Task

TerminateInstanceAsync(OrchestrationInstance)

Forcefully terminate the specified orchestration instance

public Task TerminateInstanceAsync(OrchestrationInstance orchestrationInstance)

Parameters

orchestrationInstance OrchestrationInstance

Instance to terminate

Returns

Task

TerminateInstanceAsync(OrchestrationInstance, string)

Forcefully terminate the specified orchestration instance with a reason

public Task TerminateInstanceAsync(OrchestrationInstance orchestrationInstance, string reason)

Parameters

orchestrationInstance OrchestrationInstance

Instance to terminate

reason string

Reason for terminating the instance

Returns

Task

WaitForOrchestrationAsync(OrchestrationInstance, TimeSpan)

Wait for an orchestration to reach any terminal state within the given timeout

public Task<OrchestrationState> WaitForOrchestrationAsync(OrchestrationInstance orchestrationInstance, TimeSpan timeout)

Parameters

orchestrationInstance OrchestrationInstance

Instance to terminate

timeout TimeSpan

Max timeout to wait

Returns

Task<OrchestrationState>

WaitForOrchestrationAsync(OrchestrationInstance, TimeSpan, CancellationToken)

Wait for an orchestration to reach any terminal state within the given timeout

public Task<OrchestrationState> WaitForOrchestrationAsync(OrchestrationInstance orchestrationInstance, TimeSpan timeout, CancellationToken cancellationToken)

Parameters

orchestrationInstance OrchestrationInstance

Instance to terminate

timeout TimeSpan

Max timeout to wait

cancellationToken CancellationToken

Task cancellation token

Returns

Task<OrchestrationState>