SlideShare a Scribd company logo
Building a document e-
signing workflow with
Durable Functions
Joonas Westlin
Speaker Intro
• Joonas Westlin
• Developer / Architect @ Zure
• Azure MVP
• Global #9 on Stack Overflow for Azure
answers
@JoonasWestlin
joonasw.net
Contents
• An e-signing workflow
• Workflows? Orchestrations? Activities?
• What is Durable Functions and what can you use it for?
• Demo: Building the signing workflow
• Useful things to know
• Conclusions and Q&A
• Links
An e-signing workflow
User uploads
document
Send email to
signers
Wait for signer
response
Create signed
document
Send
completion
email
Users download
signed
document
Workflows? Orchestrations? Activities?
• A workflow is an orchestrated sequence of activities that describes a process
• An activity is a step in a workflow
• Orchestration refers to automatic management of workflows
• In this context at least
What is Durable Functions?
• Framework built on Azure Functions and the Durable Task framework
• Build durable serverless workflows in C# / JavaScript
• State persisted in Table Storage -> Durable
• Storage Queue messages used under the hood to communicate
• Three types of functions: Orchestrator, Activity, and Entity
• Orchestrators can be started by any other Azure Function
Use cases for
Durable Functions
Function chaining
Fan out – fan in
External events and human interaction
Approved
Rejected
Wait for
approval
Monitoring
Poll status
Repeat
Why orchestrators and activities?
• Orchestrator functions:
• Define steps of the workflow
• State is persisted in history table
• Code is replayed as the workflow progresses
• Require code to be deterministic
• Can start sub-orchestrators and activities
• Activity functions:
• Steps in the workflow
• Can do I/O
• Can be non-deterministic
Code replay
• When an orchestrator hits an await/yield for a sub-orchestrator or activity:
• Message is posted to a queue
• The orchestrator is suspended
• Once result is available, a queue message wakes up the orchestrator
• The code is executed again; this time it will continue past the await/yield call
• History table tells it that the activity was completed
• Can check if we are currently replaying from the context object
Sample orchestrator
Execution history
Execution started
Orchestrator started
Activity scheduled
Orchestrator completed
Activity completed
Orchestrator started
Activity scheduled
Orchestrator completed
Activity completed
Orchestrator started
Activity scheduled
Orchestrator completed
Activity completed
Orchestrator started
Orchestrator completed
Execution completed
Determinism
• Required in orchestrator function code due to replay
• With the same inputs, the same code path is taken and the same output is produced
• DateTime.UtcNow is non-deterministic, because it gives a different result
depending on time
• Other examples of things you cannot do/use:
• Randomness
• Guid.NewGuid()
• I/O, database queries
• CPU-intensive computation, multi-threading, thread blocking
• Orchestration context object has deterministic versions of some of these
• HTTP API calls are also possible, but flexibility is limited
Sample activity
• Activities are where
you will do:
• Database queries
• API calls with
maximum flexibility
• Other non-
deterministic things
• Their results are
persisted in the
history table
Workflow that we will build
Waitfor
signaturesub-
orchestrator
Mainorchestrator
Mark workflow
started in database
Send emails to
signers
Set instance id to
database
Wait for signing
event
Signer
responded on
time?
Yes
Set signing data in
database
Did allsigners
sign?
No
No
Send completion
email
Start
Yes
Create signed
document
Mark workflow
completed in
database
End
Demo: Building the signing
workflow
Useful things to know
Error handling
• Use try-catch around activity / sub-orchestrator calls to catch errors thrown
in them
• Compensate or re-throw
• Use retries: CallActivityWithRetryAsync / CallSubOrchestratorWithRetryAsync
• Retry with optional back-off coefficient
Monitoring Durable Functions
• Application Insights works, but end-to-
end tracing does not work correctly
• Use context.CreateReplaySafeLogger()
to prevent duplicate log messages
Use the .NET analyzers
• Microsoft.Azure.WebJobs.Extensions.DurableTask.Analyzers
• Gives you warnings if you:
• Break determinism in orchestrators
• Use the wrong parameter type for activities or sub-orchestrators
• And much more
Handling code complexity
• Divide and conquer
• Split complex orchestrator functions into sub-orchestrators
• Can also split into methods; Use [Deterministic] on them
• A long activity function might be doing too much work, split it
Updating Durable Functions
• When deploying new versions, you must think about existing orchestrations
• Having the orchestrator code change would be a violation of determinism
• Versioning strategies:
• Let the old orchestrations fail by changing the function name
• Create the new version side-by-side as a new function and delete the old one later
• Deploy new function app
• https://docs.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-
versioning
Summary and takeaways
• Build workflows in code with Durable Functions
• Implement patterns like function chaining, fan-out / fan-in, and human
interaction
• Use orchestrator functions to build the overall workflow and call activities
• Orchestrator code must be deterministic
• Use activity functions to do database queries, send emails, heavy
computation etc.
• Monitoring is currently not the best but is improving
• Be careful when updating orchestrators
Q&A
Links
• https://westl.in/globalazure2020
• https://docs.microsoft.com/en-us/azure/azure-functions/durable/durable-
functions-overview
• Concepts section is awesome
• https://markheath.net/category/durable%20functions
• https://dontcodetired.com/blog/?tag=durable+functions
• https://github.com/juunas11/Joonasw.ElectronicSigningDemo
Building a document e-signing workflow with Azure Durable Functions

More Related Content

Similar to Building a document e-signing workflow with Azure Durable Functions

Deep Dive into Durable Functions
Deep Dive into Durable FunctionsDeep Dive into Durable Functions
Deep Dive into Durable Functions
Joonas Westlin
 
Deep Dive into Durable Functions
Deep Dive into Durable FunctionsDeep Dive into Durable Functions
Deep Dive into Durable Functions
Joonas Westlin
 
Azure Function Workflow
Azure Function WorkflowAzure Function Workflow
Azure Function Workflow
Andrea Tosato
 
#SPFestDC #Azure #Functions V2: What's new and getting started
#SPFestDC #Azure #Functions V2: What's new and getting started#SPFestDC #Azure #Functions V2: What's new and getting started
#SPFestDC #Azure #Functions V2: What's new and getting started
Vincent Biret
 
Scheduling Thread
Scheduling  ThreadScheduling  Thread
Scheduling Thread
MuhammadBilal187526
 
#SPFestSea Introduction to #Azure #Functions v2
#SPFestSea Introduction to #Azure #Functions v2#SPFestSea Introduction to #Azure #Functions v2
#SPFestSea Introduction to #Azure #Functions v2
Vincent Biret
 
Give your little scripts big wings: Using cron in the cloud with Amazon Simp...
Give your little scripts big wings:  Using cron in the cloud with Amazon Simp...Give your little scripts big wings:  Using cron in the cloud with Amazon Simp...
Give your little scripts big wings: Using cron in the cloud with Amazon Simp...
Amazon Web Services
 
Azure functions
Azure functionsAzure functions
Azure functions
Rajesh Kolla
 
O365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
O365Con18 - Automate your Tasks through Azure Functions - Elio StruyfO365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
O365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
NCCOMMS
 
Azure Functions in Action #CodePaLOUsa
Azure Functions in Action #CodePaLOUsaAzure Functions in Action #CodePaLOUsa
Azure Functions in Action #CodePaLOUsa
Baskar rao Dsn
 
Durable Azure Functions
Durable Azure FunctionsDurable Azure Functions
Durable Azure Functions
Pushkar Saraf
 
Serverless Solutions for developers
Serverless Solutions for developersServerless Solutions for developers
Serverless Solutions for developers
Juan Pablo
 
Reactive Development: Commands, Actors and Events. Oh My!!
Reactive Development: Commands, Actors and Events.  Oh My!!Reactive Development: Commands, Actors and Events.  Oh My!!
Reactive Development: Commands, Actors and Events. Oh My!!
David Hoerster
 
Manage your devices with Azure IoT...and more
Manage your devices with Azure IoT...and moreManage your devices with Azure IoT...and more
Manage your devices with Azure IoT...and more
Marco Parenzan
 
Azure Functions in Action #OrlandoCC
Azure Functions in Action #OrlandoCCAzure Functions in Action #OrlandoCC
Azure Functions in Action #OrlandoCC
Baskar rao Dsn
 
Introduction to Long Running Workflows 3.7
Introduction to Long Running Workflows 3.7Introduction to Long Running Workflows 3.7
Introduction to Long Running Workflows 3.7
StephenKardian
 
Microservices for java architects it-symposium-2015-09-15
Microservices for java architects it-symposium-2015-09-15Microservices for java architects it-symposium-2015-09-15
Microservices for java architects it-symposium-2015-09-15
Derek Ashmore
 
7 steps to simplifying your AI workflows
7 steps to simplifying your AI workflows7 steps to simplifying your AI workflows
7 steps to simplifying your AI workflows
Wisecube AI
 
Getting Started with Serverless Architectures
Getting Started with Serverless ArchitecturesGetting Started with Serverless Architectures
Getting Started with Serverless Architectures
Amazon Web Services
 
Architecting for Microservices Part 2
Architecting for Microservices Part 2Architecting for Microservices Part 2
Architecting for Microservices Part 2
Elana Krasner
 

Similar to Building a document e-signing workflow with Azure Durable Functions (20)

Deep Dive into Durable Functions
Deep Dive into Durable FunctionsDeep Dive into Durable Functions
Deep Dive into Durable Functions
 
Deep Dive into Durable Functions
Deep Dive into Durable FunctionsDeep Dive into Durable Functions
Deep Dive into Durable Functions
 
Azure Function Workflow
Azure Function WorkflowAzure Function Workflow
Azure Function Workflow
 
#SPFestDC #Azure #Functions V2: What's new and getting started
#SPFestDC #Azure #Functions V2: What's new and getting started#SPFestDC #Azure #Functions V2: What's new and getting started
#SPFestDC #Azure #Functions V2: What's new and getting started
 
Scheduling Thread
Scheduling  ThreadScheduling  Thread
Scheduling Thread
 
#SPFestSea Introduction to #Azure #Functions v2
#SPFestSea Introduction to #Azure #Functions v2#SPFestSea Introduction to #Azure #Functions v2
#SPFestSea Introduction to #Azure #Functions v2
 
Give your little scripts big wings: Using cron in the cloud with Amazon Simp...
Give your little scripts big wings:  Using cron in the cloud with Amazon Simp...Give your little scripts big wings:  Using cron in the cloud with Amazon Simp...
Give your little scripts big wings: Using cron in the cloud with Amazon Simp...
 
Azure functions
Azure functionsAzure functions
Azure functions
 
O365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
O365Con18 - Automate your Tasks through Azure Functions - Elio StruyfO365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
O365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
 
Azure Functions in Action #CodePaLOUsa
Azure Functions in Action #CodePaLOUsaAzure Functions in Action #CodePaLOUsa
Azure Functions in Action #CodePaLOUsa
 
Durable Azure Functions
Durable Azure FunctionsDurable Azure Functions
Durable Azure Functions
 
Serverless Solutions for developers
Serverless Solutions for developersServerless Solutions for developers
Serverless Solutions for developers
 
Reactive Development: Commands, Actors and Events. Oh My!!
Reactive Development: Commands, Actors and Events.  Oh My!!Reactive Development: Commands, Actors and Events.  Oh My!!
Reactive Development: Commands, Actors and Events. Oh My!!
 
Manage your devices with Azure IoT...and more
Manage your devices with Azure IoT...and moreManage your devices with Azure IoT...and more
Manage your devices with Azure IoT...and more
 
Azure Functions in Action #OrlandoCC
Azure Functions in Action #OrlandoCCAzure Functions in Action #OrlandoCC
Azure Functions in Action #OrlandoCC
 
Introduction to Long Running Workflows 3.7
Introduction to Long Running Workflows 3.7Introduction to Long Running Workflows 3.7
Introduction to Long Running Workflows 3.7
 
Microservices for java architects it-symposium-2015-09-15
Microservices for java architects it-symposium-2015-09-15Microservices for java architects it-symposium-2015-09-15
Microservices for java architects it-symposium-2015-09-15
 
7 steps to simplifying your AI workflows
7 steps to simplifying your AI workflows7 steps to simplifying your AI workflows
7 steps to simplifying your AI workflows
 
Getting Started with Serverless Architectures
Getting Started with Serverless ArchitecturesGetting Started with Serverless Architectures
Getting Started with Serverless Architectures
 
Architecting for Microservices Part 2
Architecting for Microservices Part 2Architecting for Microservices Part 2
Architecting for Microservices Part 2
 

More from Joonas Westlin

Using feature flags in an ASP.NET Core app on Azure
Using feature flags in an ASP.NET Core app on AzureUsing feature flags in an ASP.NET Core app on Azure
Using feature flags in an ASP.NET Core app on Azure
Joonas Westlin
 
Zero Credential Development with Managed Identities
Zero Credential Development with Managed IdentitiesZero Credential Development with Managed Identities
Zero Credential Development with Managed Identities
Joonas Westlin
 
Zero Credential Development with Managed Identities
Zero Credential Development with Managed IdentitiesZero Credential Development with Managed Identities
Zero Credential Development with Managed Identities
Joonas Westlin
 
Zero credential development with managed identities
Zero credential development with managed identitiesZero credential development with managed identities
Zero credential development with managed identities
Joonas Westlin
 
Zero credential development with managed identities
Zero credential development with managed identitiesZero credential development with managed identities
Zero credential development with managed identities
Joonas Westlin
 
Zero Credential Development with Managed Identities for Azure resources
Zero Credential Development with Managed Identities for Azure resourcesZero Credential Development with Managed Identities for Azure resources
Zero Credential Development with Managed Identities for Azure resources
Joonas Westlin
 
Zero Credential Development with Managed Identities
Zero Credential Development with Managed IdentitiesZero Credential Development with Managed Identities
Zero Credential Development with Managed Identities
Joonas Westlin
 
7 Deadly Sins in Azure AD App Development
7 Deadly Sins in Azure AD App Development7 Deadly Sins in Azure AD App Development
7 Deadly Sins in Azure AD App Development
Joonas Westlin
 
Introduction to Azure AD and Azure AD B2C
Introduction to Azure AD and Azure AD B2CIntroduction to Azure AD and Azure AD B2C
Introduction to Azure AD and Azure AD B2C
Joonas Westlin
 
Get rid of credentials from your code: Using Managed identities for Azure res...
Get rid of credentials from your code: Using Managed identities for Azure res...Get rid of credentials from your code: Using Managed identities for Azure res...
Get rid of credentials from your code: Using Managed identities for Azure res...
Joonas Westlin
 
Programming with Azure Active Directory
Programming with Azure Active DirectoryProgramming with Azure Active Directory
Programming with Azure Active Directory
Joonas Westlin
 

More from Joonas Westlin (11)

Using feature flags in an ASP.NET Core app on Azure
Using feature flags in an ASP.NET Core app on AzureUsing feature flags in an ASP.NET Core app on Azure
Using feature flags in an ASP.NET Core app on Azure
 
Zero Credential Development with Managed Identities
Zero Credential Development with Managed IdentitiesZero Credential Development with Managed Identities
Zero Credential Development with Managed Identities
 
Zero Credential Development with Managed Identities
Zero Credential Development with Managed IdentitiesZero Credential Development with Managed Identities
Zero Credential Development with Managed Identities
 
Zero credential development with managed identities
Zero credential development with managed identitiesZero credential development with managed identities
Zero credential development with managed identities
 
Zero credential development with managed identities
Zero credential development with managed identitiesZero credential development with managed identities
Zero credential development with managed identities
 
Zero Credential Development with Managed Identities for Azure resources
Zero Credential Development with Managed Identities for Azure resourcesZero Credential Development with Managed Identities for Azure resources
Zero Credential Development with Managed Identities for Azure resources
 
Zero Credential Development with Managed Identities
Zero Credential Development with Managed IdentitiesZero Credential Development with Managed Identities
Zero Credential Development with Managed Identities
 
7 Deadly Sins in Azure AD App Development
7 Deadly Sins in Azure AD App Development7 Deadly Sins in Azure AD App Development
7 Deadly Sins in Azure AD App Development
 
Introduction to Azure AD and Azure AD B2C
Introduction to Azure AD and Azure AD B2CIntroduction to Azure AD and Azure AD B2C
Introduction to Azure AD and Azure AD B2C
 
Get rid of credentials from your code: Using Managed identities for Azure res...
Get rid of credentials from your code: Using Managed identities for Azure res...Get rid of credentials from your code: Using Managed identities for Azure res...
Get rid of credentials from your code: Using Managed identities for Azure res...
 
Programming with Azure Active Directory
Programming with Azure Active DirectoryProgramming with Azure Active Directory
Programming with Azure Active Directory
 

Recently uploaded

Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Software Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdfSoftware Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdf
MayankTawar1
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
KrzysztofKkol1
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
Jelle | Nordend
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024
Sharepoint Designs
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 

Recently uploaded (20)

Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Software Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdfSoftware Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdf
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 

Building a document e-signing workflow with Azure Durable Functions

  • 1. Building a document e- signing workflow with Durable Functions Joonas Westlin
  • 2. Speaker Intro • Joonas Westlin • Developer / Architect @ Zure • Azure MVP • Global #9 on Stack Overflow for Azure answers @JoonasWestlin joonasw.net
  • 3. Contents • An e-signing workflow • Workflows? Orchestrations? Activities? • What is Durable Functions and what can you use it for? • Demo: Building the signing workflow • Useful things to know • Conclusions and Q&A • Links
  • 4. An e-signing workflow User uploads document Send email to signers Wait for signer response Create signed document Send completion email Users download signed document
  • 5. Workflows? Orchestrations? Activities? • A workflow is an orchestrated sequence of activities that describes a process • An activity is a step in a workflow • Orchestration refers to automatic management of workflows • In this context at least
  • 6. What is Durable Functions? • Framework built on Azure Functions and the Durable Task framework • Build durable serverless workflows in C# / JavaScript • State persisted in Table Storage -> Durable • Storage Queue messages used under the hood to communicate • Three types of functions: Orchestrator, Activity, and Entity • Orchestrators can be started by any other Azure Function
  • 9. Fan out – fan in
  • 10. External events and human interaction Approved Rejected Wait for approval
  • 12. Why orchestrators and activities? • Orchestrator functions: • Define steps of the workflow • State is persisted in history table • Code is replayed as the workflow progresses • Require code to be deterministic • Can start sub-orchestrators and activities • Activity functions: • Steps in the workflow • Can do I/O • Can be non-deterministic
  • 13. Code replay • When an orchestrator hits an await/yield for a sub-orchestrator or activity: • Message is posted to a queue • The orchestrator is suspended • Once result is available, a queue message wakes up the orchestrator • The code is executed again; this time it will continue past the await/yield call • History table tells it that the activity was completed • Can check if we are currently replaying from the context object
  • 14. Sample orchestrator Execution history Execution started Orchestrator started Activity scheduled Orchestrator completed Activity completed Orchestrator started Activity scheduled Orchestrator completed Activity completed Orchestrator started Activity scheduled Orchestrator completed Activity completed Orchestrator started Orchestrator completed Execution completed
  • 15. Determinism • Required in orchestrator function code due to replay • With the same inputs, the same code path is taken and the same output is produced • DateTime.UtcNow is non-deterministic, because it gives a different result depending on time • Other examples of things you cannot do/use: • Randomness • Guid.NewGuid() • I/O, database queries • CPU-intensive computation, multi-threading, thread blocking • Orchestration context object has deterministic versions of some of these • HTTP API calls are also possible, but flexibility is limited
  • 16. Sample activity • Activities are where you will do: • Database queries • API calls with maximum flexibility • Other non- deterministic things • Their results are persisted in the history table
  • 17. Workflow that we will build Waitfor signaturesub- orchestrator Mainorchestrator Mark workflow started in database Send emails to signers Set instance id to database Wait for signing event Signer responded on time? Yes Set signing data in database Did allsigners sign? No No Send completion email Start Yes Create signed document Mark workflow completed in database End
  • 18. Demo: Building the signing workflow
  • 20. Error handling • Use try-catch around activity / sub-orchestrator calls to catch errors thrown in them • Compensate or re-throw • Use retries: CallActivityWithRetryAsync / CallSubOrchestratorWithRetryAsync • Retry with optional back-off coefficient
  • 21. Monitoring Durable Functions • Application Insights works, but end-to- end tracing does not work correctly • Use context.CreateReplaySafeLogger() to prevent duplicate log messages
  • 22. Use the .NET analyzers • Microsoft.Azure.WebJobs.Extensions.DurableTask.Analyzers • Gives you warnings if you: • Break determinism in orchestrators • Use the wrong parameter type for activities or sub-orchestrators • And much more
  • 23. Handling code complexity • Divide and conquer • Split complex orchestrator functions into sub-orchestrators • Can also split into methods; Use [Deterministic] on them • A long activity function might be doing too much work, split it
  • 24. Updating Durable Functions • When deploying new versions, you must think about existing orchestrations • Having the orchestrator code change would be a violation of determinism • Versioning strategies: • Let the old orchestrations fail by changing the function name • Create the new version side-by-side as a new function and delete the old one later • Deploy new function app • https://docs.microsoft.com/en-us/azure/azure-functions/durable/durable-functions- versioning
  • 25. Summary and takeaways • Build workflows in code with Durable Functions • Implement patterns like function chaining, fan-out / fan-in, and human interaction • Use orchestrator functions to build the overall workflow and call activities • Orchestrator code must be deterministic • Use activity functions to do database queries, send emails, heavy computation etc. • Monitoring is currently not the best but is improving • Be careful when updating orchestrators
  • 26. Q&A
  • 27. Links • https://westl.in/globalazure2020 • https://docs.microsoft.com/en-us/azure/azure-functions/durable/durable- functions-overview • Concepts section is awesome • https://markheath.net/category/durable%20functions • https://dontcodetired.com/blog/?tag=durable+functions • https://github.com/juunas11/Joonasw.ElectronicSigningDemo

Editor's Notes

  1. Mention it isn’t really defined what happens if determinism isn’t respected. You might get wrong results from activities etc.