Durable Functions Orchestration Basics
Explore how to orchestrate workflows using Azure Durable Functions. Understand starting orchestrators via HTTP triggers, triggering activity functions, and managing state through Azure Storage queues to handle long-running processes efficiently.
We'll cover the following...
In this lesson, we will have a look at how the orchestration process works in Durable Functions. We will do so with the help of the interactive playground below:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="2.9.2" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.1.1" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>In this setup, we have a simple HTTP trigger that starts the orchestrator. The orchestrator then triggers a basic activity function that returns a message based on its input.
Starting the orchestrator
When the trigger function starts the orchestrator, behind the scenes, a message is placed on a queue in the Azure Storage Account. This is why we need access to a Storage Account for a durable function to work.
In the example above, we start the orchestrator in line 35 of the Functions.cs file, which looks like this:
string instanceId = await starter.StartNewAsync("Function", null);