Some work takes days and consists mostly of waiting: A tender waits for management to decide whether the office will bid, at most until its deadline, and someone should be reminded a day before. With ordinary Functions that would take state in a database, a timer that checks every hour, and code that holds state, reminder and deadline together. Durable Functions is an extension of Azure Functions for exactly such workflows: You write the workflow as ordinary C# code with await, and the extension saves after every step where it stands. If the host fails or the app is delivered anew, it picks up at the same place.

New in this lesson:

Package Version What for
Microsoft.Azure.Functions.Worker.Extensions.DurableTask 1.22.0 Durable Functions in the isolated worker model, with analyzers for the orchestrator's rules

The building blocks

  • Orchestration (orchestrator function): describes the workflow. It calls activities, waits for timers and events, and decides. It does no work with the outside world itself.
  • Activity: does the work, a step with an effect: send an email, write a row, ask an interface. An activity can be repeated and is therefore idempotent, like every processing step in module 3.5.
  • Entity (durable entity): a small object with state and operations that handles messages one at a time, such as a counter per calendar. It is reminiscent of the actor in lesson 3.11.8.
  • Client: starts orchestrations, sends them events, asks for their state, ends them. In a Function it is a parameter with [DurableClient] DurableTaskClient client.

Every orchestration has an instance ID. You use it to ask for the state (Running, Completed, Failed, Terminated) and to send events.