SlideShare a Scribd company logo
Stateful
Programming Models
in Serverless
Functions
@SteefJan
Me
Azure Technology Consultant
Microsoft MVP – Azure
InfoQ Cloud Editor
WAZUG NL board member
Azure Lowlands Organizer
Writer
Agenda
• Serverless
• Azure (Durable) Functions
• Workflows
• Actors
• Key takeaways
• Call to action
Serverless
FUNCTIONS-AS-A-SERVICE
(FAAS)
SCALABLE, EVENT-DRIVEN
PROGRAMMING MODELS
GENERALLY LOW-COST; PAY
ONLY FOR WHAT YOU USE
Azure Functions serverless programming model
Author functions in
C#, F#, JavaScript,
TypeScript, Java, Python,
PowerShell, and more
CodeEvents
React to timers, HTTP, or
events from your favorite
Azure services, with
more on the way
Outputs
Send results to an ever-
growing collection of
services
Bindings programming model
[FunctionName("QueueTriggerTableOutput")]
[return: Table("outTable")]
public static Person Create([QueueTrigger("myqueue-items")] JObject order)
{
return new Person
{
PartitionKey = "Orders",
RowKey = Guid.NewGuid().ToString(),
Name = order["Name"].ToString(),
MobileNumber = order["MobileNumber"].ToString()
};
}
Trigger binding
Output binding
“Functions must be stateless”
“Functions must not call other functions”
“Functions should do only one thing”
FaaS
principles
and best
practices?
Integration-Monday-Stateful-Programming-Models-Serverless-Functions
Stateful pattern #1: Function chaining
F1 F2 F3
Problems:
• Relationship between functions and queues is unclear.
• Operation context cannot be easily captured without a database.
• Middle queues are an implementation detail (conceptual overhead).
• Error handling adds a lot more complexity.
Declarative workflow solutions
Durable Functions
Durable Task Framework (DTFx)
Durable Functions runtime extension
Durable
storage /
messaging
Writing flexible workflows
Azure Function Extension Based up on the Durable
Task Framework – OSS
library since 2014.
Persistence on Azure
Storage
Implementation of stateful
workflow-as-code
What “chaining” could look like in code
// calls functions in sequence
public static async Task<object> Run(IDurableOrchestrationContext ctx)
{
try
{
var x = await ctx.CallActivityAsync("F1");
var y = await ctx.CallActivityAsync("F2", x);
return await ctx.CallActivityAsync("F3", y);
}
catch (Exception)
{
// error handling/compensation can go here (or anywhere)
}
}
Orchestrator Function
Activity Functions
A. Memory snapshots
B. Compiler hooks
C. Event sourcing
D. All the above
E. None of the above
How do
we
preserve
local
variable
state?
Behind the scenes
1. var x = await ctx.CallActivityAsync("F1");
2. var y = await ctx.CallActivityAsync("F2", x);
3. return await ctx.CallActivityAsync("F3", y);
Orchestrator Function
F1 => return 42;
F2 => return n + 1;
F3 => return n + 2;
Execution started
Task scheduled, F1
Task completed, F1 => 42
Task scheduled, F2
Task scheduled, F3
Task completed, F3 => 45
Orchestrator completed => 45
Task completed, F2 => 43
Orchestrator code MUST be deterministic!
• Rule #1: Never write logic that depends on random numbers, the
current date/time, etc.
• Rule #2: Never do I/O or custom thread scheduling directly in the
orchestrator function.
• Rule #3: Do not write infinite loops
• Rule #4: Use the built-in workarounds for rules #1, #2, and #3
When in doubt, use the Durable source code analyzer!
Stateful pattern #2: Fan-out & fan-in
Problems:
• Fanning-out is easy, but fanning-in is significantly more complicated
• Stateful agent is required to track progress of all work
• All the same problems of the previous pattern
Fan-out & fan-in as code
public static async Task Run(IDurableOrchestrationContext context)
{
var parallelTasks = new List<Task<int>>();
// Get a list of N work items to process in parallel.
object[] workBatch = await context.CallActivityAsync<object[]>("F1");
for (int i = 0; i < workBatch.Length; i++)
{
Task<int> task = context.CallActivityAsync<int>("F2", workBatch[i]);
parallelTasks.Add(task);
}
await Task.WhenAll(parallelTasks);
// Aggregate all N outputs and send the result to F3.
int sum = parallelTasks.Sum(t => t.Result);
await context.CallActivityAsync("F3", sum);
}
https://www.microsoft.com/en-us/microsoft-365/customer-stories/fujifilm-manufacturing-azure-ai-functions-japan
Demo!
Ingest Data
With Logic Apps you can automate a scheduled process of retrieving data and storing in a database
(SQL or NoSQL) using a graphical interface (GUI) – Visual Designer.
Convert Epoch to
DateTime
Ingest
Pull Push Pull Push
Function A
Store in Collection
Ingest Data
With Durable Functions you can automate a scheduled process of retrieving data and storing in a
database using a Integrated Development Environment – Visual Studio or Visual Code.
Orchestrator
Client
Orchestration
Function
Convert to
TimeStamp
Store In
Database
GetRates
Integration-Monday-Stateful-Programming-Models-Serverless-Functions
Integration-Monday-Stateful-Programming-Models-Serverless-Functions
Durable Function Types
Orchestrator
(Stateful)
Activity
(Stateless)
Entity
(Stateful)
New!
External / Client
(Stateless)
https://docs.microsoft.com/azure/azure-functions/durable/durable-functions-types-features-overview
Counter entity as a class (C#)
public class Counter
{
[JsonProperty]
public int value;
public void Add(int amount) => this.value += amount;
public void Reset() => this.value = 0;
public int Get() => this.value;
// Required boilerplate code
[FunctionName(nameof(Counter))]
public static Task Run([EntityTrigger] IDurableEntityContext ctx)
=> ctx.DispatchAsync<Counter>();
}
The entities concept
Message
EntityID: @Counter@Qux
Operation: add
Input: 1
Entity Class
Name: Counter
Entity
Key: Foo
State: 2
Entity
Key: Bar
State: 4
Entity
Key: Baz
State: 8
Entity
Key: Qux
State: 0
Function invocation
Context(ID: @Counter@Qux, State: 0, Operation: add, Input: 1)
Demo!
Entities are addressable via an entity ID.
Entity operations execute serially, one at a time.
Entities are created implicitly when called or
signaled.
When not executing operations, entities are
silently unloaded from memory
Similarities
with virtual
actors
Serverless!
Durability > Latency
Reliable, in-order messaging
No message timeouts
One-way messaging*
No deadlocks*
Integration with orchestrations
Differences
from other
virtual actor
frameworks
Other applications
• Serverless distributed circuit breaker
• Polly announcement: https://github.com/App-vNext/Polly/issues/687
• Example implementation: https://dev.to/azure/serverless-circuit-breakers-with-durable-entities-3l2f
• IoT device management
• Device offline detection: http://case.schollaart.net/2019/07/01/device-offline-detection-with-
durable-entities.html
• Stream analysis and alerting: https://thecloudblog.net/post/iot-edge-device-monitoring-and-
management-with-azure-durable-entities-functions-part-1/
• API cache
• https://www.aaron-powell.com/posts/2019-09-27-using-durable-entities-and-orchestrators-to-
create-an-api-cache/
• Ride sharing sample application
• https://github.com/Azure/azure-functions-durable-extension/tree/master/samples/entitites-
csharp/RideSharing
Key takeaways
MODERATE LEARNING
CURVE
DURABLE FUNCTIONS
EXCELLENT FOR
BACKEND PROCESSES
NOT A COMPETING
TECHNOLOGY OF
LOGIC APPS
OPTION IN AZURE AS
ALTERNATIVE TO
AKKA.NET OR ORLEANS
Call to action
https://aka.ms/DurableFunctions
https://aka.ms/DFGitHub
@AzureFunctions, @steefjan
@SteefJan
https://github.com/steefjan
Steef-Jan.Wiggers@codit.eu

More Related Content

What's hot (20)

PDF
Functional UIs with Java 8 and Vaadin JavaOne2014
hezamu
 
PPTX
Functional Reactive Endpoints using Spring 5
Rory Preddy
 
PDF
Redux data flow with angular 2
Gil Fink
 
PPTX
Spring batch
Deepak Kumar
 
PDF
Ngrx slides
Christoffer Noring
 
PDF
React state management with Redux and MobX
Darko Kukovec
 
PDF
Asyc flow control with javascript generators - redux-saga
Pedro Solá
 
PDF
Predictable reactive state management - ngrx
Ilia Idakiev
 
ODP
Gatling
Gaurav Shukla
 
PPSX
Writing code that writes code - Nguyen Luong
Vu Huy
 
ODP
Unit Testing and Coverage for AngularJS
Knoldus Inc.
 
PDF
Découvrir dtrace en ligne de commande.
CocoaHeads France
 
PPTX
Reactive Java (33rd Degree)
Tomasz Kowalczewski
 
ODP
Introduction to ScalaZ
Knoldus Inc.
 
PDF
Esctl in action elastic user group presentation aug 25 2020
FaithWestdorp
 
PPTX
Redux in Angular2 for jsbe
Brecht Billiet
 
PPTX
Azure Function Workflow
Andrea Tosato
 
PDF
PyData Amsterdam 2018 – Building customer-visible data science dashboards wit...
Uwe Korn
 
PDF
RxJava on Android
Dustin Graham
 
PDF
Gatling @ Scala.Io 2013
slandelle
 
Functional UIs with Java 8 and Vaadin JavaOne2014
hezamu
 
Functional Reactive Endpoints using Spring 5
Rory Preddy
 
Redux data flow with angular 2
Gil Fink
 
Spring batch
Deepak Kumar
 
Ngrx slides
Christoffer Noring
 
React state management with Redux and MobX
Darko Kukovec
 
Asyc flow control with javascript generators - redux-saga
Pedro Solá
 
Predictable reactive state management - ngrx
Ilia Idakiev
 
Gatling
Gaurav Shukla
 
Writing code that writes code - Nguyen Luong
Vu Huy
 
Unit Testing and Coverage for AngularJS
Knoldus Inc.
 
Découvrir dtrace en ligne de commande.
CocoaHeads France
 
Reactive Java (33rd Degree)
Tomasz Kowalczewski
 
Introduction to ScalaZ
Knoldus Inc.
 
Esctl in action elastic user group presentation aug 25 2020
FaithWestdorp
 
Redux in Angular2 for jsbe
Brecht Billiet
 
Azure Function Workflow
Andrea Tosato
 
PyData Amsterdam 2018 – Building customer-visible data science dashboards wit...
Uwe Korn
 
RxJava on Android
Dustin Graham
 
Gatling @ Scala.Io 2013
slandelle
 

Similar to Integration-Monday-Stateful-Programming-Models-Serverless-Functions (20)

PDF
Azure Durable Functions (2019-04-27)
Paco de la Cruz
 
PDF
Azure Durable Functions (2019-03-30)
Paco de la Cruz
 
PPTX
Durable Functions
Matti Petrelius
 
PDF
Durable functions 2.0 (2019-10-10)
Paco de la Cruz
 
PPTX
State in stateless serverless functions
Alex Pshul
 
PPTX
State in stateless serverless functions - Alex Pshul
CodeValue
 
PPTX
Guidelines to understand durable functions with .net core, c# and stateful se...
Concetto Labs
 
PPTX
ServerLess by usama Azure fuctions.pptx
Usama Wahab Khan Cloud, Data and AI
 
PPTX
Durable functions
Amresh Krishnamurthy
 
PPTX
Develop in ludicrous mode with azure serverless
Lalit Kale
 
PDF
Stateful patterns in Azure Functions
Massimo Bonanni
 
PDF
[SOT322] Serverless Side-by-Side Extensions with Azure Durable Functions - Wh...
Christian Lechner
 
PPTX
Mastering Azure Durable Functions - Building Resilient and Scalable Workflows
Callon Campbell
 
PPTX
Building a document signing workflow with Durable Functions
Joonas Westlin
 
PDF
Azure functions
Rajesh Kolla
 
PPTX
Azure Durable Functions
Kanio Dimitrov
 
PDF
Stateful pattern con Azure Functions
Massimo Bonanni
 
PPTX
Building stateful serverless orchestrations with Azure Durable Azure Function...
Callon Campbell
 
PDF
Azure Functions 2.0 Deep Dive - デベロッパーのための最新開発ガイド
Yoichi Kawasaki
 
PDF
Massimo Bonanni - Workflow as code with Azure Durable Functions - Codemotion ...
Codemotion
 
Azure Durable Functions (2019-04-27)
Paco de la Cruz
 
Azure Durable Functions (2019-03-30)
Paco de la Cruz
 
Durable Functions
Matti Petrelius
 
Durable functions 2.0 (2019-10-10)
Paco de la Cruz
 
State in stateless serverless functions
Alex Pshul
 
State in stateless serverless functions - Alex Pshul
CodeValue
 
Guidelines to understand durable functions with .net core, c# and stateful se...
Concetto Labs
 
ServerLess by usama Azure fuctions.pptx
Usama Wahab Khan Cloud, Data and AI
 
Durable functions
Amresh Krishnamurthy
 
Develop in ludicrous mode with azure serverless
Lalit Kale
 
Stateful patterns in Azure Functions
Massimo Bonanni
 
[SOT322] Serverless Side-by-Side Extensions with Azure Durable Functions - Wh...
Christian Lechner
 
Mastering Azure Durable Functions - Building Resilient and Scalable Workflows
Callon Campbell
 
Building a document signing workflow with Durable Functions
Joonas Westlin
 
Azure functions
Rajesh Kolla
 
Azure Durable Functions
Kanio Dimitrov
 
Stateful pattern con Azure Functions
Massimo Bonanni
 
Building stateful serverless orchestrations with Azure Durable Azure Function...
Callon Campbell
 
Azure Functions 2.0 Deep Dive - デベロッパーのための最新開発ガイド
Yoichi Kawasaki
 
Massimo Bonanni - Workflow as code with Azure Durable Functions - Codemotion ...
Codemotion
 
Ad

More from BizTalk360 (20)

PPTX
Optimise Business Activity Tracking – Insights from Smurfit Kappa
BizTalk360
 
PPTX
Optimise Business Activity Tracking – Insights from Smurfit Kappa
BizTalk360
 
PPTX
What's inside "migrating to biz talk server 2020" Book (BizTalk360 Webinar)
BizTalk360
 
PPTX
Integration Monday - Logic Apps: Development Experiences
BizTalk360
 
PPTX
Integration Monday - BizTalk Migrator Deep Dive
BizTalk360
 
PPTX
Testing for Logic App Solutions | Integration Monday
BizTalk360
 
PPTX
No-Slides
BizTalk360
 
PPTX
System Integration using Reactive Programming | Integration Monday
BizTalk360
 
PPTX
Building workflow solution with Microsoft Azure and Cloud | Integration Monday
BizTalk360
 
PPTX
Serverless Minimalism: How to architect your apps to save 98% on your Azure b...
BizTalk360
 
PPTX
Migrating BizTalk Solutions to Azure: Mapping Messages | Integration Monday
BizTalk360
 
PPTX
Integration-Monday-Infrastructure-As-Code-With-Terraform
BizTalk360
 
PPTX
Integration-Monday-Serverless-Slackbots-with-Azure-Durable-Functions
BizTalk360
 
PPTX
Integration-Monday-Building-Stateful-Workloads-Kubernetes
BizTalk360
 
PPTX
Integration-Monday-Logic-Apps-Tips-Tricks
BizTalk360
 
PPTX
Integration-Monday-Terraform-Serverless
BizTalk360
 
PPTX
Integration-Monday-Microsoft-Power-Platform
BizTalk360
 
PDF
One name unify them all
BizTalk360
 
PPTX
Securely Publishing Azure Services
BizTalk360
 
PPTX
Integration-Monday-BizTalk-Server-2020
BizTalk360
 
Optimise Business Activity Tracking – Insights from Smurfit Kappa
BizTalk360
 
Optimise Business Activity Tracking – Insights from Smurfit Kappa
BizTalk360
 
What's inside "migrating to biz talk server 2020" Book (BizTalk360 Webinar)
BizTalk360
 
Integration Monday - Logic Apps: Development Experiences
BizTalk360
 
Integration Monday - BizTalk Migrator Deep Dive
BizTalk360
 
Testing for Logic App Solutions | Integration Monday
BizTalk360
 
No-Slides
BizTalk360
 
System Integration using Reactive Programming | Integration Monday
BizTalk360
 
Building workflow solution with Microsoft Azure and Cloud | Integration Monday
BizTalk360
 
Serverless Minimalism: How to architect your apps to save 98% on your Azure b...
BizTalk360
 
Migrating BizTalk Solutions to Azure: Mapping Messages | Integration Monday
BizTalk360
 
Integration-Monday-Infrastructure-As-Code-With-Terraform
BizTalk360
 
Integration-Monday-Serverless-Slackbots-with-Azure-Durable-Functions
BizTalk360
 
Integration-Monday-Building-Stateful-Workloads-Kubernetes
BizTalk360
 
Integration-Monday-Logic-Apps-Tips-Tricks
BizTalk360
 
Integration-Monday-Terraform-Serverless
BizTalk360
 
Integration-Monday-Microsoft-Power-Platform
BizTalk360
 
One name unify them all
BizTalk360
 
Securely Publishing Azure Services
BizTalk360
 
Integration-Monday-BizTalk-Server-2020
BizTalk360
 
Ad

Recently uploaded (20)

PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PDF
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
PDF
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PPTX
Digital Circuits, important subject in CS
contactparinay1
 
PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
Digital Circuits, important subject in CS
contactparinay1
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 

Integration-Monday-Stateful-Programming-Models-Serverless-Functions

  • 2. Me Azure Technology Consultant Microsoft MVP – Azure InfoQ Cloud Editor WAZUG NL board member Azure Lowlands Organizer Writer
  • 3. Agenda • Serverless • Azure (Durable) Functions • Workflows • Actors • Key takeaways • Call to action
  • 5. Azure Functions serverless programming model Author functions in C#, F#, JavaScript, TypeScript, Java, Python, PowerShell, and more CodeEvents React to timers, HTTP, or events from your favorite Azure services, with more on the way Outputs Send results to an ever- growing collection of services
  • 6. Bindings programming model [FunctionName("QueueTriggerTableOutput")] [return: Table("outTable")] public static Person Create([QueueTrigger("myqueue-items")] JObject order) { return new Person { PartitionKey = "Orders", RowKey = Guid.NewGuid().ToString(), Name = order["Name"].ToString(), MobileNumber = order["MobileNumber"].ToString() }; } Trigger binding Output binding
  • 7. “Functions must be stateless” “Functions must not call other functions” “Functions should do only one thing” FaaS principles and best practices?
  • 9. Stateful pattern #1: Function chaining F1 F2 F3 Problems: • Relationship between functions and queues is unclear. • Operation context cannot be easily captured without a database. • Middle queues are an implementation detail (conceptual overhead). • Error handling adds a lot more complexity.
  • 11. Durable Functions Durable Task Framework (DTFx) Durable Functions runtime extension Durable storage / messaging
  • 12. Writing flexible workflows Azure Function Extension Based up on the Durable Task Framework – OSS library since 2014. Persistence on Azure Storage Implementation of stateful workflow-as-code
  • 13. What “chaining” could look like in code // calls functions in sequence public static async Task<object> Run(IDurableOrchestrationContext ctx) { try { var x = await ctx.CallActivityAsync("F1"); var y = await ctx.CallActivityAsync("F2", x); return await ctx.CallActivityAsync("F3", y); } catch (Exception) { // error handling/compensation can go here (or anywhere) } } Orchestrator Function Activity Functions
  • 14. A. Memory snapshots B. Compiler hooks C. Event sourcing D. All the above E. None of the above How do we preserve local variable state?
  • 15. Behind the scenes 1. var x = await ctx.CallActivityAsync("F1"); 2. var y = await ctx.CallActivityAsync("F2", x); 3. return await ctx.CallActivityAsync("F3", y); Orchestrator Function F1 => return 42; F2 => return n + 1; F3 => return n + 2; Execution started Task scheduled, F1 Task completed, F1 => 42 Task scheduled, F2 Task scheduled, F3 Task completed, F3 => 45 Orchestrator completed => 45 Task completed, F2 => 43
  • 16. Orchestrator code MUST be deterministic! • Rule #1: Never write logic that depends on random numbers, the current date/time, etc. • Rule #2: Never do I/O or custom thread scheduling directly in the orchestrator function. • Rule #3: Do not write infinite loops • Rule #4: Use the built-in workarounds for rules #1, #2, and #3 When in doubt, use the Durable source code analyzer!
  • 17. Stateful pattern #2: Fan-out & fan-in Problems: • Fanning-out is easy, but fanning-in is significantly more complicated • Stateful agent is required to track progress of all work • All the same problems of the previous pattern
  • 18. Fan-out & fan-in as code public static async Task Run(IDurableOrchestrationContext context) { var parallelTasks = new List<Task<int>>(); // Get a list of N work items to process in parallel. object[] workBatch = await context.CallActivityAsync<object[]>("F1"); for (int i = 0; i < workBatch.Length; i++) { Task<int> task = context.CallActivityAsync<int>("F2", workBatch[i]); parallelTasks.Add(task); } await Task.WhenAll(parallelTasks); // Aggregate all N outputs and send the result to F3. int sum = parallelTasks.Sum(t => t.Result); await context.CallActivityAsync("F3", sum); }
  • 20. Demo!
  • 21. Ingest Data With Logic Apps you can automate a scheduled process of retrieving data and storing in a database (SQL or NoSQL) using a graphical interface (GUI) – Visual Designer. Convert Epoch to DateTime Ingest Pull Push Pull Push Function A Store in Collection
  • 22. Ingest Data With Durable Functions you can automate a scheduled process of retrieving data and storing in a database using a Integrated Development Environment – Visual Studio or Visual Code. Orchestrator Client Orchestration Function Convert to TimeStamp Store In Database GetRates
  • 25. Durable Function Types Orchestrator (Stateful) Activity (Stateless) Entity (Stateful) New! External / Client (Stateless) https://docs.microsoft.com/azure/azure-functions/durable/durable-functions-types-features-overview
  • 26. Counter entity as a class (C#) public class Counter { [JsonProperty] public int value; public void Add(int amount) => this.value += amount; public void Reset() => this.value = 0; public int Get() => this.value; // Required boilerplate code [FunctionName(nameof(Counter))] public static Task Run([EntityTrigger] IDurableEntityContext ctx) => ctx.DispatchAsync<Counter>(); }
  • 27. The entities concept Message EntityID: @Counter@Qux Operation: add Input: 1 Entity Class Name: Counter Entity Key: Foo State: 2 Entity Key: Bar State: 4 Entity Key: Baz State: 8 Entity Key: Qux State: 0 Function invocation Context(ID: @Counter@Qux, State: 0, Operation: add, Input: 1)
  • 28. Demo!
  • 29. Entities are addressable via an entity ID. Entity operations execute serially, one at a time. Entities are created implicitly when called or signaled. When not executing operations, entities are silently unloaded from memory Similarities with virtual actors
  • 30. Serverless! Durability > Latency Reliable, in-order messaging No message timeouts One-way messaging* No deadlocks* Integration with orchestrations Differences from other virtual actor frameworks
  • 31. Other applications • Serverless distributed circuit breaker • Polly announcement: https://github.com/App-vNext/Polly/issues/687 • Example implementation: https://dev.to/azure/serverless-circuit-breakers-with-durable-entities-3l2f • IoT device management • Device offline detection: http://case.schollaart.net/2019/07/01/device-offline-detection-with- durable-entities.html • Stream analysis and alerting: https://thecloudblog.net/post/iot-edge-device-monitoring-and- management-with-azure-durable-entities-functions-part-1/ • API cache • https://www.aaron-powell.com/posts/2019-09-27-using-durable-entities-and-orchestrators-to- create-an-api-cache/ • Ride sharing sample application • https://github.com/Azure/azure-functions-durable-extension/tree/master/samples/entitites- csharp/RideSharing
  • 32. Key takeaways MODERATE LEARNING CURVE DURABLE FUNCTIONS EXCELLENT FOR BACKEND PROCESSES NOT A COMPETING TECHNOLOGY OF LOGIC APPS OPTION IN AZURE AS ALTERNATIVE TO AKKA.NET OR ORLEANS