durable-functions package

Classes

AggregatedError

A specific error thrown when context.df.Task.all() fails. Its message contains an aggregation of all the exceptions that failed. It should follow the below format:

context.df.Task.all() encountered the below error messages:

Name: DurableError Message: The activity function "ActivityA" failed. StackTrace:

Name: DurableError Message: The activity function "ActivityB" failed. StackTrace:

DummyEntityContext

An entity context with dummy default values to facilitate mocking/stubbing the Durable Functions API.

DummyOrchestrationContext

An orchestration context with dummy default values to facilitate mocking/stubbing the Durable Functions API.

DurableClient

Client for starting, querying, terminating and raising events to orchestration and entity instances.

DurableError

A specfic error thrown when a scheduled activity or suborchestrator has failed. This error can be checked for via instanceof guards to catch only exceptions thrown by the DurableJS library.

DurableOrchestrationContext

Provides functionality for application code implementing an orchestration operation.

DurableOrchestrationStatus

Represents the status of a durable orchestration instance.

Can be fetched using DurableClient.getStatus()

EntityId

A unique identifier for an entity, consisting of entity class and entity key.

EntityStateResponse

The response returned by DurableClient.readEntityState().

HttpManagementPayload

Data structure containing instance management HTTP endpoints.

ManagedIdentityTokenSource

Token Source implementation for Azure Managed Identities.

Example

Get a list of Azure Subscriptions by calling the Azure Resource Manager HTTP API.

const df = require("durable-functions");

df.app.orchestration(function* (context) {
  return yield context.df.callHttp({
      method: "GET",
      url: "https://management.azure.com/subscriptions?api-version=2019-06-01",
      tokenSource: df.ManagedIdentityTokenSource("https://management.core.windows.net"),
  });
});
PurgeHistoryResult

Class to hold statistics about this execution of purge history. The return type of DurableClient.purgeHistory()

RetryOptions

Defines retry policies that can be passed as parameters to various operations.

Interfaces

ActivityOptions
ActivityTrigger
CallHttpOptions

Options object provided to callHttp() methods on orchestration contexts

DurableClientInput
DurableClientOptions

Configures the inputs, outputs, and handler for a Durable Client function.

DurableEntityContext

Provides functionality for application code implementing an entity operation.

EntityContext

Context object passed to entity Functions.

EntityOptions
EntityTrigger
GetStatusOptions

Options object passed to client getStatus() method

HttpDurableClientOptions

Configures options for an HTTP-triggered Durable Client function.

OrchestrationContext

Context object passed to orchestration Functions.

OrchestrationFilter

Options object passed to DurableClient APIs to filter orchestrations on which to perform actions

OrchestrationOptions
OrchestrationTrigger
RegisteredActivityTask

A Durable Functions Task.

RegisteredOrchestrationTask

A Durable Functions Task.

StartNewOptions

Options object provided as an optional second argument to the client.startNew() method

Task

A Durable Functions Task.

TaskHubOptions

Options object passed to DurableClient APIs to specify task hub properties

TimerDurableClientOptions

Configures options for a timer-triggered Durable Client function.

TimerTask

Returned from DurableClient.createTimer(Date) if the call is not yield-ed. Represents a pending timer. See documentation on Task for more information.

All pending timers must be completed or canceled for an orchestration to complete.

Example

Cancel a timer

// calculate expiration date
const timeoutTask = context.df.createTimer(expirationDate);

// do some work

if (!timeoutTask.isCompleted) {
    // An orchestration won't get marked as completed until all its scheduled
    // tasks have returned, or been cancelled. Therefore, it is important
    // to cancel timers when they're no longer needed
    timeoutTask.cancel();
}

Example

Create a timeout

const now = Date.now();
const expiration = new Date(now.valueOf()).setMinutes(now.getMinutes() + 30);

const timeoutTask = context.df.createTimer(expirationDate);
const otherTask = context.df.callActivity("DoWork");

const winner = yield context.df.Task.any([timeoutTask, otherTask]);

if (winner === otherTask) {
    // do some more work
}

if (!timeoutTask.isCompleted) {
    // An orchestration won't get marked as completed until all its scheduled
    // tasks have returned, or been cancelled. Therefore, it is important
    // to cancel timers when they're no longer needed
    timeoutTask.cancel();
}
WaitForCompletionOptions

Options object passed to the durableClient.waitForCompletionOrCreateCheckStatusResponse() method to specify timeouts for how long to wait for output from the durable function and how often to check for output.

Type Aliases

ActivityHandler
DurableClientHandler

Type of a handler function that is triggered by some trigger and receives a DurableClient instance as an input.

EntityHandler
HttpDurableClientHandler
OrchestrationHandler

Type of a Generator that can be registered as an orchestration

RegisteredActivity
RegisteredOrchestration
TimerDurableClientHandler
TokenSource

Enums

OrchestrationRuntimeStatus

The status of an orchestration instance.

Functions

getClient(InvocationContext)

Returns an OrchestrationClient instance.

Function Details

getClient(InvocationContext)

Returns an OrchestrationClient instance.

function getClient(context: InvocationContext): DurableClient

Parameters

context
InvocationContext

The context object of the Azure function whose body calls this method.

Returns