We have already discussed
a quite a bit about Azure Durable Functions. I did write up on bit of history and why we need Azure
Durable functions. You can read that article here..link below
Why do we need Azure Durable Functions and its history
I also wrote about
what are azure durable functions
If you want to get hands on and get some dev experience , here is
a good point of start
Simple Azure Durable function implementation
If you keen to know the differences between Logic Apps and Azure
Durable functions then read my blog on
What is difference between Azure Durable Function & Logic App
We know that Durable Functions helps us simplify complex scenarios where state management is required in serverless applications. In this article, we will discuss various application patterns. These kinds of functions can be used for the following patterns:
I always like to depict the comparison as a diagram as I guess it helps understand the difference better. Please find below the comparison
I have already discussed Function Chaining approach in my previous
article. I used that approach to solve our hypothetical example
complexity. Link to that article
What are Azure durable functions
In Why do we need Azure Durable Functions and its history we also discussed a scenario when we might have to run functions/actions in parallel.For instance, what if we need to reconcile outputs of each task. Say your manager wants to know how much the whole trip cost to the company. And Fan out/Fan-in is the perfect use case to solve that issue.In our example,Book Bus action and Book accomodation action, results need to be reconciled and then run a separate azure function may be called CostToCompany which will do reporting task.CostToCompany the function may link to the database and add it to say some expenses table.Or maybe will generate some reports. It is up to you/CostToCompany task what you want to do with the expenses received.To solve this kind of problem we need Sub-orchestrators.Sub-orchestrators/child orchestrators are called by the "parent" orchestrator. Parent calls the child orchestrator using context. CallSubOrchestratorAsync method:
[FunctionName("MyParallelWorkFlow")]
public static async Task Sequential([OrchestrationTrigger] DurableOrchestrationContext context)
{
//Any other actions go here
var reserveBus = context.CallSubOrchestratorAsync("ReserveBus", bookBus);
var bookAccomodation = context.CallSubOrchestratorAsync("BookAccomodation", bookAccomodation);
var expenses= await Task.WhenAll(reserveBus, bookAccomodation);
await context.CallActivityAsync("CostToCompany", expenses);
}
Task.WhenAll returns an array of results (one result per each input task).This array of result is then passed on to the reporting activity.
To conclude,I hope you would have got the basics of various application patterns available and that can benefit from Azure Durable function.
Email me at "techspacedeck@gmail.com" incase you have queries. Alternatively, you can fill the "CONTACT" form or drop a comment below