SlideShare a Scribd company logo
1 of 29
Serverless Orchestration with
Durable Functions
Callon Campbell
Systems Architect, Microsoft Azure MVP
Email: CallonCampbell@Outlook.com
Blog: https://TheFlyingMaverick.com
Twitter: @Flying_Maverick
Microsoft Azure
About me
2
Email: CallonCampbell@Outlook.com Twitter: @Flying_Maverick
Blog: http://TheFlyingMaverick.com LinkedIn: LinkedIn.com/in/calloncampbell
Website: http://ReflectInsight.com Slideshare: https://www.slideshare.net/calloncampbell
Callon Campbell - Microsoft Azure MVP
Systems Architect and Developer with 20 years of
experience developing desktop, mobile and web
enterprise applications using .NET, SQL Server,
Mobile and Azure technologies.
Co-creator of ReflectInsight, a .NET logging
framework and real-time Live Log Viewer.
Microsoft Azure
Agenda
•Serverless refresher
•Serverless challenges
•Solutions through Durable Functions
•Wrap up
3
Microsoft Azure
The evolution of application platforms
4
Microsoft Azure
What is serverless?
5
Microsoft Azure
Focus on code, not plumbing
6
Microsoft Azure
FaaS is at the center of serverless
7
Functions-as-a-service programming model use functions to achieve true serverless compute
Microsoft Azure
What is Azure Functions?
Microsoft Azure
What’s still hard?
9
Microsoft Azure
Pattern #1: Function chaining
Problems:
• No visualization to show relationships between functions and
queues
• Middle queues are an implementation detail – conceptual
overhead
• Error handling adds a lot more complexity
10
Microsoft Azure
Pattern #2: Fan-out/fan-in
11
Problems:
• Fanning-out is easy, but fanning-in is significantly more
complicated
• Functions offers to help with this scenario today
• All the same problems as the previous pattern
Microsoft Azure
Introducing Durable Functions
• Write long-running orchestration as a single function while
maintaining local state
• Simplify complex transactions and coordination (chaining,
fan-out/fan-in, etc.) with a new function called orchestrator
function
• All of the above using code-only. No JSON schemas. No
UI/graphical designer
• Support for C#, F#, and JavaScript (in preview)
12
Microsoft Azure
Durable Functions Components
The Durable Functions has 3 components:
• Starter Function
• Orchestrator Function
• Activity Functions
13
Microsoft Azure
Prerequisites
•Install Visual Studio 2017 and ensure Azure
development workload is installed.
•Install the latest Azure Functions tools.
•Verify you have the Azure Storage Emulator installed
and running.
14
Demo 1
Function Chaining
Microsoft Azure
The Code
Function chaining
sample
This was scaffolded out
by the Visual Studio
templates.
16
Microsoft Azure
Starter Function
The Orchestration Client is the entry point (starter
function). Notice the OrchestrationClient attribute.
17
Microsoft Azure
URLs for checking status of execution
• StatusQueryGetUri - Get the status of a running
orchestration instance.
• SendEventPostUri - Send an event notification to a
running orchestration instance.
• TerminatePostUri - Terminate an instance of a running
orchestration.
• RewindPostUri - Rewind a running orchestration instance
to a replay events from a previous checkpoint.
18
Microsoft Azure
Orchestrator Function
Orchestration function is the conductor and responsible for
coordinating requests to activity functions
19
Microsoft Azure
Activity Function
The activity function is the equivalent of a regular
Azure Function with the difference – invoked by a
durable orchestrator.
20
Microsoft Azure
Triggering our Function
21
Microsoft Azure
“Hello Amsterdam!”[“Hello Amsterdam!”]
Orchestrator
Function
Activity
Function
Execution
History
var outputs = new List<string>();
outputs.Add(await context.CallActivityAsync<string>("SayHello", “Amsterdam"));
return outputs;
Orchestrator
Function
?
Activity
Function
“Hello Amsterdam!”
Orchestrator Started
Execution Started
Task Scheduled, SayHello, “Amsterdam”
Orchestrator Completed
Task Completed, “Hello Amsterdam!”
Orchestrator Started
Execution Completed, ["Hello Amsterdam!"]
Orchestrator Completed
Microsoft Azure
Event Source Log
23
Demo 2
Fan-Out/Fan-In
Microsoft Azure
Fan-Out/Fan-In Sample
25
Microsoft Azure
Orchestration Constraints
• Orchestrator code must be deterministic
• Never use random numbers, DateTime.UtcNow, Guid.NewGuid(), etc.
• Use DurableOrchestrationContext.CurrentUtcDateTime
• Orchestrator code should be non-blocking. Never do I/O directly in the
orchestrator
• Do I/O in activity functions
• Don't write infinite loops
• Use DurableOrchestrationContext.ContinueAsNew()
Microsoft Azure
Summary
•Azure Durable Functions make managing state and
complex workflows easy and familiar
•Now generally available and includes the following:
• Improved performance
• Large message support
• Application Insights diagnostics
• Logic Apps integration
27
Microsoft Azure
Thank you!
CallonCampbell@Outlook.com
TheFlyingMaverick.com
@Flying_Maverick
28
Microsoft Azure
References
• Durable Function Docs: http://aka.ms/durablefunctions
• GitHub:
• https://github.com/Azure/azure-functions-durable-extension
• https://github.com/Azure/durabletask/tree/azure-functions
• Orchestrator code constraints
• Develop Azure Functions using Visual Studio
• Serverless use cases and best practices
• Azure Durable Functions: before and after
29

More Related Content

More from Callon Campbell

Global Azure 2022 - Architecting Modern Serverless APIs with Azure Functions ...
Global Azure 2022 - Architecting Modern Serverless APIs with Azure Functions ...Global Azure 2022 - Architecting Modern Serverless APIs with Azure Functions ...
Global Azure 2022 - Architecting Modern Serverless APIs with Azure Functions ...Callon Campbell
 
Building stateful serverless orchestrations with Azure Durable Azure Function...
Building stateful serverless orchestrations with Azure Durable Azure Function...Building stateful serverless orchestrations with Azure Durable Azure Function...
Building stateful serverless orchestrations with Azure Durable Azure Function...Callon Campbell
 
Building scalable applications using serverless on the cloud
Building scalable applications using serverless on the cloudBuilding scalable applications using serverless on the cloud
Building scalable applications using serverless on the cloudCallon Campbell
 
Bringing Serverless into the Enterprise (Global Azure Virtual 2020)
Bringing Serverless into the Enterprise (Global Azure Virtual 2020)Bringing Serverless into the Enterprise (Global Azure Virtual 2020)
Bringing Serverless into the Enterprise (Global Azure Virtual 2020)Callon Campbell
 
Developing scalable enterprise serverless applications on azure with .net
Developing scalable enterprise serverless applications on azure with .netDeveloping scalable enterprise serverless applications on azure with .net
Developing scalable enterprise serverless applications on azure with .netCallon Campbell
 
Exposing services with Azure API Management
Exposing services with Azure API ManagementExposing services with Azure API Management
Exposing services with Azure API ManagementCallon Campbell
 
Build embedded and IoT solutions with Microsoft Windows IoT Core (BRK30077)
Build embedded and IoT solutions with Microsoft Windows IoT Core (BRK30077)Build embedded and IoT solutions with Microsoft Windows IoT Core (BRK30077)
Build embedded and IoT solutions with Microsoft Windows IoT Core (BRK30077)Callon Campbell
 
Centralized configuration with azure app configuration
Centralized configuration with azure app configurationCentralized configuration with azure app configuration
Centralized configuration with azure app configurationCallon Campbell
 
Creating Event Driven Applications with Azure Event Grid
Creating Event Driven Applications with Azure Event GridCreating Event Driven Applications with Azure Event Grid
Creating Event Driven Applications with Azure Event GridCallon Campbell
 
Getting Started with Azure Artifacts
Getting Started with Azure ArtifactsGetting Started with Azure Artifacts
Getting Started with Azure ArtifactsCallon Campbell
 
Serverless Orchestration with Azure Durable Functions
Serverless Orchestration with Azure Durable FunctionsServerless Orchestration with Azure Durable Functions
Serverless Orchestration with Azure Durable FunctionsCallon Campbell
 
Serverless Application Development with Azure
Serverless Application Development with AzureServerless Application Development with Azure
Serverless Application Development with AzureCallon Campbell
 
Introduction to Azure Event Grid
Introduction to Azure Event GridIntroduction to Azure Event Grid
Introduction to Azure Event GridCallon Campbell
 
Azure functions: Build apps faster with serverless architecture (March 2018)
Azure functions: Build apps faster with serverless architecture (March 2018)Azure functions: Build apps faster with serverless architecture (March 2018)
Azure functions: Build apps faster with serverless architecture (March 2018)Callon Campbell
 
Bring ai into your xamarin apps with microsoft cognitive services
Bring ai into your xamarin apps with microsoft cognitive servicesBring ai into your xamarin apps with microsoft cognitive services
Bring ai into your xamarin apps with microsoft cognitive servicesCallon Campbell
 
Introduction to serverless compute with azure functions
Introduction to serverless compute with azure functionsIntroduction to serverless compute with azure functions
Introduction to serverless compute with azure functionsCallon Campbell
 
Azure functions - Build apps faster with serverless architecture
Azure functions - Build apps faster with serverless architectureAzure functions - Build apps faster with serverless architecture
Azure functions - Build apps faster with serverless architectureCallon Campbell
 
Serverless integrations using Azure Logic Apps (intro)
Serverless integrations using Azure Logic Apps (intro)Serverless integrations using Azure Logic Apps (intro)
Serverless integrations using Azure Logic Apps (intro)Callon Campbell
 

More from Callon Campbell (20)

Global Azure 2022 - Architecting Modern Serverless APIs with Azure Functions ...
Global Azure 2022 - Architecting Modern Serverless APIs with Azure Functions ...Global Azure 2022 - Architecting Modern Serverless APIs with Azure Functions ...
Global Azure 2022 - Architecting Modern Serverless APIs with Azure Functions ...
 
Building stateful serverless orchestrations with Azure Durable Azure Function...
Building stateful serverless orchestrations with Azure Durable Azure Function...Building stateful serverless orchestrations with Azure Durable Azure Function...
Building stateful serverless orchestrations with Azure Durable Azure Function...
 
Building scalable applications using serverless on the cloud
Building scalable applications using serverless on the cloudBuilding scalable applications using serverless on the cloud
Building scalable applications using serverless on the cloud
 
Bringing Serverless into the Enterprise (Global Azure Virtual 2020)
Bringing Serverless into the Enterprise (Global Azure Virtual 2020)Bringing Serverless into the Enterprise (Global Azure Virtual 2020)
Bringing Serverless into the Enterprise (Global Azure Virtual 2020)
 
Developing scalable enterprise serverless applications on azure with .net
Developing scalable enterprise serverless applications on azure with .netDeveloping scalable enterprise serverless applications on azure with .net
Developing scalable enterprise serverless applications on azure with .net
 
Exposing services with Azure API Management
Exposing services with Azure API ManagementExposing services with Azure API Management
Exposing services with Azure API Management
 
Build embedded and IoT solutions with Microsoft Windows IoT Core (BRK30077)
Build embedded and IoT solutions with Microsoft Windows IoT Core (BRK30077)Build embedded and IoT solutions with Microsoft Windows IoT Core (BRK30077)
Build embedded and IoT solutions with Microsoft Windows IoT Core (BRK30077)
 
Centralized configuration with azure app configuration
Centralized configuration with azure app configurationCentralized configuration with azure app configuration
Centralized configuration with azure app configuration
 
Creating Event Driven Applications with Azure Event Grid
Creating Event Driven Applications with Azure Event GridCreating Event Driven Applications with Azure Event Grid
Creating Event Driven Applications with Azure Event Grid
 
Getting Started with Azure Artifacts
Getting Started with Azure ArtifactsGetting Started with Azure Artifacts
Getting Started with Azure Artifacts
 
Serverless Orchestration with Azure Durable Functions
Serverless Orchestration with Azure Durable FunctionsServerless Orchestration with Azure Durable Functions
Serverless Orchestration with Azure Durable Functions
 
Azure DevOps in Action
Azure DevOps in ActionAzure DevOps in Action
Azure DevOps in Action
 
Tour of Azure DevOps
Tour of Azure DevOpsTour of Azure DevOps
Tour of Azure DevOps
 
Serverless Application Development with Azure
Serverless Application Development with AzureServerless Application Development with Azure
Serverless Application Development with Azure
 
Introduction to Azure Event Grid
Introduction to Azure Event GridIntroduction to Azure Event Grid
Introduction to Azure Event Grid
 
Azure functions: Build apps faster with serverless architecture (March 2018)
Azure functions: Build apps faster with serverless architecture (March 2018)Azure functions: Build apps faster with serverless architecture (March 2018)
Azure functions: Build apps faster with serverless architecture (March 2018)
 
Bring ai into your xamarin apps with microsoft cognitive services
Bring ai into your xamarin apps with microsoft cognitive servicesBring ai into your xamarin apps with microsoft cognitive services
Bring ai into your xamarin apps with microsoft cognitive services
 
Introduction to serverless compute with azure functions
Introduction to serverless compute with azure functionsIntroduction to serverless compute with azure functions
Introduction to serverless compute with azure functions
 
Azure functions - Build apps faster with serverless architecture
Azure functions - Build apps faster with serverless architectureAzure functions - Build apps faster with serverless architecture
Azure functions - Build apps faster with serverless architecture
 
Serverless integrations using Azure Logic Apps (intro)
Serverless integrations using Azure Logic Apps (intro)Serverless integrations using Azure Logic Apps (intro)
Serverless integrations using Azure Logic Apps (intro)
 

Recently uploaded

Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 

Recently uploaded (20)

Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 

Serverless Orchestration with Durable Functions in Azure

  • 1. Serverless Orchestration with Durable Functions Callon Campbell Systems Architect, Microsoft Azure MVP Email: CallonCampbell@Outlook.com Blog: https://TheFlyingMaverick.com Twitter: @Flying_Maverick
  • 2. Microsoft Azure About me 2 Email: CallonCampbell@Outlook.com Twitter: @Flying_Maverick Blog: http://TheFlyingMaverick.com LinkedIn: LinkedIn.com/in/calloncampbell Website: http://ReflectInsight.com Slideshare: https://www.slideshare.net/calloncampbell Callon Campbell - Microsoft Azure MVP Systems Architect and Developer with 20 years of experience developing desktop, mobile and web enterprise applications using .NET, SQL Server, Mobile and Azure technologies. Co-creator of ReflectInsight, a .NET logging framework and real-time Live Log Viewer.
  • 3. Microsoft Azure Agenda •Serverless refresher •Serverless challenges •Solutions through Durable Functions •Wrap up 3
  • 4. Microsoft Azure The evolution of application platforms 4
  • 5. Microsoft Azure What is serverless? 5
  • 6. Microsoft Azure Focus on code, not plumbing 6
  • 7. Microsoft Azure FaaS is at the center of serverless 7 Functions-as-a-service programming model use functions to achieve true serverless compute
  • 8. Microsoft Azure What is Azure Functions?
  • 10. Microsoft Azure Pattern #1: Function chaining Problems: • No visualization to show relationships between functions and queues • Middle queues are an implementation detail – conceptual overhead • Error handling adds a lot more complexity 10
  • 11. Microsoft Azure Pattern #2: Fan-out/fan-in 11 Problems: • Fanning-out is easy, but fanning-in is significantly more complicated • Functions offers to help with this scenario today • All the same problems as the previous pattern
  • 12. Microsoft Azure Introducing Durable Functions • Write long-running orchestration as a single function while maintaining local state • Simplify complex transactions and coordination (chaining, fan-out/fan-in, etc.) with a new function called orchestrator function • All of the above using code-only. No JSON schemas. No UI/graphical designer • Support for C#, F#, and JavaScript (in preview) 12
  • 13. Microsoft Azure Durable Functions Components The Durable Functions has 3 components: • Starter Function • Orchestrator Function • Activity Functions 13
  • 14. Microsoft Azure Prerequisites •Install Visual Studio 2017 and ensure Azure development workload is installed. •Install the latest Azure Functions tools. •Verify you have the Azure Storage Emulator installed and running. 14
  • 16. Microsoft Azure The Code Function chaining sample This was scaffolded out by the Visual Studio templates. 16
  • 17. Microsoft Azure Starter Function The Orchestration Client is the entry point (starter function). Notice the OrchestrationClient attribute. 17
  • 18. Microsoft Azure URLs for checking status of execution • StatusQueryGetUri - Get the status of a running orchestration instance. • SendEventPostUri - Send an event notification to a running orchestration instance. • TerminatePostUri - Terminate an instance of a running orchestration. • RewindPostUri - Rewind a running orchestration instance to a replay events from a previous checkpoint. 18
  • 19. Microsoft Azure Orchestrator Function Orchestration function is the conductor and responsible for coordinating requests to activity functions 19
  • 20. Microsoft Azure Activity Function The activity function is the equivalent of a regular Azure Function with the difference – invoked by a durable orchestrator. 20
  • 22. Microsoft Azure “Hello Amsterdam!”[“Hello Amsterdam!”] Orchestrator Function Activity Function Execution History var outputs = new List<string>(); outputs.Add(await context.CallActivityAsync<string>("SayHello", “Amsterdam")); return outputs; Orchestrator Function ? Activity Function “Hello Amsterdam!” Orchestrator Started Execution Started Task Scheduled, SayHello, “Amsterdam” Orchestrator Completed Task Completed, “Hello Amsterdam!” Orchestrator Started Execution Completed, ["Hello Amsterdam!"] Orchestrator Completed
  • 26. Microsoft Azure Orchestration Constraints • Orchestrator code must be deterministic • Never use random numbers, DateTime.UtcNow, Guid.NewGuid(), etc. • Use DurableOrchestrationContext.CurrentUtcDateTime • Orchestrator code should be non-blocking. Never do I/O directly in the orchestrator • Do I/O in activity functions • Don't write infinite loops • Use DurableOrchestrationContext.ContinueAsNew()
  • 27. Microsoft Azure Summary •Azure Durable Functions make managing state and complex workflows easy and familiar •Now generally available and includes the following: • Improved performance • Large message support • Application Insights diagnostics • Logic Apps integration 27
  • 29. Microsoft Azure References • Durable Function Docs: http://aka.ms/durablefunctions • GitHub: • https://github.com/Azure/azure-functions-durable-extension • https://github.com/Azure/durabletask/tree/azure-functions • Orchestrator code constraints • Develop Azure Functions using Visual Studio • Serverless use cases and best practices • Azure Durable Functions: before and after 29

Editor's Notes

  1. Overview – Serverless and what are Azure Functions Dev tooling – Tools along with deployment and monitoring capabilities
  2. Serverless is the culmination of several iterations of cloud platforms. The evolution began with physical metal in the data center and progressed through Infrastructure as a Service (IaaS) and Platform as a Service (PaaS).
  3. With serverless, infrastructure is abstracted. Serverless further abstracts servers by focusing on event-driven code. Another feature of serverless is micro-billing.
  4. Dynamically and elastically scale to meet demand. Allows you as the developer get to focus on the fun stuff…your code and business logic. Everything else is taken cared for you. This drastically increases time to market.
  5. At the center of serverless is FaaS. Break it up into single responsibility. No state…but when you require state it gets tricky.
  6. Some sequencing that needs to happen and I have to chain them all together. If I want to parallel some work and then pull in the results into one function Waiting for external events Watcher pattern Long running http requests Human interaction and I don’t want to wait forever…I want a timeout. The answer to some of these is I don’t know. Let’s take a look at two patterns and how we can solve them
  7. Durable Functions is an open source framework for Azure Functions. Allows you to coordinate long running stateful workflows in code. They define workflows in code. No JSON schemas or designers are needed. They can call other functions synchronously and asynchronously. Output from called functions can be saved to local variables. They automatically checkpoint their progress whenever the function awaits. Local state is never lost if the process recycles or the VM reboots. Similar to Logic Apps but without a workflow designer.
  8. In Durable Functions we introduce the concept of an orchestrator function. The starter function triggers the orchestrator to start the execution. Often this starter function is an Http endpoint. Once the starter has called the orchestrator function, it goes to sleep for the rest of the day or until it’s triggered again. This reduces the cost significantly. The orchestrator function is responsible for calling and receiving the output of the activity functions (what you know as normal functions). The activity function output becomes part of the local state of the orchestrator function.
  9. Using this client, you start a new Orchestration function with the StartNewAsync(string, object) where the 1st parameter is the name of the durable orchestrator function and the 2nd parameter is the JSON-serializable input value which you would use to provide input data to the orchestrator. The second key thing to notice is that the orchestration client returns a CheckStatusResponse which contains a set of URLs for inspecting the status of an orchestration execution. The default endpoints you get back are:
  10. You will notice that the function is decorated with a OrchestrationTrigger attribute which exposes the DurableOrchestrationContext This context is what is used to invoke and interact with Activity functions. As mentioned above, orchestrator functions checkpoint their progress after each await. The above code therefore executes each Activity function in series, only progressing to the next function after the current invoked function returns. If you wanted to execute all of the above Activity functions in parallel, you would create a list of Task objects that represent the asynchronous operations and then call Task.WhenAll(List<Task<string>)
  11. It performs some logic in a stateless way and returns a response to it’s parent orchestration function. You will notice that this function is decorated with an ActivityTrigger attribute.
  12. We can easily test this out by pasting the starter function URL into the browser or via PostMan. We will then get back a list of URLs as mentioned earlier. If we navigate to the StatusQueryGerUri, we can observe the status of the durable function instance. In this example the orchestrator client is an HttpTrigger. It’s important to note that the OrchestratorClient can be triggered by any of the supported Azure Function triggers: TimerTrigger, QueueTrigger, CosmosDbTrigger, etc.
  13. 22
  14. Orchestrator code must be deterministic, as it will be replayed multiple times and must produce the same result each time.