Learn About Azure Durable Functions

Azure Durable Functions is an extension of Azure Functions that lets you write stateful functions in a serverless environment.

You can write orchestrator functions that coordinate multiple tasks across various services.

Durable Functions let you write code in a declarative, asynchronous programming model that is easy to understand and debug.

You can use Durable Functions to build long-running workflows, generate summaries from event streams, and process data files in parallel.

It is built on top of Azure Storage and uses the same internals as the Azure Functions runtime. This makes Durable Functions apps highly available and scalable.

To use it, you must create a new Azure Functions app and enable the Durable Functions extension.

Once you have created a new Azure Functions app, you can add it by going to the Extensions tab and searching for Durable Functions.

Once you have added the extension, you will see a new tab called Durable Functions in the Azure Functions portal.

To create a new Durable Functions app, click on the + sign next to Durable Functions in the portal.

Enter a name for your app and select a location. Then, click on the Create button.

Once your app has been created, you can add Durable Functions by clicking the + sign next to Functions in the portal.

Enter a name for your function and select a language.

Once you have created your function, you can add code by clicking on the Code tab in the portal.

The following is a sample orchestrator function that coordinates two tasks. The first task calls an HttpTrigger JavaScript function. The second task calls a QueueTrigger C# function.

public static async Task Run(DurableOrchestrationContext context)
{
    var output = await context.CallActivityAsync("HttpTrigger", null);
    await context.CallActivityAsync("QueueTrigger", output);
}

Use Durable Function with Kafka

Azure Durable Functions with Kafka is an ideal way to process large amounts of data in a highly scalable and reliable manner. When using Kafka with Durable Functions, each message is processed as a separate function instance, which allows for parallel processing and high throughput. In addition, using Kafka means that messages can be processed in order and exactly once, which is essential for many applications.

[FunctionName("HelloWorld")]
public static async Task < string > Run([KafkaTrigger("bootstrap.servers", "my-topic", ConsumerGroup = "my-consumer-group", Protocol = BrokerProtocol.SaslSsl, Username = "$ConnectionString", Password = "PLACEHOLDER")] string message, ILogger log) {
    log.LogInformation($ "Received message: {message}");
    return message;
}

In the code above, we're using the KafkaTrigger attribute to specify the Kafka server and topic to consume messages. We also use the ConsumerGroup and Protocol properties to select the consumer group and SASL/SSL protocol.

Supported languages*

Durable Functions is designed to work with all Azure Functions programming languages but may have different minimum requirements for each language. The following table shows the minimum supported app configurations:

Language stack Azure Functions Runtime versions Language worker version Minimum bundles version
.NET / C# / F# Functions 1.0+ In-process (GA)
Out-of-process (preview)
n/a
JavaScript/TypeScript Functions 2.0+ Node 8+ 2.x bundles
Python Functions 2.0+ Python 3.7+ 2.x bundles
PowerShell Functions 3.0+ PowerShell 7+ 2.x bundles
Java Functions 4.0+ Java 8+ 4.x bundles

This article is not intended to discuss the technology itself intensely but for you to become aware of this incredible technology.

Here you will find how to get started with Durable Functions.

*Information from https://learn.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-overview?tabs=csharp

Let's do it!

Learn about Azure Durable Functions