This template repository contains a Durable Functions sample demonstrating the fan-out/fan-in pattern in C# (isolated process model). The sample can be easily deployed to Azure using the Azure Developer CLI (azd). It uses managed identities to secure communication between services, and you can optionally create a secure deployment in a virtual network.
Durable Functions is part of Azure Functions offering. It helps orchestrate stateful logic that's long-running or multi-step by providing durable execution. An execution is durable when it can continue in another process or machine from the point of failure in the face of interruptions or infrastructure failures. Durable Functions handles automatic retries and state persistence as your orchestrations run to ensure durable execution.
Durable Functions needs a backend provider to persist application states. This sample uses the Durable Task Scheduler (DTS) backend, an Azure-managed service that provides a fully managed, serverless task scheduling and orchestration engine.
- .NET 10 SDK
- Azure Functions Core Tools
- Azure Developer CLI (
azd) - Azurite storage emulator
- To use Visual Studio to run and debug locally:
- Visual Studio 2022.
- Make sure to select the Azure development workload during installation.
- To use Visual Studio Code to run and debug locally:
You can initialize a project from this azd template in one of these ways:
-
Use this
azd initcommand from an empty local (root) folder:azd init --template durable-functions-quickstart-dotnet-azd
Supply an environment name, such as
dfquickstartwhen prompted. Inazd, the environment is used to maintain a unique deployment context for your app. -
Clone the GitHub template repository locally using the
git clonecommand:git clone https://github.com/Azure-Samples/durable-functions-quickstart-dotnet-azd.git cd durable-functions-quickstart-dotnet-azdYou can also clone the repository from your own fork in GitHub.
This sample uses a remote Durable Task Scheduler (DTS) resource in Azure as the Durable Functions backend.
Note
As an alternative to connecting to a remote DTS resource during local development, you can instead use the Durable Task Scheduler Emulator, which runs locally in a Docker container. The emulator provides a fully functional DTS instance without requiring Azure resources but does require Docker to be installed.
Run this command to provision the required Azure resources, including the DTS instance:
azd auth login
azd provisionYou're prompted to supply these required deployment parameters:
| Parameter | Description |
|---|---|
| Environment name | An environment that's used to maintain a unique deployment context for your app. You won't be prompted if you created the local project using azd init. |
| Azure subscription | Subscription in which your resources are created. |
| Azure location | Azure region in which to create the resource group that contains the new Azure resources. Only regions that currently support the Flex Consumption plan are shown. |
| vnetEnabled | Whether to deploy with a virtual network for enhanced security. Select true or false. |
After provisioning completes, a postprovision hook automatically generates the fanoutfanin/local.settings.json file with your DTS connection information.
-
Start the Azurite storage emulator. The Functions runtime requires a storage component for internal state management:
azurite
-
In a separate terminal, navigate to the
fanoutfaninfolder:cd fanoutfaninThe
fanoutfaninfolder is the root folder for the app and contains thehost.jsonfile. -
Start the Functions host:
func start
-
From your HTTP test tool in a new terminal (or from your browser), call the HTTP trigger endpoint: http://localhost:7071/api/FetchOrchestration_HttpStart to start a new orchestration instance. This orchestration then fans out to several activities to fetch the titles of Microsoft Learn articles in parallel. When the activities finish, the orchestration fans back in and returns the titles as a formatted string.
The HTTP endpoint returns a set of URLs that manage the orchestration, which looks like this fragment:
{ "id": "9addc67238604701a38d1470874a5f04", "statusQueryGetUri": "http://localhost:7071/runtime/webhooks/durabletask/instances/9addc67238604701a38d1470874a5f04?taskHub=TestHubName&connection=Storage&code=<code>", "sendEventPostUri": "http://localhost:7071/runtime/webhooks/durabletask/instances/9addc67238604701a38d1470874a5f04/raiseEvent/{eventName}?taskHub=TestHubName&connection=Storage&code=<code>", "terminatePostUri": "http://localhost:7071/runtime/webhooks/durabletask/instances/9addc67238604701a38d1470874a5f04/terminate?reason={text}&taskHub=TestHubName&connection=Storage&code<code>", } -
Navigate to the
statusQueryGetUriURL in your browser to check the orchestration status. When the orchestration completes, the response looks like this:{ "name": "FetchOrchestration", "instanceId": "987adada388a496b85bbc5496a54dd58", "runtimeStatus": "Completed", "input": null, "output": "Durable Functions Overview: Stateful Serverless Workflows; Durable Task Scheduler - Durable Task; Azure Functions Scenarios; Use AI tools and models in Azure Functions", "createdTime": "2026-06-22T06:58:58Z", "lastUpdatedTime": "2026-06-22T06:59:00Z" }The
outputfield contains the article titles fetched in parallel by the fan-out/fan-in orchestration. -
When you're done, press Ctrl+C in the terminal window to stop the
func.exehost process.
- Open the
fanoutfaninapp folder in a new terminal. - Run the
code .code command to open the project in Visual Studio Code. - Press Run/Debug (F5) to run in the debugger. Select Debug anyway if prompted about local emulator not running.
- From your HTTP test tool in a new terminal (or from your browser), call the HTTP trigger endpoint: http://localhost:7071/api/FetchOrchestration_HttpStart to start a new orchestration instance.
- The HTTP endpoint should return several URLs. The
statusQueryGetUriprovides the orchestration status.
- Open the
fanoutfanin.slnsolution file in Visual Studio. - Press Run/F5 to run in the debugger. Make a note of the
localhostURL endpoints, including the port, which might not be7071. - From your HTTP test tool in a new terminal (or from your browser), call the HTTP trigger endpoint: http://localhost:7071/api/FetchOrchestration_HttpStart to start a new orchestration instance.
- The HTTP endpoint should return several URLs. The
statusQueryGetUriprovides the orchestration status.
After you've verified the app works locally, deploy your code from the project root to the provisioned function app in Azure:
azd deployOnce deployment is done, test the Durable Functions app by making an HTTP request to trigger the start of an orchestration. To get the function URL with access key, run the following:
func azure functionapp list-functions "$(azd env get-value AZURE_FUNCTION_NAME)" --show-keysCopy the Invoke url value for FetchOrchestration_HttpStart and open it in a browser or use curl to start a new orchestration.
In Azure, open the deployed Durable Task Scheduler resource (type Microsoft.DurableTask/schedulers) in the Azure portal and follow the Dashboard link to inspect orchestrations, activities, history, and instance state.
To find the scheduler name quickly:
azd showYou can run the azd deploy command as many times as you need to deploy code updates to your function app. To reprovision infrastructure changes, run azd provision again.
Note
Deployed code files are always overwritten by the latest deployment package.
When you're done working with your function app and related resources, you can use this command to delete the function app and its related resources from Azure and avoid incurring any further costs:
azd down