Durable Functions is a new extension of Azure Functions which manages state, checkpoints and restarts for you. Durable Functions provide the capability to code stateful functions in a serverless environment. This new extension enables a new type of function called an orchestrator. The primary use case for Durable Functions is to simplify complex, stateful coordination problems in serverless applications. Some advantages of an orchestrator function are:

  • Workflows are defined in code. This means no JSON schemas or designers are needed.
  • Other functions can be called synchronously or asynchronously. Output from functions can be saved to local variables.
  • Automatic checkpoint the progress of the function whenever it awaits. This means local state is never lost if the process recycles or the VM reboots.

The following are 5 sample patterns where Durable Functions can help.

Pattern #1: Function Chaining

Function chaining is the execution of functions in sequence where the output of one function is the input to another function. With this pattern you typically use queues to pass state from function to function.

Function chaining diagram

Pattern #2: Fan-out/Fan-in

Fan-out/Fan-in refers to the execution of multiple functions in parallel and then waiting for all of them to finish. This pattern also uses queues to manage state from start to end. Fanning back in is much more complicated as you would have to track the outputs of all the functions waiting for them to finish.

Fan-out/fan-in diagram 

Pattern #3: Async HTTP APIs

Async HTTP APIs pattern is all about the problem of coordinating the state of long running operations with external APIs. With this pattern you often use another status endpoint for the client to check on the status of the long running operation.

HTTP API diagram

Pattern #4: Monitoring

The Monitoring pattern is a recurring process in a workflow where the function polls for a certain condition to be met. A simple timer trigger could address this but its interval is static and management of it is more complex.

Monitor diagram

Pattern #5: Human Interaction

Finally we have the Human Interaction pattern. This pattern is where a function executes but its process is gated based on some sort of human interaction. People are not always available or respond in a timely manner which introduces complexity to your function process.

Human interaction diagram

In all five use cases, Durable Functions provides built-in support for easily handling these scenarios without the need extra resources likes queues, timers, etc for managing state and controlling the function flow. For more information on each of these patterns and code samples please see the Durable Functions documentation.

Durable Functions is currently in preview and is an advanced extension for Azure Functions that is not appropriate for all scenarios. Next month is the annual Microsoft developer conference Build. I suspect we’ll see some new exciting details with Azure Functions and Durable Functions specifically. Hopefully they become generally available.

Enjoy!

References

Overview of Azure Functions

Durable Functions Documentation

Posted by Callon Campbell [MVP]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s