SlideShare una empresa de Scribd logo
1 de 34
Descargar para leer sin conexión
@pacodelacruz
Paco de la Cruz
Durable Functions 2.0
Stateful Serverless Functions
IntegrationDownUnder
@pacodelacruz
@pacodelacruz
@pacodelacruz
linkedin.com/in/pacodelacruz
pacodelacruz.io
slideshare.net/pacodelac/presentations
github.com/pacodelacruz
@pacodelacruz
Serverless and Azure Functions Recap
What’s Coming in Durable Functions 2.0
Durable Functions Patterns
Function Types
Durable Entities
Demo
Q & A
Agenda
@pacodelacruz
Cloud Compute Spectrum
@pacodelacruz
Azure Compute Spectrum
@pacodelacruz
Serverless FaaS and its Benefits
Server abstraction
(Ops Productivity)
Scaling,
Load balancing &
High availability
built-in
@pacodelacruz
Serverless FaaS and its Benefits
Server abstraction
(Ops Productivity)
Event-driven scaling
not resource-driven
Scaling,
Load balancing &
High availability
built-in
Pay only for
what you use
Devs Productivity
(Programming
Models)
@pacodelacruz
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, PowerShell
Send results to a
growing list of services
(output bindings)
@pacodelacruz
Durable Functions in a Nutshell
Based on
Durable Task Framework
Using Azure Storage
(Managed & Abstracted)
To Implement
stateful entities and
workflows-as-code
(C#, F# & Node.js)
Azure Functions
Extension
@pacodelacruz
Durable Entities (Actor-Like)
HTTP Calls from Orch. (with MI)
Pluggable State Providers
Testability Improvements
Orchestrator Roslyn Analyser
What’s Coming in Durable Functions 2.0
@pacodelacruz
Durable Functions Patterns (1.0)
Function Chaining Fan-out & Fan-in Async HTTP APIs
Human Interaction /
Wait for External Events
Monitoring
Start
Get Status
@pacodelacruz
Durable Functions Patterns (2.0)
Function Chaining Fan-out & Fan-in Async HTTP APIs
Human Interaction /
Wait for External Events
Monitoring Durable Entities *
Start
Get Status
Query
* New on 2.0
@pacodelacruz
Durable Functions Types (1.0)
Client ActivityOrchestrator
Start Orch.
Query Orch.
Terminate Orch.
Signal Orch.
Call Activity
Call Sub-orch.
Set Status
Perform Step,
IO
Stateless Stateful Stateless
Client Orchestrator Activity
@pacodelacruz
Durable Functions Types (2.0)
Entity*Client ActivityOrchestrator
Start Orch.
Query Orch.
Terminate Orch.
Signal Orch.
Signal Entity*
Query Entity*
Call Activity
Call Sub-orch.
Set Status
Call Entity*
Perform Step,
IO
Initialise*
Destruct*
Handle Event*
Set State*
Stateless Stateful Stateless Stateful
Client Orchestrator Activity Entity*
* New on 2.0
@pacodelacruz
Addressable via entity Id
Operations execute serially
Created when called or signalled
When not executing, unloaded from memory
One-way messaging from Clients and other Entities ^
Two-way requests from Orchestrations ^
Orchestrations provide distributed locking ^
Durability over latency ^
Durable Entities (Actor-Like)
^ Different from virtual-actors
@pacodelacruz
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 / compensation
}
}
@pacodelacruz
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 / compensation
}
}
@pacodelacruz
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 / compensation
}
}
@pacodelacruz
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;
}
@pacodelacruz
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
@pacodelacruz
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;
}
@pacodelacruz
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;
}
@pacodelacruz
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;
}
@pacodelacruz
Durable Entity Functions
public class Counter
{
[JsonProperty("value")]
public int CurrentValue { get; set; }
public void Add(int amount) => this.CurrentValue += amount;
public void Reset() => this.CurrentValue = 0;
public int Get() => this.CurrentValue;
[FunctionName(nameof(Counter))]
public static Task Run([EntityTrigger] IDurableEntityContext ctx)
=> ctx.DispatchAsync<Counter>();
}
@pacodelacruz
Durable Entity Functions
public class Counter
{
[JsonProperty("value")]
public int CurrentValue { get; set; }
public void Add(int amount) => this.CurrentValue += amount;
public void Reset() => this.CurrentValue = 0;
public int Get() => this.CurrentValue;
[FunctionName(nameof(Counter))]
public static Task Run([EntityTrigger] IDurableEntityContext ctx)
=> ctx.DispatchAsync<Counter>();
}
@pacodelacruz
Durable Entity Functions
public class Counter
{
[JsonProperty("value")]
public int CurrentValue { get; set; }
public void Add(int amount) => this.CurrentValue += amount;
public void Reset() => this.CurrentValue = 0;
public int Get() => this.CurrentValue;
[FunctionName(nameof(Counter))]
public static Task Run([EntityTrigger] IDurableEntityContext ctx)
=> ctx.DispatchAsync<Counter>();
}
@pacodelacruz
Durable Entity Functions
public class Counter
{
[JsonProperty("value")]
public int CurrentValue { get; set; }
public void Add(int amount) => this.CurrentValue += amount;
public void Reset() => this.CurrentValue = 0;
public int Get() => this.CurrentValue;
[FunctionName(nameof(Counter))]
public static Task Run([EntityTrigger] IDurableEntityContext ctx)
=> ctx.DispatchAsync<Counter>();
}
@pacodelacruz
Durable Functions vs Logic Apps?
Durable Functions Logic Apps
Stateful workflows and entities Stateful workflows
C#, F# and JavaScript Visual designer and WDL
Bindings (~ 20 supported) 250+ connectors
Portable Runtime Run only on Azure
Monitoring based on App Insights & APIs Rich monitoring & management tools
Serverless, dedicated and isolated Serverless & dedicated (ISE)
platform.deloitte.com.au/articles/azure-durable-functions-vs-logic-apps
@pacodelacruz
Questions so far?
@pacodelacruz
Stateful Serverless Request Bin
Why Having Your Own Serverless Request Bin?
Deploy to Azure
Understand the Solution
Test It!
Demo
github.com/pacodelacruz/
serverless-request-bin-durable-functions
@pacodelacruz
Q & A
IntegrationDownUnder
@pacodelacruz
Additional Resources
Twitter @azurefunctions
Documentation aka.ms/durablefunctions &
aka.ms/durable/2docs
Live Web Cast aka.ms/azurefunctionslive
Repos github.com/Azure/azure-functions-durable-extension
github.com/Azure/azure-functions-durable-js
Samples aka.ms/durable/entitysamples
@pacodelacruz
@pacodelacruz
linkedin.com/in/pacodelacruz
pacodelacruz.io
slideshare.net/pacodelac/presentations
github.com/pacodelacruz
@pacodelacruz
:)
IntegrationDownUnder

Más contenido relacionado

La actualidad más candente

Coldbox developer training – session 5
Coldbox developer training – session 5Coldbox developer training – session 5
Coldbox developer training – session 5
Billie Berzinskas
 
Biz Talk Demo slideshare
Biz Talk Demo slideshareBiz Talk Demo slideshare
Biz Talk Demo slideshare
erios
 

La actualidad más candente (20)

Coldbox developer training – session 5
Coldbox developer training – session 5Coldbox developer training – session 5
Coldbox developer training – session 5
 
Parse Advanced
Parse AdvancedParse Advanced
Parse Advanced
 
Firebase ng2 zurich
Firebase ng2 zurichFirebase ng2 zurich
Firebase ng2 zurich
 
Vertx - Reactive & Distributed
Vertx - Reactive & DistributedVertx - Reactive & Distributed
Vertx - Reactive & Distributed
 
A serverless IoT story from design to production and monitoring
A serverless IoT story from design to production and monitoringA serverless IoT story from design to production and monitoring
A serverless IoT story from design to production and monitoring
 
Vert.x - Reactive & Distributed [Devoxx version]
Vert.x - Reactive & Distributed [Devoxx version]Vert.x - Reactive & Distributed [Devoxx version]
Vert.x - Reactive & Distributed [Devoxx version]
 
Backbone js
Backbone jsBackbone js
Backbone js
 
Kogito: cloud native business automation
Kogito: cloud native business automationKogito: cloud native business automation
Kogito: cloud native business automation
 
Biz Talk Demo slideshare
Biz Talk Demo slideshareBiz Talk Demo slideshare
Biz Talk Demo slideshare
 
Spray - Build RESTfull services in scala
Spray - Build RESTfull services in scalaSpray - Build RESTfull services in scala
Spray - Build RESTfull services in scala
 
Orion Context Broker
Orion Context Broker Orion Context Broker
Orion Context Broker
 
Spring Boot Actuator 2.0 & Micrometer #jjug_ccc #ccc_a1
Spring Boot Actuator 2.0 & Micrometer #jjug_ccc #ccc_a1Spring Boot Actuator 2.0 & Micrometer #jjug_ccc #ccc_a1
Spring Boot Actuator 2.0 & Micrometer #jjug_ccc #ccc_a1
 
Introduction to Retrofit and RxJava
Introduction to Retrofit and RxJavaIntroduction to Retrofit and RxJava
Introduction to Retrofit and RxJava
 
JavaOne 2013: Java 8 - The Good Parts
JavaOne 2013: Java 8 - The Good PartsJavaOne 2013: Java 8 - The Good Parts
JavaOne 2013: Java 8 - The Good Parts
 
Typescript barcelona
Typescript barcelonaTypescript barcelona
Typescript barcelona
 
Reactive Programming in Java 8 with Rx-Java
Reactive Programming in Java 8 with Rx-JavaReactive Programming in Java 8 with Rx-Java
Reactive Programming in Java 8 with Rx-Java
 
Presente e Futuro: Java EE.next()
Presente e Futuro: Java EE.next()Presente e Futuro: Java EE.next()
Presente e Futuro: Java EE.next()
 
Reactive Fault Tolerant Programming with Hystrix and RxJava
Reactive Fault Tolerant Programming with Hystrix and RxJavaReactive Fault Tolerant Programming with Hystrix and RxJava
Reactive Fault Tolerant Programming with Hystrix and RxJava
 
AAI 2236-Using the New Java Concurrency Utilities with IBM WebSphere
AAI 2236-Using the New Java Concurrency Utilities with IBM WebSphereAAI 2236-Using the New Java Concurrency Utilities with IBM WebSphere
AAI 2236-Using the New Java Concurrency Utilities with IBM WebSphere
 
Open sourcing the store
Open sourcing the storeOpen sourcing the store
Open sourcing the store
 

Similar a Durable functions 2.0 (2019-10-10)

Droidcon2013 android experience lahoda
Droidcon2013 android experience lahodaDroidcon2013 android experience lahoda
Droidcon2013 android experience lahoda
Droidcon Berlin
 
Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android Infrastructure
Alexey Buzdin
 
Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android Infrastructure
C.T.Co
 
Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best Practices
Yekmer Simsek
 

Similar a Durable functions 2.0 (2019-10-10) (20)

[NDC 2019] Enterprise-Grade Serverless
[NDC 2019] Enterprise-Grade Serverless[NDC 2019] Enterprise-Grade Serverless
[NDC 2019] Enterprise-Grade Serverless
 
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
 
Architecting Alive Apps
Architecting Alive AppsArchitecting Alive Apps
Architecting Alive Apps
 
Java Configuration Deep Dive with Spring
Java Configuration Deep Dive with SpringJava Configuration Deep Dive with Spring
Java Configuration Deep Dive with Spring
 
Modern Android app library stack
Modern Android app library stackModern Android app library stack
Modern Android app library stack
 
Working with data using Azure Functions.pdf
Working with data using Azure Functions.pdfWorking with data using Azure Functions.pdf
Working with data using Azure Functions.pdf
 
NodeJS: the good parts? A skeptic’s view (jax jax2013)
NodeJS: the good parts? A skeptic’s view (jax jax2013)NodeJS: the good parts? A skeptic’s view (jax jax2013)
NodeJS: the good parts? A skeptic’s view (jax jax2013)
 
Reactive programming on Android
Reactive programming on AndroidReactive programming on Android
Reactive programming on Android
 
Speed up your Web applications with HTML5 WebSockets
Speed up your Web applications with HTML5 WebSocketsSpeed up your Web applications with HTML5 WebSockets
Speed up your Web applications with HTML5 WebSockets
 
Improving android experience for both users and developers
Improving android experience for both users and developersImproving android experience for both users and developers
Improving android experience for both users and developers
 
Droidcon2013 android experience lahoda
Droidcon2013 android experience lahodaDroidcon2013 android experience lahoda
Droidcon2013 android experience lahoda
 
Google App Engine Developer - Day3
Google App Engine Developer - Day3Google App Engine Developer - Day3
Google App Engine Developer - Day3
 
Reactive programming every day
Reactive programming every dayReactive programming every day
Reactive programming every day
 
Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android Infrastructure
 
Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android Infrastructure
 
Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best Practices
 
Flask and Angular: An approach to build robust platforms
Flask and Angular:  An approach to build robust platformsFlask and Angular:  An approach to build robust platforms
Flask and Angular: An approach to build robust platforms
 
An intro to cqrs
An intro to cqrsAn intro to cqrs
An intro to cqrs
 
The evolution of redux action creators
The evolution of redux action creatorsThe evolution of redux action creators
The evolution of redux action creators
 
A GWT Application with MVP Pattern Deploying to CloudFoundry using Spring Roo
A GWT Application with MVP Pattern Deploying to CloudFoundry using  Spring Roo A GWT Application with MVP Pattern Deploying to CloudFoundry using  Spring Roo
A GWT Application with MVP Pattern Deploying to CloudFoundry using Spring Roo
 

Más de Paco de la Cruz

Más de Paco de la Cruz (9)

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

Último

Último (20)

Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Durable functions 2.0 (2019-10-10)

  • 1. @pacodelacruz Paco de la Cruz Durable Functions 2.0 Stateful Serverless Functions IntegrationDownUnder @pacodelacruz
  • 3. @pacodelacruz Serverless and Azure Functions Recap What’s Coming in Durable Functions 2.0 Durable Functions Patterns Function Types Durable Entities Demo Q & A Agenda
  • 6. @pacodelacruz Serverless FaaS and its Benefits Server abstraction (Ops Productivity) Scaling, Load balancing & High availability built-in
  • 7. @pacodelacruz Serverless FaaS and its Benefits Server abstraction (Ops Productivity) Event-driven scaling not resource-driven Scaling, Load balancing & High availability built-in Pay only for what you use Devs Productivity (Programming Models)
  • 8. @pacodelacruz 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, PowerShell Send results to a growing list of services (output bindings)
  • 9. @pacodelacruz Durable Functions in a Nutshell Based on Durable Task Framework Using Azure Storage (Managed & Abstracted) To Implement stateful entities and workflows-as-code (C#, F# & Node.js) Azure Functions Extension
  • 10. @pacodelacruz Durable Entities (Actor-Like) HTTP Calls from Orch. (with MI) Pluggable State Providers Testability Improvements Orchestrator Roslyn Analyser What’s Coming in Durable Functions 2.0
  • 11. @pacodelacruz Durable Functions Patterns (1.0) Function Chaining Fan-out & Fan-in Async HTTP APIs Human Interaction / Wait for External Events Monitoring Start Get Status
  • 12. @pacodelacruz Durable Functions Patterns (2.0) Function Chaining Fan-out & Fan-in Async HTTP APIs Human Interaction / Wait for External Events Monitoring Durable Entities * Start Get Status Query * New on 2.0
  • 13. @pacodelacruz Durable Functions Types (1.0) Client ActivityOrchestrator Start Orch. Query Orch. Terminate Orch. Signal Orch. Call Activity Call Sub-orch. Set Status Perform Step, IO Stateless Stateful Stateless Client Orchestrator Activity
  • 14. @pacodelacruz Durable Functions Types (2.0) Entity*Client ActivityOrchestrator Start Orch. Query Orch. Terminate Orch. Signal Orch. Signal Entity* Query Entity* Call Activity Call Sub-orch. Set Status Call Entity* Perform Step, IO Initialise* Destruct* Handle Event* Set State* Stateless Stateful Stateless Stateful Client Orchestrator Activity Entity* * New on 2.0
  • 15. @pacodelacruz Addressable via entity Id Operations execute serially Created when called or signalled When not executing, unloaded from memory One-way messaging from Clients and other Entities ^ Two-way requests from Orchestrations ^ Orchestrations provide distributed locking ^ Durability over latency ^ Durable Entities (Actor-Like) ^ Different from virtual-actors
  • 16. @pacodelacruz 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 / compensation } }
  • 17. @pacodelacruz 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 / compensation } }
  • 18. @pacodelacruz 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 / compensation } }
  • 19. @pacodelacruz 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; }
  • 20. @pacodelacruz 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
  • 21. @pacodelacruz 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; }
  • 22. @pacodelacruz 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; }
  • 23. @pacodelacruz 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; }
  • 24. @pacodelacruz Durable Entity Functions public class Counter { [JsonProperty("value")] public int CurrentValue { get; set; } public void Add(int amount) => this.CurrentValue += amount; public void Reset() => this.CurrentValue = 0; public int Get() => this.CurrentValue; [FunctionName(nameof(Counter))] public static Task Run([EntityTrigger] IDurableEntityContext ctx) => ctx.DispatchAsync<Counter>(); }
  • 25. @pacodelacruz Durable Entity Functions public class Counter { [JsonProperty("value")] public int CurrentValue { get; set; } public void Add(int amount) => this.CurrentValue += amount; public void Reset() => this.CurrentValue = 0; public int Get() => this.CurrentValue; [FunctionName(nameof(Counter))] public static Task Run([EntityTrigger] IDurableEntityContext ctx) => ctx.DispatchAsync<Counter>(); }
  • 26. @pacodelacruz Durable Entity Functions public class Counter { [JsonProperty("value")] public int CurrentValue { get; set; } public void Add(int amount) => this.CurrentValue += amount; public void Reset() => this.CurrentValue = 0; public int Get() => this.CurrentValue; [FunctionName(nameof(Counter))] public static Task Run([EntityTrigger] IDurableEntityContext ctx) => ctx.DispatchAsync<Counter>(); }
  • 27. @pacodelacruz Durable Entity Functions public class Counter { [JsonProperty("value")] public int CurrentValue { get; set; } public void Add(int amount) => this.CurrentValue += amount; public void Reset() => this.CurrentValue = 0; public int Get() => this.CurrentValue; [FunctionName(nameof(Counter))] public static Task Run([EntityTrigger] IDurableEntityContext ctx) => ctx.DispatchAsync<Counter>(); }
  • 28. @pacodelacruz Durable Functions vs Logic Apps? Durable Functions Logic Apps Stateful workflows and entities Stateful workflows C#, F# and JavaScript Visual designer and WDL Bindings (~ 20 supported) 250+ connectors Portable Runtime Run only on Azure Monitoring based on App Insights & APIs Rich monitoring & management tools Serverless, dedicated and isolated Serverless & dedicated (ISE) platform.deloitte.com.au/articles/azure-durable-functions-vs-logic-apps
  • 30. @pacodelacruz Stateful Serverless Request Bin Why Having Your Own Serverless Request Bin? Deploy to Azure Understand the Solution Test It! Demo github.com/pacodelacruz/ serverless-request-bin-durable-functions
  • 32. @pacodelacruz Additional Resources Twitter @azurefunctions Documentation aka.ms/durablefunctions & aka.ms/durable/2docs Live Web Cast aka.ms/azurefunctionslive Repos github.com/Azure/azure-functions-durable-extension github.com/Azure/azure-functions-durable-js Samples aka.ms/durable/entitysamples