Durable Functions PowerShell Fan-Out/Fan-In (Durable Task Scheduler)
This template repository contains a Durable Functions sample demonstrating the fan-out/fan-in pattern in PowerShell, backed by the Azure Durable Task Scheduler (DTS). The sample can be easily deployed to Azure using the Azure Developer CLI (azd). It uses a user-assigned managed identity and can optionally deploy a virtual network.
Durable Functions orchestrates stateful, long-running, multi-step logic with durable execution. State is persisted by a backend provider. This sample uses the Azure Durable Task Scheduler provider, a fully managed backend purpose-built for Durable Functions and the Durable Task Framework. It replaces the Azure Storage backend and provides a dedicated dashboard for monitoring orchestrations.
This sample uses the standard Functions extension bundle (
Microsoft.Azure.Functions.ExtensionBundle, version[4.*, 5.0.0)), which provides theazureManagedstorage provider for the Durable Task Scheduler backend.
Prerequisites
- PowerShell 7.4
- Azure Functions Core Tools
- Azure Developer CLI (
azd) - Azurite storage emulator
- To run/debug in Visual Studio Code:
Initialize the local project
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-powershell-azdSupply 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-powershell-azd.git cd durable-functions-quickstart-powershell-azdYou can also clone the repository from your own fork in GitHub.
Provision Azure resources
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 these commands to sign in to Azure and provision the required Azure resources, including the DTS instance:
azd auth login
azd provision
You'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 optionally create a secure deployment with a virtual network. Select true or false. |
After provisioning completes, a postprovision hook automatically generates the src/local.settings.json file with your DTS connection information.
Run your app from the terminal
Start the Azurite storage emulator. The Functions runtime requires a storage component for internal state management:
azuriteIn a separate terminal, navigate to the
srcfolder:cd srcThe
srcfolder is the root folder for the app and contains thehost.jsonfile.Start the Functions host:
func startYou should see output similar to:
Functions: FetchOrchestration: orchestrationTrigger FetchOrchestration_HttpStart: [GET,POST] http://localhost:7071/api/FetchOrchestration_HttpStart FetchTitle: activityTriggerFrom 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.
Run your app using Visual Studio Code
- Open the
srcapp folder in a new terminal. - Run the
code .code command to open the project in Visual Studio Code. - Ensure Azurite is running, as described above.
- 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.
Deploy to Azure
After you've verified the app works locally, deploy your code from the project root to the provisioned function app in Azure:
azd deploy
Test deployed app
Once 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-keys
Copy the Invoke url value for FetchOrchestration_HttpStart and open it in a browser or use curl to start a new orchestration.
Monitor with the DTS dashboard
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 show
Redeploy your code
You 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.
Clean up resources
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
Troubleshooting
If you see the following transient error after azd up, rerun the command:
ERROR: error executing step command 'deploy --all': failed deploying service 'api': publishing zip file: deployment failed: [KuduSpecializer] Kudu has been restarted during deployment