Marcin Niesyn | Cloud Services | 29.11.2021
Business process automation is a natural transformation that most companies have to get on board with. It is not an easy process, as it requires knowledge and experience. But the battle is not yet lost! In this article, I would like to present the Azure Durable Function solution, an Azure Function Extension, which will allow you to proceed smoothly throughout the development process. Read on to find out more about serverless workflow orchestration.
Usually, the system we develop isn’t just “a set of functionalities or modules” (Function-as-a-Service), but rather “a set of multiple functionalities and modules influencing one another, dependent and interacting”. Thanks to the Azure Durable Functions, we are able to master this process. Azure Durable Function is the orchestrator controlling the entire business process, meaning our workflow. Durable Function is an extension of Azure Functions which allows you to optimize processes in a serverless environment.
Azure Durable Function consists of 3 basic types of blocks:
A kind of starter that gets the process up and running. It is most often triggered by an http request, adding a record to the database, uploading a file, etc.
The process that controls our workflow – this is where we set up the sequence of steps in the process.
A specific functionality, e.g. retrieving a record from a database, sending an e-mail, issuing an invoice, etc.
For the purposes of the article, let’s assume that we run a web fashion store, and after the payment has been credited, we want to present the customer with possible color versions and, once the decision has been made, close the order. The initial process would look like this:
Now let’s try to answer the following questions:
As you can see, there are a number of problems. The process is not perfect and cannot be easily controlled. Let’s get started and make sure it’s done right!
We begin with the ‘starter’:
We have created a function that is triggered by an http request and receives information about the order. Its key element is the type object IDurableOrchestrationClient, which starts the selected process.
In its initial, simplified form, it might just look like this:
As you can see, it’s a place from which we can control the entire ordering process.
To put it very simply, without diving into too much detail, the individual steps of the process, i.e. the Activity Function, can look like this:
Let’s make modifications to find clear answers to the questions previously asked:
Now we can see the significant changes:
The last question is: how do we monitor the state of the process? By default, after starting the orchestrator, we get a set of links to the list of workflow operations:
So to monitor the current status of the process, just call statusQueryGetUri and as a result, you will get, for example:
We see that the process is now over and it can be considered completed.
To sum up, thanks to the use of Azure Durable Function, you can freely create complicated workflows and fully control them. Native functions can work with the entire cloud ecosystem, so the possibilities of expansion are endless. What’s more, there is an option to use containers of functions in the on-premise environment – but that’s a matter for a separate article.