This template repository contains a Durable Functions sample demonstrating the fan-out/fan-in pattern in Python (v2 programming model), 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.
- Python 3.11+
- Azure Functions Core Tools v4
- Azure Developer CLI (
azd) - Azurite storage emulator
- To run/debug in Visual Studio Code:
You can initialize a project from this azd template in one of these ways:
-
Use
azd initfrom an empty local folder:azd init --template durable-functions-quickstart-python-azd
-
Or clone directly:
git clone https://github.com/Azure-Samples/durable-functions-quickstart-python-azd.git cd durable-functions-quickstart-python-azd
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 src/local.settings.json file with your DTS connection information.
In the src folder, create and activate a virtual environment named .venv:
Linux/macOS:
cd src
python3 -m venv .venv
source .venv/bin/activateWindows:
cd src
py -m venv .venv
.venv\scripts\activateFrom the src folder with the virtual environment activated, run this command to install the required dependencies:
pip install -r requirements.txt-
Start the Azurite storage emulator. The Functions runtime requires a storage component for internal state management:
azurite
-
In a separate terminal, navigate to the
srcfolder with the virtual environment activated, and start the Functions host:func start
You should see output similar to:
Functions: http_start: http://localhost:7071/api/orchestrators/{functionName} fetch_orchestration: orchestrationTrigger fetch_title: activityTrigger -
In another terminal (or your browser), hit the HTTP trigger: http://localhost:7071/api/orchestrators/fetch_orchestration
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": "fetch_orchestration", "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. -
Press Ctrl+C to stop the Functions host when finished.
- Open the repository folder in VS Code (
code .). - Ensure Azurite is running, as described above.
- Press Run/Debug (F5) to start the app in the debugger.
- Trigger the orchestration with an HTTP request to http://localhost:7071/api/orchestrators/fetch_orchestration.
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 http_start 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.
azd downIf 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