The document discusses Azure Durable Functions, which simplify complex, stateful coordination problems in serverless applications. Durable Functions run inside the Azure Functions runtime and maintain execution state using event sourcing. They support features like orchestrator functions that can call other orchestrators, durable timers to implement delays, and coordinating orchestrations across function apps. The document provides examples of using Durable Functions for real-world scenarios like order management.
Designing IA for AI - Information Architecture Conference 2024
Workflow as code with Azure Durable Functions
1. Workflow as code with
Azure Durable Functions
Massimo Bonanni
Paranormal Developer, with the head in the Cloud and all the REST in microservices!!
Rome | March 22 - 23, 2019
4. What are Durable Functions?
Simplifying complex, stateful coordination problems
in serverless applications.
5. What are Durable Functions?
Run inside the Azure Functions Runtime
Are built on top of the Durable Task Framework
Maintain their execution state using a design pattern known
as Event Sourcing
Written in C#, F# and JavaScript – No JSON, No Designer!!!
Use Azure Storage queues, tables, and blobs to persist
execution history state and trigger function execution
6. Features and patterns
Orchestrator functions can call other orchestrator
functions.
Sub-Orchestration
Durable timers can use in orchestrator functions to
implement delays or to set up timeouts on async
actions.
Durable Timers
Orchestrator functions can wait for external events to
update an orchestration instance.
External Events
Can coordinate orchestrations across many function
apps maintaining a durable process across two apps.
Cross-function app
communication
7. Is the triggered
functions that will
create new
instances of an
orchestration.
It is the entry point
for creating an
instance of a
durable
orchestration
Is the heart of a
durable function.
Orchestrator
functions describe
the way and order
actions are
executed
Is the basic unit of
work in a durable
orchestration.
An activity function
must be triggered
by an activity
trigger
Types of functions
8. Orchestration client
The orchestrator client can:
• Starts a orchestrator function (StartAsync).
• Queries an orchestrator function status (GetStatusAsync).
• Terminates an orchestrator function (TerminateAsync).
• Sends events to an orchestrator function while it is running
(RaiseEventAsync)
9. Orchestration triggers
The orchestration trigger:
• Enables you to author durable orchestrator
• Supports starting new orchestrator function instances
• Resuming existing orchestrator function instances that are
"awaiting" a task.
Internally this trigger binding a set of queues in the
default storage account for the function app.
10. Activity triggers
The orchestration trigger:
• Author functions that are called by orchestrator
functions.
Internally this trigger binding a set of queues in the
default storage account for the function app.
11. Orchestration history
At each await statement, the Durable Task
Framework checkpoints the execution state of
the function into table storage.
This state is what is referred to as the
orchestration history.
Enqueues messages for the orchestrator itself — for example, durable timer messages
Enqueues messages for functions the orchestrator wants to invoke
Saves execution history into Azure Storage tables
13. Orchestration history
When the activity completes its job,
the orchestrator starts again from the
begin and rebuilds its status using
event sourcing table.
14. Versioning
• If you change an activity function, you could break the
orchestrator function that depends on it.
• If you update the orchestrator function to accommodate this
change, you could break existing in-flight instances.
Changing activity function
signatures
• If you change the orchestrator logic, you confuse the replay
logic for the in-flight instances.
Changing orchestrator logic
15. Real World Scenarios - Classical
Web
Server
Web request
HTML, CSS, JS
NewOrder Webhook
Mail
QueueGenerate Invoice
Send Email
Nightly
Report
Generator
16. Real World Scenarios – Azure Functions
Web
Server
Web request
HTML, CSS, JS
Function App
Generate
Invoice
Message
Invoice File
In Blob Storage
Invoice
File
Send Email
To Customer
Nightly
Scheduled
Task
Generate
Report
NewOrder
Webhook
Message
In Queue
Order
Table
17. Real World Scenarios – Azure Durable Functions
Web
Server
Web request
HTML, CSS, JS
Nightly
Scheduled
Task
Generate
Report
NewOrder
Webhook
Invoice File
In Blob Storage
Order
Table
Send Email
To Customer
Client
Orchestrator
Activities
19. Both allow implementing advanced workflow patterns.
C#, F# and JavaScript Visual Designer
~20 Bindings 200+ Connectors
Portable runtime Runs only on Azure
Monitoring based on App Insights and
APIs
Rich monitoring and management tools
Serverless, dedicated and isolated Serverless only
Stateful Replays Queued Dependency Graph
Durable Functions vs Logic Apps