The release 2.4.0 of Durable Functions brings native support for distributed tracing, the ability to use Durable Functions in other .NET Core applications using dependency injection, and a new API to restart orchestrations.
In a serverless environment, you need to design your functions to be stateless. However, a workflow often has a state associated with it and is stored on a queue or a database. Durable Functions is a framework that abstracts the state management, and you just need to code the workflow using an Orchestrator Function and its activities using Activity Functions.
One of the main features of this release allows a native correlation of the activities performed by an Orchestrator Function. Durable Functions runs/sleeps a workflow multiple times, but it will contain a different operation id for each iteration, making it hard for developers to correlate the logs.
The distributed tracing feature will correlate the requests performed by an orchestrator and its child activities when enabled. With a single query in your Azure Application Insights, you can understand the amount of time spent in each task of your workflow and also visualize if an activity has failed:
To enable the distributed tracing feature, you need to set to true
the property extensions.durableTask.tracing.distributedTracingEnabled
and specify the distributed tracing protocol in the host.json
file. A full sample can be found in the official GitHub repository.
Another feature of this release allows you to inject an instance of IDurableClient
into Console Apps and ASP.NET Core applications to perform management operations on orchestrations and entities.
You can visit the following GitHub repository for further details and a sample TODO-LIST ASP.NET application that calls a SetReminder
Durable Function every time a task is added to the list. The SetReminder
function schedules a reminder text to be sent to your phone after 24 hours so you won't forget to complete the task.
The last new feature on this release allows the restart of orchestrations that may have failed or have terminated due to transient conditions. The restarted orchestration will use the same input as the original orchestration, and it can reuse the instance id or use a new one.
This new API can be called with the C# method IDurableOrchestrationClient.RestartAsync(string instanceId, bool restartWithNewInstanceId)
as well as the HTTP API /instances/<instance-id>/restart
. Support for Azure Functions Node and Python SDKs will be added in future releases.
Durable Functions is an open-source project released under the MIT license. Contributions, feedback, issues reports, and feature requests are welcome.