Durable Functions is an extension that helps developers build reliable, stateful apps on the Azure Functions platform.
This extension adds three new types functions to the Azure Functions family:
- Orchestrator functions: Long-running, reliable workflow functions written in code that schedule and coordinate other functions.
- Activity functions: Stateless functions that are the basic unit of work in a durable function orchestration.
- Entity functions: Stateful actor-like functions that have identities and store state explicitly.
Durable Functions can run anywhere that Azure Functions can run, including in the Azure Functions "Serverless" Consumption plan, the Elastic Premium plan, on Kubernetes, or even locally for development using Visual Studio or Visual Studio Code.
For a more detailed overview, including examples of what you can do with Durable Functions, see our What is Durable Functions? article.
This type of azure durable function allows us to start several functions(tasks) simultaneously and do an aggregation of the results.
Fan-Out/Fan-In Azure Durable Function helps us to optimize our solutions when we have a very heavy workload by dividing it to smaller blocks(task) which are executed concurrently. At the end of the execution of these tasks, an aggregation of the results is made. The result obtained can be reused to perform other tasks, for example ratio calculations.
We are going to do a little demo with Fan-Out/Fan-In using the ASP.NET/C# Framework.
- First we retrieve a list of products from the database AdventureWorks2012
- Then we retrieve the list of sales of all products in parallel.
- At the end, we aggregate all product sales.
To install this project in your computer, you must install these prerequisites listed below:
You need to create a local.setting.json file in the project folder of the project then add the contents of the json below in this file..
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"AzureWebJobsSecretStorageType": "files",
// FeatureFlags
"FeatureFlags:EnableMonitor": true,
// ConnectionStrings
"ConnectionStrings:DefaultConnection": ""
}
}
In this project, we have implemented a monitor that allows us to follow the execution of our functions and to see the returned values. This feature FeatureFlags can be used to enable/disable this monitor.
- Monitor home page
2. example of running tasks in parallel with the monitor interface.
- Fan-out/fan-in Azure Durable Function
- DurableFunctionsMonitor.DotNetBackend (The monitot for Azure Function with ASP.NET/C#)