Understanding workflows

A workflow is a series of steps or activities that are executed either in parallel or in sequence, or in a combination of the two. Since activities can be executed in parallel, they can perform jobs across multiple services at the same time without being blocked.

The following are the features of workflows:

Azure Functions need to have finished executing within 5 minutes. This means they are short-lived, and composing workflows with them can really be difficult. There is the possibility of implementing multiple functions and ensuring they are coordinated to execute one after another. Even this endeavor has its limitations.

This is more of a hack and needs considerable effort, design, and operations. All the Functions will need to have inputs tied to the outputs of their previous Function, and each Function will still run for few minutes. Another drawback of implementing workflows this way is that it is extremely difficult to understand their connectivity, dependency, and sequence of execution at a glance. In short, Azure Functions are good for implementing a single responsibility that is short-lived. They are not well suited for implementing workflows.

Another important feature of Azure Functions is that they are stateless. This means that the Functions are fleeting, available only at the time they are being executed. One Function instance execution has no relation to the previous or consequent running instance. This means there is no possibility of storing state with Azure Functions.

Azure Functions can run on any server behind the scenes, and that server might not be the same as in subsequent executions. This means Functions cannot store their state in the server they are executed on.

The only way to save state in Azure Functions is to store state externally in data stores such as Cosmos DB, SQL databases, or Azure Storage. But this design will have significant performance issues, since every time the Function executes, it would need to connect to a data store, retrieve, and eventually write to it. Now that we have looked into understanding workflows, we will proceed with Durable Functions.