Inferensys

Glossary

Durable Function

Durable Function is an extension of Azure Functions that provides a serverless orchestration framework for writing stateful workflows with automatic checkpointing and replay.
Developer designing multi-agent workflow on laptop, architecture diagram on screen, casual home office setup with afternoon light.
AZURE SERVERLESS ORCHESTRATION

What is Durable Function?

A Durable Function is a serverless orchestration framework on Microsoft Azure that enables the creation of stateful, long-running workflows using a serverless compute model.

A Durable Function is an extension of Azure Functions that provides a framework for writing stateful workflows in a serverless environment. It automatically manages checkpointing and replay of function execution, allowing complex, long-running processes to be composed from smaller, stateless functions. This model abstracts away the complexities of managing state, queues, and reliability, enabling developers to write orchestration logic using familiar procedural code patterns in C#, Python, JavaScript, or other supported languages.

The framework implements core cloud design patterns like the Function Chaining and Fan-out/Fan-in patterns, and the Saga pattern for distributed transactions. It uses underlying Azure Storage (queues, tables, blobs) or the Microsoft Durable Task Framework to durably persist orchestration state. This architecture ensures atomicity guarantees and eventual consistency, making it ideal for business process automation, data processing pipelines, and other long-running processes that require resilience to server restarts and transient failures.

ORCHESTRATION LAYER DESIGN

Core Features of Durable Functions

Durable Functions is an Azure serverless extension that provides a framework for writing stateful, long-running workflows (orchestrations) using a familiar, code-first approach. It abstracts the complexities of checkpointing, state management, and reliable messaging.

01

Orchestrator Functions

The central controller of a workflow. An orchestrator function defines the sequence and logic for executing activity functions and other sub-orchestrations. Its key characteristic is deterministic execution: the orchestrator code must produce the same result when replayed, which Durable Functions enables by using event sourcing to track history and manage replay automatically.

  • Checkpointing & Replay: The runtime periodically checkpoints the orchestrator's state. If the host fails, a new instance replays the history to rebuild the current state, ensuring durability.
  • Durable Context: Provides APIs (IDurableOrchestrationContext) for scheduling activities, creating timers, waiting for external events, and managing sub-orchestrations.
02

Activity Functions

The stateless, executable units of work within an orchestration. Activity functions contain the actual business logic that performs tasks like calling a database, processing a file, or invoking an external API. They are designed to be idempotent where possible, as the orchestration engine may retry them in case of failure.

  • Execution Guarantees: Activities are executed at least once. The orchestrator manages retries with configurable policies (e.g., exponential backoff).
  • Input/Output: Receive input from and return output to the orchestrator. Their execution is tracked as part of the orchestration's event history.
03

Durable Timers

A mechanism for creating delayed execution or implementing timeouts within an orchestration without blocking a thread. Created using context.CreateTimer(), durable timers are resilient to process recycling. The orchestrator function suspends and automatically resumes when the timer expires, with the state fully preserved.

  • Use Cases: Implementing human approval timeouts, delaying retry attempts, scheduling future work, or polling an external system with a delay.
  • Persistence: Timer schedules are durably stored, ensuring they fire even if the entire app scales to zero and restarts.
04

External Events

A pattern that allows an orchestration to pause and wait for asynchronous input from outside the workflow. The orchestrator uses context.WaitForExternalEvent() to listen for a named event. An external client (e.g., a human via a webhook, another system) can then raise this event to the specific orchestration instance, providing the necessary data to proceed.

  • Human-in-the-Loop: Essential for workflows requiring manual approval or review.
  • Async Callbacks: Enables orchestrations to interact with systems that use webhook or callback-based APIs.
05

Sub-Orchestrations

An orchestrator function can call another orchestrator function as a sub-orchestration. This enables modular, hierarchical workflow design, breaking complex processes into reusable, manageable components. The parent orchestrator manages the sub-orchestration's lifecycle, including its input, output, and error handling.

  • Modularity & Reuse: Encapsulate common workflow patterns into reusable sub-orchestrations.
  • Scalability: Sub-orchestrations can be distributed across multiple workers. The parent can fan-out to execute many sub-orchestrations in parallel and fan-in the results.
06

Eternal Orchestrations

An orchestration that runs indefinitely by design, typically using a perpetual loop. Eternal orchestrations are useful for monitoring, aggregation, or agent-like continuous processing. They are made durable by the framework's checkpointing and can be gracefully terminated via an external event.

  • Pattern: while (true) { await context.CallActivityAsync(...); await context.CreateTimer(...); }
  • Management: Can be started via a client binding and stopped by raising a termination event. The runtime manages their state across indefinite executions and host restarts.
SERVERLESS ORCHESTRATION

How Durable Functions Work: The Orchestrator Pattern

Durable Functions is an extension of Azure Functions that enables the creation of stateful, long-running workflows in a serverless environment using the orchestrator pattern.

A Durable Function is a serverless orchestration framework on Azure that allows developers to write stateful workflows in a serverless environment. It is built on the orchestrator pattern, where a central, durable orchestrator function manages the execution sequence and state of a series of activity functions. This pattern provides automatic checkpointing and replay, ensuring workflow resilience and exactly-once execution semantics even in the face of server restarts or transient failures.

The orchestrator function's logic is written as deterministic code, which the Durable Task Framework replays from checkpoints to rebuild local state after an interruption. This allows it to manage complex patterns like function chaining, fan-out/fan-in, and human interaction without losing progress. By handling state durability and message coordination, it abstracts away the complexities of distributed systems, enabling developers to focus on business logic while the platform guarantees reliable, long-running execution.

ORCHESTRATION LAYER DESIGN

Frequently Asked Questions

Common questions about Durable Functions, a serverless orchestration framework for building resilient, stateful workflows on Azure.

A Durable Function is an extension of Azure Functions that enables writing stateful, long-running workflows in a serverless environment. It works by abstracting away the complexity of checkpointing and replay through a orchestrator function pattern. The framework automatically manages state persistence, allowing the orchestrator code to be written as if it were executing continuously, while behind the scenes it is broken into discrete execution steps. When an orchestrator function "awaits" an activity, its state is serialized to durable storage (like Azure Storage or Netherite). Upon the activity's completion, the orchestrator is rehydrated from the last checkpoint and replays its logic to determine the next step, ensuring deterministic execution despite server restarts or failures.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.