Sachith Dassanayake Software Engineering Azure Functions durable orchestrations — Crash Course — Practical Guide (May 23, 2026)

Azure Functions durable orchestrations — Crash Course — Practical Guide (May 23, 2026)

Azure Functions durable orchestrations — Crash Course — Practical Guide (May 23, 2026)

Azure Functions Durable Orchestrations — Crash Course

Azure Functions Durable Orchestrations — Crash Course

Level: Intermediate

As of May 23, 2026, using Azure Functions version 4.x with Durable Functions extension 2.x

Introduction

Azure Durable Functions extend Azure Functions with the ability to write stateful orchestrations in a serverless environment. They are ideal for coordinating complex workflows that involve multiple steps, external events, retries, long-running processes, and asynchronous patterns. Durable orchestrations use the Durable Task Framework under the hood, providing robust state management and checkpointing without requiring you to explicitly manage state persistence.

This crash course covers the practical essentials for building durable orchestrations using Azure Functions, focusing on design patterns, best practices, and common pitfalls. It serves intermediate developers comfortable with Azure Functions basics, C# or JavaScript/TypeScript, and asynchronous programming.

Prerequisites

  • Azure subscription with permission to create Function Apps, Storage accounts, and optionally Application Insights.
  • Azure Functions Core Tools 4.x installed (compatible with .NET 6+ or Node.js 18+ runtimes).
  • IDE support: Visual Studio 2022+, VS Code with Azure Functions extension, or Azure Portal.
  • Durable Functions extension version 2.x (recommended stable version as of May 2026).
  • Core familiarity with async programming (async/await in C# or Promises in JavaScript).

Hands-on Steps

1. Create the Function App and Enable Durable Functions

You can create a new function app via Azure CLI or Azure Portal. Ensure you provision a storage account as Durable Functions relies on Azure Storage for state persistence.

# Create resource group
az group create --name MyResourceGroup --location eastus

# Create storage account
az storage account create --resource-group MyResourceGroup --name mystorageacct123 --sku Standard_LRS --location eastus

# Create function app using .NET 6 runtime
az functionapp create --resource-group MyResourceGroup --consumption-plan-location eastus 
  --runtime dotnet --functions-version 4 --name myDurableApp123 --storage-account mystorageacct123

After creating your Function App, add the Durable Functions extension package for your preferred language:

// .NET example (add via NuGet)
Microsoft.Azure.Functions.Worker.Extensions.DurableTask version 2.x
// For in-process functions:
Microsoft.Azure.WebJobs.Extensions.DurableTask version 2.x

// JavaScript example in package.json dependencies
"durable-functions": "^2.10.4"

2. Define Durable Orchestration, Activity, and Client Functions

Durable orchestrations orchestrate workflows by calling activity functions which perform tasks. A client function starts the orchestration.


// Orchestration function example in C#
[Function("SampleOrchestrator")]
public async Task<string> RunOrchestrator([OrchestrationTrigger] IDurableOrchestrationContext context)
{
    var output1 = await context.CallActivityAsync<string>("Activity1", "input1");
    var output2 = await context.CallActivityAsync<string>("Activity2", output1);
    return $"Completed with results: {output2}";
}

// Activity function example
[Function("Activity1")]
public string Activity1([ActivityTrigger] string input)
{
    // Simulate work
    return $"Processed {input}";
}

[Function("Activity2")]
public string Activity2([ActivityTrigger] string input)
{
    return $"Final step with {input}";
}

// HTTP starter function (Client)
[Function("StartOrchestration")]
public async Task<HttpResponseData> StartOrchestration(
    [HttpTrigger(AuthorizationLevel.Anonymous, "post")] HttpRequestData req,
    [DurableClient] IDurableClient starter)
{
    string instanceId = await starter.StartNewAsync("SampleOrchestrator", null);
    var response = req.CreateResponse(HttpStatusCode.OK);
    response.Headers.Add("Content-Type", "application/json");
    await response.WriteStringAsync($"{{"instanceId":"{instanceId}"}}");
    return response;
}

3. Deploy and Test Locally or in Azure

Use the Azure Functions Core Tools (func CLI) for local development and debugging. When ready, deploy your function app.


# Run locally with storage emulator or Azure Storage connection string
func start

# Deploy to Azure
func azure functionapp publish myDurableApp123

Common Pitfalls

  • Non-deterministic code inside orchestrators: Orchestrator functions must be deterministic. Avoid I/O calls, random number generation, system clock reads, or mutable static variables inside orchestration code.
  • Long-running activities with timeouts: Use appropriate retry policies or external durable timers for extended waits. Activities should be idempotent for retries.
  • Improper input/output serialization: Durable Functions serialise inputs/outputs to JSON by default. Use serializable types and avoid circular references.
  • Resource limits: Orchestrator state replay and storage transactions have limits. Best practice is to minimise state size and batch operations if possible.
  • Mixing versions or preview features: Stick to stable Durable Functions extensions to avoid breaking changes or unexpected behaviours.

Validation

To validate your durable orchestration’s execution and health:

  • Use the Azure Portal’s Durable Functions monitoring tab inside your Function App.
  • Enable Application Insights for distributed tracing and telemetry on orchestration status, failures, and timings.
  • Use the IDurableClient.GetStatusAsync API or Azure Durable extension CLI commands to query orchestration state programmatically.
  • Test idempotency by replaying orchestration with the same input and verifying consistent output.
  • Implement appropriate unit and integration tests using the DurableTask Emulator or Azure Storage Emulator locally.

Checklist / TL;DR

  • Ensure Azure Function App uses runtime 4.x and Durable Functions 2.x.
  • Install and reference Durable Functions extension in your project.
  • Create three components: orchestrator, activities, and client trigger.
  • Write deterministic orchestrator code; use activities for side-effects.
  • Handle retries and long delays using built-in patterns.
  • Deploy with Azure Functions Core Tools, validate with Application Insights.
  • Avoid common pitfalls around non-determinism and state size.

When to Choose Durable Orchestrations vs Alternatives

Durable Orchestrations excel at coordinating complex stateful workflows in a serverless environment with built-in checkpointing. They are the right choice for:

  • Long-running processes that require reliable state persistence.
  • Fan-out/fan-in parallelism with coordination steps.
  • Human interaction workflows requiring external events.

Alternatives:

  • Azure Logic Apps: No-code orchestration, integrating hundreds of connectors, ideal for integrating SaaS services quickly.
  • Azure Data Factory: Best suited for data ETL and data engineering pipelines.
  • Custom orchestrations with queues and Azure Functions: More control but higher complexity and manual state management.

References

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Post