Azure Durable Functions
Jasmin George
Consultant, Cloud Analytics
M : +91 9400665658
TEKLINK INTERNATIONAL - HINDUJA GLOBAL SOLUTIONS
Agenda
1 Azure Function
2 Why can’t Azure Function maintain state?
3 Why Durable Function
4 What is Durable Function
5 Function Types
6 Application Pattern
Azure Function
To run a small piece of code without worrying about infrastructure .
Function is triggered by a specific type of event.
Scalable
Pay-per-use pricing model
Supports multiple languages
Stateless Function
Why cannot Azure Function maintain state?
Why Durable Function?
It maintains state.
What is Durable Function?
Durable Functions is an extension of Azure Functions that lets you write stateful
functions in a serverless compute environment.
Function Types
Durable Function Orchestrator looks like
import azure.functions as func
import azure.durable_functions as df
def orchestrator_function(context: df.DurableOrchestrationContext):
x = yield context.call_activity("F1", None)
y = yield context.call_activity("F2", x)
z = yield context.call_activity("F3", y)
result = yield context.call_activity("F4", z)
return result
main = df.Orchestrator.create(orchestrator_function)
Orchestration History
x = yield context.call_activity(“SayHello", “World”)
return result History Table
Orchestrator Started
Execution Started
Client Orchestrator Activity Function
Function Task Scheduled, SayHello, “World”
Orchestrator Completed
Task Completed, “Hello World”
Orchestrator Started
Execution Completed, [“Hello World]
Execution
History
Application Patterns
The coming sections describe typical application patterns that can benefit from
Durable Functions:
• Function chaining
• Fan-out/fan-in
• Async HTTP APIs
• Monitoring
• Human interaction
Function chaining
• In the function chaining pattern, a sequence of functions executes in a specific
order.
• In this pattern, the output of one function is applied to the input of another
function.
• You can include error handling logic in try/catch/finally blocks.
Fan-out/fan-in
In the fan out/fan in pattern, you execute multiple functions in parallel and then
wait for all functions to finish.
Some aggregation work is done on the results.
Monitor
The monitor pattern refers to a flexible, recurring process in a workflow.
An example is polling until specific conditions are met.
Human Interaction
• You can implement the pattern in this example by using an orchestrator function.
• The orchestrator uses a durable timer to request approval.
• The orchestrator escalates if timeout occurs.
• The orchestrator waits for an external event, such as a notification that's
generated by a human interaction.
Async HTTP APIs
• Addresses the problem of coordinating
the state of long-running operations.
• Client polls to learn when the operation
is finished.
DEMO
Your Trusted Analytics and Planning Partner