Durable Functions
Amresh Krishnamurthy
◈ Technical Architect, JCPenney
◈ BDotNet Member
◈ @amreshkris
Agenda
◈ Serverless in Azure
◈ Azure Functions
◈ Sample Problem
◈ Why we need Durable Functions !
◈ What is Durable Functions !
� Activity Functions
� Orchestrator
� How does it work?
� Workflows
� Error Handling and Resiliency
� Demo
Azure Serverless Compute
◈ Serverless computing enables developers to build applications faster by eliminating the
need for them to manage infrastructure. With serverless applications, the cloud service
provider automatically provisions, scales and manages the infrastructure required to run the
code.
Event
Grid
Logic
Apps
Azure Functions
Azure Functions - FaaS
Short Lived
Each function is short
lived for its executions
and resources freed-up
after one execution
Stateless
Functions don’t
maintain state
Event-driven |
Dynamic Scaling
Functions are triggered
through events such as
Http trigger, Timer,
Event grid etc.
Pay as per you use
Pay only for the time
the function actively
runs.
Sample Business Usecase & Solution
Function Chaining
Fan out- Fan
In
Async HTTP API Monitor
Aggregato
r
Approval
Hello, Durable Functions
Orchestration of Azure Functions
Durable Functions
are extensions of
Azure Functions.
Azure Function –
Stateless Vs Durable
Function – Can retain
state
Long running
orchestrations as a
single unit.
Coordinate and
Aggregate across
multiple
functions/workflows
Code driven. No
JSON schema files or
no designer involved
Built on Durable Task
Framework and Azure
Function.
Uses Azure storage
for maintaining state.
Components
Activity Function
◈ Activity Function – Performs Activity/Unit of work. Tasks being orchestrated
Book Hotel Book Flight
Compute
Total
Components
Orchestrator Function
◈ Orchestrator Function – Described how actions are executed and the order in
which they are run.
Orchestrate :
Book Vacation
Components
Client Function
◈ Client Function – Entry point for creating an instance of Durable function.
Trigger/Event Based
Trigger : Book
Vacation
Durable Function Flow
Starter Function
Orchestrator
Function
Activity Function
Demo
◈ Durable Functions – Function Chaining
◈ Fan Out- Fan In
◈ VS Code – Azure Storage Emulator
◈ Source Code - https://github.com/amreshkris/DurableFunctions-FanOutFanIn
How Durable functions works !
◈ Pattern Used – Event Sourcing – Maintains each step of the execution in Event/History
Table
◈ ``
Orchestration
Function Called
Orchestration Started
Activity Function F1
Called
Activity Function F1
Scheduled
Execution Instance
Started
Orchestration
Completed
Activity Function F1
Completed
Activity Function F2
Called
Orchestration Started
Activity Function F2
Scheduled
Orchestration
Completed
Orchestration Started
Activity Function F2
Completed
Orchestrator Execution
Completed
Error Handling | Resiliency
◈ Demo
Orchestrator Function Constraints
◈ Must be deterministic
◈ Avoid Date and Time related API – Use ‘CurrentUtcDateTime’ provided in Durable
functions context
◈ Random Numbers , Async API , Static Variables , Infinite loops etc
theCurrentUtcDateTime
References/Links
◈ https://docs.microsoft.com/en-in/azure/azure-functions/durable/
◈ https://github.com/Azure/azure-functions-durable-extension

Durable functions

  • 1.
  • 2.
    Amresh Krishnamurthy ◈ TechnicalArchitect, JCPenney ◈ BDotNet Member ◈ @amreshkris
  • 3.
    Agenda ◈ Serverless inAzure ◈ Azure Functions ◈ Sample Problem ◈ Why we need Durable Functions ! ◈ What is Durable Functions ! � Activity Functions � Orchestrator � How does it work? � Workflows � Error Handling and Resiliency � Demo
  • 4.
    Azure Serverless Compute ◈Serverless computing enables developers to build applications faster by eliminating the need for them to manage infrastructure. With serverless applications, the cloud service provider automatically provisions, scales and manages the infrastructure required to run the code. Event Grid Logic Apps Azure Functions
  • 5.
    Azure Functions -FaaS Short Lived Each function is short lived for its executions and resources freed-up after one execution Stateless Functions don’t maintain state Event-driven | Dynamic Scaling Functions are triggered through events such as Http trigger, Timer, Event grid etc. Pay as per you use Pay only for the time the function actively runs.
  • 6.
  • 7.
    Function Chaining Fan out-Fan In Async HTTP API Monitor Aggregato r Approval
  • 8.
    Hello, Durable Functions Orchestrationof Azure Functions Durable Functions are extensions of Azure Functions. Azure Function – Stateless Vs Durable Function – Can retain state Long running orchestrations as a single unit. Coordinate and Aggregate across multiple functions/workflows Code driven. No JSON schema files or no designer involved Built on Durable Task Framework and Azure Function. Uses Azure storage for maintaining state.
  • 9.
    Components Activity Function ◈ ActivityFunction – Performs Activity/Unit of work. Tasks being orchestrated Book Hotel Book Flight Compute Total
  • 10.
    Components Orchestrator Function ◈ OrchestratorFunction – Described how actions are executed and the order in which they are run. Orchestrate : Book Vacation
  • 11.
    Components Client Function ◈ ClientFunction – Entry point for creating an instance of Durable function. Trigger/Event Based Trigger : Book Vacation
  • 12.
    Durable Function Flow StarterFunction Orchestrator Function Activity Function
  • 13.
    Demo ◈ Durable Functions– Function Chaining ◈ Fan Out- Fan In ◈ VS Code – Azure Storage Emulator ◈ Source Code - https://github.com/amreshkris/DurableFunctions-FanOutFanIn
  • 14.
    How Durable functionsworks ! ◈ Pattern Used – Event Sourcing – Maintains each step of the execution in Event/History Table ◈ `` Orchestration Function Called Orchestration Started Activity Function F1 Called Activity Function F1 Scheduled Execution Instance Started Orchestration Completed Activity Function F1 Completed Activity Function F2 Called Orchestration Started Activity Function F2 Scheduled Orchestration Completed Orchestration Started Activity Function F2 Completed Orchestrator Execution Completed
  • 15.
    Error Handling |Resiliency ◈ Demo
  • 16.
    Orchestrator Function Constraints ◈Must be deterministic ◈ Avoid Date and Time related API – Use ‘CurrentUtcDateTime’ provided in Durable functions context ◈ Random Numbers , Async API , Static Variables , Infinite loops etc theCurrentUtcDateTime
  • 17.