Durable functions
Basic information about durable functions
Introduction
Durable Functions is an extension of Azure
Functions and Azure WebJobs that lets you write stateful
functions in a serverless environment. The extension manages
state, checkpoints, and restarts for you.
• Basic information about durable
functions
• Demo in 5 patterns
Basic information about durable functions and demo in 5 patterns
Behind the scenes
Event Sourcing
https://www.youtube.com/watch?v=9a1PqwFrMP0
Basic information
Client
Client functions are the triggered functions that will
create new instances of an orchestration
Orchestrator
Orchestrator functions are the heart of a durable function.
Orchestrator functions describe the way and order actions
are executed.
1. StartNewAsync
2. GetStatusAsync
3. TerminateAsync
4. RaiseEventAsync
Orchestrator code contrains
• Orchestrator code must be deterministic
• Orchestrator code should be non-blocking
• Orchestrator code must never initiate any async
operation
• Infinite loops should be avoided in orchestrator
code
Basic information
Activity functions are the basic unit of work in a durable
orchestration. Activity functions are the functions and
tasks being orchestrated in the process
Demo
SUMMARY
The primary use case for Durable Functions is simplifying complex,
stateful coordination problems in serverless applications
Durable Functions is an advanced extension for Azure Functions that is
not appropriate for all applications. The rest of this article assumes that
you have a strong familiarity with Azure Functions concepts and the
challenges involved in serverless application development.
More information
References
• https://docs.microsoft.com/en-us/azure/azure-functions/durable-
functions-overview
• https://github.com/Azure/azure-functions-durable-extension
• https://www.youtube.com/watch?v=9a1PqwFrMP0
Durable functions – Q&A
Thanks for listening!

Durable functions

Editor's Notes

  • #8 1. Orchestrator code must be deterministic. It will be replayed multiple times and must produce the same result each time. For example, no direct calls to get the current date/time, get random numbers, generate random GUIDs, or call into remote endpoints. If orchestrator code needs to get the current date/time, it should use the CurrentUtcDateTime API, which is safe for replay. Non-deterministic operations must be done in activity functions. This includes any interaction with other input or output bindings. This ensures that any non-deterministic values will be generated once on the first execution and saved into the execution history. Subsequent executions will then use the saved value automatically. 2. Orchestrator code should be non-blocking. For example, that means no I/O and no calls to Thread.Sleep or equivalent APIs. If an orchestrator needs to delay, it can use the CreateTimer API. 3. Orchestrator code must never initiate any async operation except by using the DurableOrchestrationContext API. For example, no Task.Run, Task.Delay or HttpClient.SendAsync. The Durable Task Framework executes orchestrator code on a single thread and cannot interact with any other threads that could be scheduled by other async APIs. 4. Infinite loops should be avoided in orchestrator code. Because the Durable Task Framework saves execution history as the orchestration function progresses, an infinite loop could cause an orchestrator instance to run out of memory. For infinite loop scenarios, use APIs such as ContinueAsNew to restart the function execution and discard previous execution history.