SlideShare a Scribd company logo
Paco de la Cruz
Durable Functions
Serverless and Stateful Orchestrations on Azure
@pacodelacruz
Global Azure Bootcamp 2019, Melbourne
@pacodelacruz
linkedin.com/in/pacodelacruz
pacodelacruzag.wordpress.com
slideshare.net/pacodelac/presentations
Agenda
Durable
Cloud compute spectrum
Azure compute spectrum
Azure compute spectrum
“Serverless” and its benefits
Event-driven scaling
not resource-driven
Pay only for what
you use
Server abstraction
Focus on value
Azure Functions in a nutshell
Event Triggers Code Outputs
React and get inputs from
a growing list of services
(triggers and input
bindings)
C#, F#,
Node.js, Java,
Python (Preview)
Send results to a
growing list of services
(output bindings)
Some limitations/challenges of Azure Functions
Manageable Sequencing
+ Error Handling / Compensation
Manageable Sequencing
+ Error Handling / Compensation
Some limitations/challenges of Azure Functions
Fanning-out & Fanning-in
Some limitations/challenges of Azure Functions
Manageable Sequencing
+ Error Handling / Compensation
Fanning-out & Fanning-in
Async Long-Running Http APIs
(Status polling)
Start
Get Status
Some limitations/challenges of Azure Functions
Manageable Sequencing
+ Error Handling / Compensation
Fanning-out & Fanning-in Async Long-Running Http APIs
(Status polling)
Start
Get Status
Long-Running Stateful
Repeating Process
Some limitations/challenges of Azure Functions
Manageable Sequencing
+ Error Handling / Compensation
Fanning-out & Fanning-in
Long-Running Stateful
Repeating Process
Async Long-Running Http APIs
(Status polling)
Start
Get Status
Human Interaction
Some limitations/challenges of Azure Functions
Manageable Sequencing
+ Error Handling / Compensation
Fanning-out & Fanning-in
Human InteractionLong-Running Stateful
Repeating Process
Async Long-Running Http APIs
(Status polling)
Start
Get Status
External Events Correlation
Some limitations/challenges of Azure Functions
Manageable Sequencing
+ Error Handling / Compensation
Fanning-out & Fanning-in
Human InteractionLong-Running Stateful
Repeating Process
Async Long-Running Http APIs
(Status polling)
Start
Get Status
External Events Correlation
Durable Function Patterns
Function Chaining Fanning-out & Fanning-in Async HTTP APIs
Human InteractionMonitoring External Events Correlation
Start
Get Status
Durable Functions in a nutshell
Based on
Durable Task Framework
Persistence on Azure Storage
(Fully Managed and Abstracted)
To Implement stateful
workflows-as-code
(C#, F#, Java and Node.js)
Azure Functions
Extension
Durable Functions Components
Activity Function Activity Function Activity Function
Orchestrator Function
Orchestration Client
Durable Functions Components
Activity Function Activity Function Activity Function
Orchestrator Function
Orchestration Client
Stateful
Process Manager
Call Activity Functions
Advanced Retries
Error Handling
Fall Back / Compensation
Checkpointing
Dehydrates during activities
Rehydrates at responses / events
Durable Functions Components
Activity Function Activity Function Activity Function
Orchestrator Function
Orchestration Client
Stateless
Single Step
Inputs and Outputs
Stateful
Process Manager
Call Activity Functions
Advanced Retries
Error Handling
Fall Back / Compensation
Checkpointing
Dehydrates during activities
Rehydrates at responses / events
Durable Functions Components
Activity Function Activity Function Activity Function
Orchestrator Function
Orchestration Client
Start
Get Status
Send Event
Wait for Completion
Terminate
Stateless
Single Step
Inputs and Outputs
Stateful
Process Manager
Call Activity Functions
Advanced Retries
Error Handling
Fall Back / Compensation
Checkpointing
Dehydrates during activities
Rehydrates at responses / events
Orchestration Function Limitations
Orchestration code must
• Be deterministic
(e.g. no NewGuid(), Random, DateTime.Now(), Http calls, etc.)
• Be non-blocking: (no I/O, Thread.Sleep(), etc.)
• Never initiate any async operations: without using its
context
• Avoid infinite loops
There are workarounds
Orchestration Considerations
Activity function calls and responses are sent via queues
Async calls persist the orchestration state into a storage table
Activity function outputs are persisted (Event Sourcing)
Activity function responses, timer or external events will recover
the persisted orchestration state into memory
The orchestration is replayed up-to the last persisted point
Activity Functions are not replayed
Function Chaining Pattern
public static async Task<object> Run(
[OrchestrationTrigger] DurableOrchestrationContext ctx)
{
try
{
var x = await ctx.CallActivityAsync<object>("F1");
var y = await ctx.CallActivityAsync<object>("F2", x);
return await ctx.CallActivityAsync<object>("F3", y);
}
catch (Exception ex)
{
// error handling / fall back / compensation
}
}
Function Chaining Pattern
public static async Task<object> Run(
[OrchestrationTrigger] DurableOrchestrationContext ctx)
{
try
{
var x = await ctx.CallActivityAsync<object>("F1");
var y = await ctx.CallActivityAsync<object>("F2", x);
return await ctx.CallActivityAsync<object>("F3", y);
}
catch (Exception ex)
{
// error handling / fall back / compensation
}
}
Function Chaining Pattern
public static async Task<object> Run(
[OrchestrationTrigger] DurableOrchestrationContext ctx)
{
try
{
var x = await ctx.CallActivityAsync<object>("F1");
var y = await ctx.CallActivityAsync<object>("F2", x);
return await ctx.CallActivityAsync<object>("F3", y);
}
catch (Exception ex)
{
// error handling / fall back / compensation
}
}
Fan-out & Fan-In Pattern
public static async Task<int> Run(
[OrchestrationTrigger] DurableOrchestrationContext ctx)
{
object[] workBatch = await ctx.CallActivityAsync<object[]>("F1");
var tasks = new Task<long>[workBatch.Length];
for (int i = 0; i < workBatch.Length; i++)
{
tasks[i] = ctx.CallActivityAsync<int>("F2", workBatch[i]);
}
await Task.WhenAll(tasks);
long sum = tasks.Sum(t => t.Result);
return sum;
}
Fan-out & Fan-In Pattern
public static async Task<int> Run(
[OrchestrationTrigger] DurableOrchestrationContext ctx)
{
object[] workBatch = await ctx.CallActivityAsync<object[]>("F1");
var tasks = new Task<long>[workBatch.Length];
for (int i = 0; i < workBatch.Length; i++)
{
tasks[i] = ctx.CallActivityAsync<int>("F2", workBatch[i]);
}
await Task.WhenAll(tasks);
long sum = tasks.Sum(t => t.Result);
return sum;
}
CallActivityWithRetryAsync
Orchestration Client
public static async Task<HttpResponseMessage> Run(
[HttpTrigger(AuthorizationLevel.Function, methods: "post",
Route = "orchestrators/{functionName}")] HttpRequestMessage req,
[OrchestrationClient] DurableOrchestrationClientBase starter, ILogger log)
{
// Function input comes from the request content.
dynamic eventData = await req.Content.ReadAsAsync<object>();
string instanceId = await starter.StartNewAsync("myOrchestrator", eventData);
log.LogInformation($"Started orchestration with ID = '{instanceId}'.");
var res = starter.CreateCheckStatusResponse(req, instanceId);
return res;
}
Orchestration Client
public static async Task<HttpResponseMessage> Run(
[HttpTrigger(AuthorizationLevel.Function, methods: "post",
Route = "orchestrators/{functionName}")] HttpRequestMessage req,
[OrchestrationClient] DurableOrchestrationClientBase starter, ILogger log)
{
// Function input comes from the request content.
dynamic eventData = await req.Content.ReadAsAsync<object>();
string instanceId = await starter.StartNewAsync("myOrchestrator", eventData);
log.LogInformation($"Started orchestration with ID = '{instanceId}'.");
var res = starter.CreateCheckStatusResponse(req, instanceId);
return res;
}
Orchestration Client
public static async Task<HttpResponseMessage> Run(
[HttpTrigger(AuthorizationLevel.Function, methods: "post",
Route = "orchestrators/{functionName}")] HttpRequestMessage req,
[OrchestrationClient] DurableOrchestrationClientBase starter, ILogger log)
{
// Function input comes from the request content.
dynamic eventData = await req.Content.ReadAsAsync<object>();
string instanceId = await starter.StartNewAsync("myOrchestrator", eventData);
log.LogInformation($"Started orchestration with ID = '{instanceId}'.");
var res = starter.CreateCheckStatusResponse(req, instanceId);
return res;
}
Durable Functions vs Logic Apps?
vs
Durable Functions Logic Apps
Both allow implementing advanced workflow patterns
C#, F#, Java, JavaScript Visual designer and WDL
Bindings (~ 20 supported) 250+ connectors
Portable Runtime Runs only on Azure
Monitoring based on App Insights & APIs Rich monitoring & management tools
Serverless + dedicated & isolated Serverless + dedicated & isolated (ISE)
platform.deloitte.com.au/articles/azure-durable-functions-vs-logic-apps
Additional Resources
Twitter @azurefunctions
Documentation aka.ms/durablefunctions
Live Web Cast aka.ms/azurefunctionslive
Repos github.com/Azure/azure-functions-durable-extension
github.com/Azure/azure-functions-durable-js
Samples github.com/Azure/azure-functions-durable-
extension/tree/master/samples
Pluralsight course app.pluralsight.com/library/courses/
azure-durable-functions-fundamentals
Any questions so far?
Let’s have
some fun!
Demo 1
Development and Debugging
Furry Models
Cat Application Approval via email
Orchestration
Function
Start
Send Approval
Request via Email
Create Timer
External
Event
Timer
Expires
WhenAny
Move Blob to
Corresponding Container
End
(Requests
blob container)
(Approved or Rejected
blob container)
Orchestration
Function
Start
Send Approval
Request via Email
Create Timer
External
Event
Timer
Expires
WhenAny
Move Blob to
Corresponding Container
End
BlobTrigger
Function
HttpTrigger
Process Approval
(Requests
blob container)
(Approved or Rejected
blob container)
Orchestration Client Activity Functions
ActivityTrigger
Send Approval
Request via Email
ActivityTrigger
Move Blob to
Corresponding Container
HttpTrigger
Check Status
Demo 2
Execution & Monitoring on Azure
Furry Models
Cat Application Approval via Slack
Orchestration
Function
Start
Send Approval
Request via Slack
Create Timer
External
Event
Timer
Expires
WhenAny
Move Blob to
Corresponding Container
End
BlobTrigger
Function
HttpTrigger
Process Approval
(Requests
blob container)
(Approved or Rejected
blob container)
Orchestration Client Activity Functions
ActivityTrigger
Send Approval
Request via Slack
ActivityTrigger
Move Blob to
Corresponding Container
HttpTrigger
Check Status
Let your Cat apply!
Great opportunity to get famous!
Send to: …@...com
Subject: I want to be a Furry Model!
Attach your cat best picture
Details about the demos:
platform.deloitte.com.au/articles/azure-durable-functions-approval-workflow-with-sendgrid
platform.deloitte.com.au/articles/azure-durable-functions-approval-workflow-with-slack
github.com/pacodelacruz/durable-functions-furry-models
Q & A
Thanks!
@pacodelacruz
linkedin.com/in/pacodelacruz
pacodelacruzag.wordpress.com
slideshare.net/pacodelac/presentations

More Related Content

PDF
Azure Durable Functions (2019-03-30)
PDF
Durable functions 2.0 (2019-10-10)
PPTX
Durable functions
PDF
Serverless APIs, the Good, the Bad and the Ugly (2019-09-19)
PDF
Azure Durable Functions (2018-06-13)
PPTX
Azure Durable Functions
PPTX
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
PPTX
Firebase ng2 zurich
Azure Durable Functions (2019-03-30)
Durable functions 2.0 (2019-10-10)
Durable functions
Serverless APIs, the Good, the Bad and the Ugly (2019-09-19)
Azure Durable Functions (2018-06-13)
Azure Durable Functions
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
Firebase ng2 zurich

What's hot (20)

PDF
JavaOne 2013: Java 8 - The Good Parts
PPTX
Typescript barcelona
PPTX
Reactive Programming in Java 8 with Rx-Java
PPTX
Vertx - Reactive & Distributed
PDF
Java9 Beyond Modularity - Java 9 más allá de la modularidad
PDF
End to end todo list app with NestJs - Angular - Redux & Redux Saga
PPTX
Parse Advanced
PPTX
Full Stack Unit Testing
PPTX
Beyond Profilers: Tracing Node.js Transactions
PDF
Sane Sharding with Akka Cluster
PDF
Nestjs MasterClass Slides
PDF
Full-Stack Reactive with Spring WebFlux + Angular - Oracle Code One 2018
PDF
Kogito: cloud native business automation
PDF
Introduction to Retrofit and RxJava
PPT
Biz Talk Demo slideshare
PDF
Retrofit
DOCX
Client server part 12
PDF
Protocol-Oriented Networking
PPTX
Why You Should Use TAPIs
PDF
Full-Stack Reativo com Spring WebFlux + Angular - FiqueEmCasaConf
JavaOne 2013: Java 8 - The Good Parts
Typescript barcelona
Reactive Programming in Java 8 with Rx-Java
Vertx - Reactive & Distributed
Java9 Beyond Modularity - Java 9 más allá de la modularidad
End to end todo list app with NestJs - Angular - Redux & Redux Saga
Parse Advanced
Full Stack Unit Testing
Beyond Profilers: Tracing Node.js Transactions
Sane Sharding with Akka Cluster
Nestjs MasterClass Slides
Full-Stack Reactive with Spring WebFlux + Angular - Oracle Code One 2018
Kogito: cloud native business automation
Introduction to Retrofit and RxJava
Biz Talk Demo slideshare
Retrofit
Client server part 12
Protocol-Oriented Networking
Why You Should Use TAPIs
Full-Stack Reativo com Spring WebFlux + Angular - FiqueEmCasaConf
Ad

Similar to Azure Durable Functions (2019-04-27) (20)

PPTX
[NDC 2019] Enterprise-Grade Serverless
PDF
Architecting Alive Apps
PPTX
Building workflow solution with Microsoft Azure and Cloud | Integration Monday
PPT
Intoduction to Play Framework
PDF
Integration-Monday-Stateful-Programming-Models-Serverless-Functions
PPTX
Intro to Node
PDF
Working with data using Azure Functions.pdf
PPTX
ADF Gold Nuggets (Oracle Open World 2011)
PDF
Inversion Of Control
PPTX
Reactive programming every day
PPTX
Avoiding Callback Hell with Async.js
PPTX
How to perform debounce in react
PPTX
spring aop.pptxfgfdgfdgfdgfdgfdgvbvcbvbcvbdf
PDF
Event Sourcing - what could go wrong - Devoxx BE
PPTX
Durable Functions
PDF
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
PDF
Struts2 - 101
PDF
Spring Web Services: SOAP vs. REST
PPTX
spring aop.pptx aspt oreinted programmin
PDF
Building Scalable Stateless Applications with RxJava
[NDC 2019] Enterprise-Grade Serverless
Architecting Alive Apps
Building workflow solution with Microsoft Azure and Cloud | Integration Monday
Intoduction to Play Framework
Integration-Monday-Stateful-Programming-Models-Serverless-Functions
Intro to Node
Working with data using Azure Functions.pdf
ADF Gold Nuggets (Oracle Open World 2011)
Inversion Of Control
Reactive programming every day
Avoiding Callback Hell with Async.js
How to perform debounce in react
spring aop.pptxfgfdgfdgfdgfdgfdgvbvcbvbcvbdf
Event Sourcing - what could go wrong - Devoxx BE
Durable Functions
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Struts2 - 101
Spring Web Services: SOAP vs. REST
spring aop.pptx aspt oreinted programmin
Building Scalable Stateless Applications with RxJava
Ad

More from Paco de la Cruz (12)

PDF
Harnessing GenAI in APIs the Good the Bad and the Ugly
PDF
Extending your Azure Integration Solutions with Open AI - Logic App Aviators
PDF
Extending your Azure Integration Services Solutions with Open AI
PDF
Mi experiencia en AU IT.pdf
PDF
Custom Distributed Tracing in Azure Functions (2021-02-27)
PDF
Serverless: The Good, the Bad and the Ugly (2019-11-19)
PDF
Azure Event Grid Lighting Talk (2017-10-05)
PDF
Building Serverless Event-Driven Apps with Azure Event Grid (2017-09-21)
PDF
Logic Apps and Azure Functions for Serverless Integration (2017-03-25)
PDF
Microsoft Azure iPaaS Overview and What's New (2018-03-24)
PDF
Building Serverless Integration Solutions with Logic Apps (2017-04-22)
PDF
Love at First Sight with Azure Logic Apps (2017-06-22)
Harnessing GenAI in APIs the Good the Bad and the Ugly
Extending your Azure Integration Solutions with Open AI - Logic App Aviators
Extending your Azure Integration Services Solutions with Open AI
Mi experiencia en AU IT.pdf
Custom Distributed Tracing in Azure Functions (2021-02-27)
Serverless: The Good, the Bad and the Ugly (2019-11-19)
Azure Event Grid Lighting Talk (2017-10-05)
Building Serverless Event-Driven Apps with Azure Event Grid (2017-09-21)
Logic Apps and Azure Functions for Serverless Integration (2017-03-25)
Microsoft Azure iPaaS Overview and What's New (2018-03-24)
Building Serverless Integration Solutions with Logic Apps (2017-04-22)
Love at First Sight with Azure Logic Apps (2017-06-22)

Recently uploaded (20)

PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
Transform Your Business with a Software ERP System
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PPTX
Introduction to Artificial Intelligence
PPTX
ISO 45001 Occupational Health and Safety Management System
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PDF
Understanding Forklifts - TECH EHS Solution
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
System and Network Administration Chapter 2
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PPT
Introduction Database Management System for Course Database
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Transform Your Business with a Software ERP System
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Introduction to Artificial Intelligence
ISO 45001 Occupational Health and Safety Management System
ManageIQ - Sprint 268 Review - Slide Deck
Understanding Forklifts - TECH EHS Solution
How Creative Agencies Leverage Project Management Software.pdf
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
System and Network Administration Chapter 2
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Which alternative to Crystal Reports is best for small or large businesses.pdf
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Design an Analysis of Algorithms II-SECS-1021-03
Navsoft: AI-Powered Business Solutions & Custom Software Development
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Introduction Database Management System for Course Database
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf

Azure Durable Functions (2019-04-27)

  • 1. Paco de la Cruz Durable Functions Serverless and Stateful Orchestrations on Azure @pacodelacruz Global Azure Bootcamp 2019, Melbourne
  • 7. “Serverless” and its benefits Event-driven scaling not resource-driven Pay only for what you use Server abstraction Focus on value
  • 8. Azure Functions in a nutshell Event Triggers Code Outputs React and get inputs from a growing list of services (triggers and input bindings) C#, F#, Node.js, Java, Python (Preview) Send results to a growing list of services (output bindings)
  • 9. Some limitations/challenges of Azure Functions Manageable Sequencing + Error Handling / Compensation
  • 10. Manageable Sequencing + Error Handling / Compensation Some limitations/challenges of Azure Functions Fanning-out & Fanning-in
  • 11. Some limitations/challenges of Azure Functions Manageable Sequencing + Error Handling / Compensation Fanning-out & Fanning-in Async Long-Running Http APIs (Status polling) Start Get Status
  • 12. Some limitations/challenges of Azure Functions Manageable Sequencing + Error Handling / Compensation Fanning-out & Fanning-in Async Long-Running Http APIs (Status polling) Start Get Status Long-Running Stateful Repeating Process
  • 13. Some limitations/challenges of Azure Functions Manageable Sequencing + Error Handling / Compensation Fanning-out & Fanning-in Long-Running Stateful Repeating Process Async Long-Running Http APIs (Status polling) Start Get Status Human Interaction
  • 14. Some limitations/challenges of Azure Functions Manageable Sequencing + Error Handling / Compensation Fanning-out & Fanning-in Human InteractionLong-Running Stateful Repeating Process Async Long-Running Http APIs (Status polling) Start Get Status External Events Correlation
  • 15. Some limitations/challenges of Azure Functions Manageable Sequencing + Error Handling / Compensation Fanning-out & Fanning-in Human InteractionLong-Running Stateful Repeating Process Async Long-Running Http APIs (Status polling) Start Get Status External Events Correlation
  • 16. Durable Function Patterns Function Chaining Fanning-out & Fanning-in Async HTTP APIs Human InteractionMonitoring External Events Correlation Start Get Status
  • 17. Durable Functions in a nutshell Based on Durable Task Framework Persistence on Azure Storage (Fully Managed and Abstracted) To Implement stateful workflows-as-code (C#, F#, Java and Node.js) Azure Functions Extension
  • 18. Durable Functions Components Activity Function Activity Function Activity Function Orchestrator Function Orchestration Client
  • 19. Durable Functions Components Activity Function Activity Function Activity Function Orchestrator Function Orchestration Client Stateful Process Manager Call Activity Functions Advanced Retries Error Handling Fall Back / Compensation Checkpointing Dehydrates during activities Rehydrates at responses / events
  • 20. Durable Functions Components Activity Function Activity Function Activity Function Orchestrator Function Orchestration Client Stateless Single Step Inputs and Outputs Stateful Process Manager Call Activity Functions Advanced Retries Error Handling Fall Back / Compensation Checkpointing Dehydrates during activities Rehydrates at responses / events
  • 21. Durable Functions Components Activity Function Activity Function Activity Function Orchestrator Function Orchestration Client Start Get Status Send Event Wait for Completion Terminate Stateless Single Step Inputs and Outputs Stateful Process Manager Call Activity Functions Advanced Retries Error Handling Fall Back / Compensation Checkpointing Dehydrates during activities Rehydrates at responses / events
  • 22. Orchestration Function Limitations Orchestration code must • Be deterministic (e.g. no NewGuid(), Random, DateTime.Now(), Http calls, etc.) • Be non-blocking: (no I/O, Thread.Sleep(), etc.) • Never initiate any async operations: without using its context • Avoid infinite loops There are workarounds
  • 23. Orchestration Considerations Activity function calls and responses are sent via queues Async calls persist the orchestration state into a storage table Activity function outputs are persisted (Event Sourcing) Activity function responses, timer or external events will recover the persisted orchestration state into memory The orchestration is replayed up-to the last persisted point Activity Functions are not replayed
  • 24. Function Chaining Pattern public static async Task<object> Run( [OrchestrationTrigger] DurableOrchestrationContext ctx) { try { var x = await ctx.CallActivityAsync<object>("F1"); var y = await ctx.CallActivityAsync<object>("F2", x); return await ctx.CallActivityAsync<object>("F3", y); } catch (Exception ex) { // error handling / fall back / compensation } }
  • 25. Function Chaining Pattern public static async Task<object> Run( [OrchestrationTrigger] DurableOrchestrationContext ctx) { try { var x = await ctx.CallActivityAsync<object>("F1"); var y = await ctx.CallActivityAsync<object>("F2", x); return await ctx.CallActivityAsync<object>("F3", y); } catch (Exception ex) { // error handling / fall back / compensation } }
  • 26. Function Chaining Pattern public static async Task<object> Run( [OrchestrationTrigger] DurableOrchestrationContext ctx) { try { var x = await ctx.CallActivityAsync<object>("F1"); var y = await ctx.CallActivityAsync<object>("F2", x); return await ctx.CallActivityAsync<object>("F3", y); } catch (Exception ex) { // error handling / fall back / compensation } }
  • 27. Fan-out & Fan-In Pattern public static async Task<int> Run( [OrchestrationTrigger] DurableOrchestrationContext ctx) { object[] workBatch = await ctx.CallActivityAsync<object[]>("F1"); var tasks = new Task<long>[workBatch.Length]; for (int i = 0; i < workBatch.Length; i++) { tasks[i] = ctx.CallActivityAsync<int>("F2", workBatch[i]); } await Task.WhenAll(tasks); long sum = tasks.Sum(t => t.Result); return sum; }
  • 28. Fan-out & Fan-In Pattern public static async Task<int> Run( [OrchestrationTrigger] DurableOrchestrationContext ctx) { object[] workBatch = await ctx.CallActivityAsync<object[]>("F1"); var tasks = new Task<long>[workBatch.Length]; for (int i = 0; i < workBatch.Length; i++) { tasks[i] = ctx.CallActivityAsync<int>("F2", workBatch[i]); } await Task.WhenAll(tasks); long sum = tasks.Sum(t => t.Result); return sum; } CallActivityWithRetryAsync
  • 29. Orchestration Client public static async Task<HttpResponseMessage> Run( [HttpTrigger(AuthorizationLevel.Function, methods: "post", Route = "orchestrators/{functionName}")] HttpRequestMessage req, [OrchestrationClient] DurableOrchestrationClientBase starter, ILogger log) { // Function input comes from the request content. dynamic eventData = await req.Content.ReadAsAsync<object>(); string instanceId = await starter.StartNewAsync("myOrchestrator", eventData); log.LogInformation($"Started orchestration with ID = '{instanceId}'."); var res = starter.CreateCheckStatusResponse(req, instanceId); return res; }
  • 30. Orchestration Client public static async Task<HttpResponseMessage> Run( [HttpTrigger(AuthorizationLevel.Function, methods: "post", Route = "orchestrators/{functionName}")] HttpRequestMessage req, [OrchestrationClient] DurableOrchestrationClientBase starter, ILogger log) { // Function input comes from the request content. dynamic eventData = await req.Content.ReadAsAsync<object>(); string instanceId = await starter.StartNewAsync("myOrchestrator", eventData); log.LogInformation($"Started orchestration with ID = '{instanceId}'."); var res = starter.CreateCheckStatusResponse(req, instanceId); return res; }
  • 31. Orchestration Client public static async Task<HttpResponseMessage> Run( [HttpTrigger(AuthorizationLevel.Function, methods: "post", Route = "orchestrators/{functionName}")] HttpRequestMessage req, [OrchestrationClient] DurableOrchestrationClientBase starter, ILogger log) { // Function input comes from the request content. dynamic eventData = await req.Content.ReadAsAsync<object>(); string instanceId = await starter.StartNewAsync("myOrchestrator", eventData); log.LogInformation($"Started orchestration with ID = '{instanceId}'."); var res = starter.CreateCheckStatusResponse(req, instanceId); return res; }
  • 32. Durable Functions vs Logic Apps? vs Durable Functions Logic Apps Both allow implementing advanced workflow patterns C#, F#, Java, JavaScript Visual designer and WDL Bindings (~ 20 supported) 250+ connectors Portable Runtime Runs only on Azure Monitoring based on App Insights & APIs Rich monitoring & management tools Serverless + dedicated & isolated Serverless + dedicated & isolated (ISE) platform.deloitte.com.au/articles/azure-durable-functions-vs-logic-apps
  • 33. Additional Resources Twitter @azurefunctions Documentation aka.ms/durablefunctions Live Web Cast aka.ms/azurefunctionslive Repos github.com/Azure/azure-functions-durable-extension github.com/Azure/azure-functions-durable-js Samples github.com/Azure/azure-functions-durable- extension/tree/master/samples Pluralsight course app.pluralsight.com/library/courses/ azure-durable-functions-fundamentals
  • 36. Demo 1 Development and Debugging Furry Models Cat Application Approval via email
  • 37. Orchestration Function Start Send Approval Request via Email Create Timer External Event Timer Expires WhenAny Move Blob to Corresponding Container End (Requests blob container) (Approved or Rejected blob container)
  • 38. Orchestration Function Start Send Approval Request via Email Create Timer External Event Timer Expires WhenAny Move Blob to Corresponding Container End BlobTrigger Function HttpTrigger Process Approval (Requests blob container) (Approved or Rejected blob container) Orchestration Client Activity Functions ActivityTrigger Send Approval Request via Email ActivityTrigger Move Blob to Corresponding Container HttpTrigger Check Status
  • 39. Demo 2 Execution & Monitoring on Azure Furry Models Cat Application Approval via Slack
  • 40. Orchestration Function Start Send Approval Request via Slack Create Timer External Event Timer Expires WhenAny Move Blob to Corresponding Container End BlobTrigger Function HttpTrigger Process Approval (Requests blob container) (Approved or Rejected blob container) Orchestration Client Activity Functions ActivityTrigger Send Approval Request via Slack ActivityTrigger Move Blob to Corresponding Container HttpTrigger Check Status
  • 41. Let your Cat apply! Great opportunity to get famous! Send to: …@...com Subject: I want to be a Furry Model! Attach your cat best picture
  • 42. Details about the demos: platform.deloitte.com.au/articles/azure-durable-functions-approval-workflow-with-sendgrid platform.deloitte.com.au/articles/azure-durable-functions-approval-workflow-with-slack github.com/pacodelacruz/durable-functions-furry-models
  • 43. Q & A