Azure Durable Functions

Also known as: Durable Functions

On this page 7

Azure Durable Functions is an extension of Azure Functions that lets developers write stateful workflows in ordinary code on a serverless platform. It adds orchestrations, durable entities and reliable timers to the otherwise stateless function as a service model, so a process that runs for seconds, days or months can survive restarts, scale out and resume exactly where it stopped.

In serverless computing, functions are short-lived and forget everything between invocations. Durable Functions solves that limitation by persisting execution history to a storage backend and rebuilding state through replay, which gives teams workflow orchestration without operating a separate workflow engine or paying for idle servers.

How Durable Functions keeps state through event sourcing

Durable Functions works by recording every step of an orchestration as an event in an append-only history and replaying that history to reconstruct local variables whenever the orchestrator wakes up. The underlying engine is the open-source Durable Task Framework, which Microsoft also uses in other products.

When an orchestrator calls an activity, the framework schedules a message, writes a checkpoint and unloads the orchestrator from memory. When the activity completes, the orchestrator runs again from the beginning; calls that already have results in the history return those results immediately instead of executing again. Execution continues past the last recorded point, and the process repeats.

The function types below divide the work between coordination and execution.

Function typeRoleKey constraint
Client functionStarts, queries, signals or terminates instancesAny trigger, such as HTTP or a queue
Orchestrator functionDefines the workflow and calls other functionsMust be deterministic
Activity functionPerforms the actual work, such as I/O or computationExecuted at least once
Entity functionHolds small pieces of state addressed by an IDOperations processed one at a time
Function types in Durable Functions

Replay explains the most important rule: orchestrator code must be deterministic. Reading the system clock, generating random GUIDs or calling a network service directly would produce different values on each replay, so the API offers safe replacements such as the current orchestration time and a deterministic new GUID.

Application patterns supported by Durable Functions

Durable Functions expresses common distributed workflow patterns in a few lines of code rather than queues, tables and polling logic assembled by hand. The table lists the patterns Microsoft documents and where each fits.

PatternWhat it doesTypical scenario
Function chainingRuns activities in a fixed sequenceValidate, transform and store a document
Fan-out/fan-inRuns activities in parallel, then aggregatesProcess thousands of files and sum results
Async HTTP APIReturns a status endpoint for long workReport generation behind a web request
MonitorPolls a condition with durable timersWait until an external job finishes
Human interactionWaits for an external event with a timeoutManager approval within 72 hours
AggregatorCollects events into a stateful entityRunning totals for a device or account
Core orchestration patterns

Durable timers deserve emphasis because they make long waits cheap. An orchestration that waits three days for approval consumes no compute while sleeping on the Consumption or Flex Consumption plan; the framework schedules a message that wakes the instance when the timer fires or the event arrives.

Sub-orchestrations, retry policies with exponential backoff, and the eternal orchestration pattern, which restarts itself with fresh history through a continue-as-new call, extend these basics for larger or indefinitely running processes.

Durable Functions compared with other workflow options

Durable Functions belongs to the code-first workflow category, as opposed to designer-based or JSON-defined state machines. The comparison below shows how it relates to nearby services in serverless architecture.

OptionDefinition styleStrengthWeakness
Azure Durable FunctionsCode in C#, JavaScript, Python, Java or PowerShellFull language power, unit testableDeterminism rules, replay overhead
Azure Logic AppsVisual designer and JSONHundreds of ready connectorsComplex logic becomes hard to read
AWS Step FunctionsAmazon States Language in JSONVisual execution historyLogic lives outside application code
Plain queues and functionsCustom code and messagesMaximum controlState and retries built by hand
Workflow options for serverless applications

Teams with strong developers and complex branching logic usually prefer Durable Functions, while integration-heavy processes maintained by less technical staff often suit Logic Apps better. The two can also be combined, with Logic Apps calling an orchestration through its HTTP management API.

Storage providers, hosting and performance

The storage provider determines throughput, cost and operational behavior. The default provider uses Azure Storage queues, tables and blobs, while alternatives target higher scale or different infrastructure.

BackendUnderlying storeBest fit
Azure StorageQueues, tables and blobsDefault choice, low cost, moderate throughput
NetheriteEvent Hubs and page blobsVery high orchestration throughput
Microsoft SQLSQL Server or Azure SQL DatabasePortability, on-premises and Kubernetes hosting
Durable Task SchedulerManaged backend serviceBuilt-in monitoring dashboard and higher performance
Durable Functions storage backends

Performance depends heavily on history size. Each replay reads the full history, so orchestrations with thousands of steps slow down; splitting work into sub-orchestrations or using continue-as-new keeps histories short. Large inputs and outputs should be stored externally and passed as references, because payloads above provider limits are written to blobs and add latency.

Common mistakes and limitations

Most production incidents with Durable Functions trace back to a small set of design errors, usually related to replay or versioning.

  • Non-deterministic orchestrator code, such as direct HTTP calls or reading the clock, causes replay failures and nondeterminism errors.
  • Changing orchestration code while instances are in flight can break their replay; versioning strategies or side-by-side deployment are required.
  • Non-idempotent activities may run twice after a crash, because activities have at-least-once execution guarantees.
  • Unbounded fan-out can overwhelm downstream databases; throttling parallel activity batches protects them.
  • Forgetting to purge history lets storage tables grow indefinitely and raises costs over time.

Orchestrations are also not suited to low-latency request paths: each step involves storage writes and queue messages, adding tens to hundreds of milliseconds, so a simple synchronous API call should remain an ordinary function.

The simple explanation

Normal cloud functions are like workers with no memory: they do one small job and forget everything. Azure Durable Functions gives those workers a shared notebook. Every finished step is written down, so if the work is interrupted, a worker can read the notebook and continue from the exact point where it stopped.

This makes it possible to run long processes, such as waiting days for a manager to approve an invoice, without keeping a computer busy the whole time. The key idea is reliable, step-by-step work that remembers its progress, written in normal program code.

How it is used in practice

An insurance company processes claim documents uploaded by customers. A client function starts an orchestration when a file arrives. The orchestrator first runs an activity that extracts text, then fans out to 20 parallel activities that check policy rules, fraud indicators and payment limits, and finally aggregates the results into a single decision.

Claims above a set amount require a human adjuster, so the orchestrator waits up to five days for an approval event, with a durable timer that escalates the case if nobody responds. During that wait no compute is billed. The result is an auditable claims pipeline that handles thousands of claims per day, survives restarts and deployments, and keeps the entire workflow readable in one code file.