PowerShell | Durable Functions
This quickstart demonstrates Durable Functions with PowerShell using the Durable Task Scheduler backend. It includes two patterns:
- Function Chaining — An orchestration that calls three "say hello" activities sequentially
- Fan-out/Fan-in — An orchestration that greets multiple cities in parallel and aggregates results
- PowerShell 7.4+
- Azure Functions Core Tools v4
- Docker (for the emulator)
-
Start the emulator:
docker run -d -p 8080:8080 -p 8082:8082 mcr.microsoft.com/dts/dts-emulator:latest
-
Navigate to the sample directory:
cd samples/durable-functions/powershell/HelloCities -
Create a
local.settings.jsonfile:{ "IsEncrypted": false, "Values": { "AzureWebJobsStorage": "UseDevelopmentStorage=true", "FUNCTIONS_WORKER_RUNTIME": "powershell", "DURABLE_TASK_SCHEDULER_CONNECTION_STRING": "Endpoint=http://localhost:8080;TaskHub=default;Authentication=None" } } -
Run the function app:
func start
-
Trigger the function chaining orchestration:
curl -X POST http://localhost:7071/api/StartChaining
-
Trigger the fan-out/fan-in orchestration:
curl -X POST http://localhost:7071/api/StartFanOutFanIn
-
View in the dashboard: http://localhost:8082
The HTTP triggers return a 202 Accepted response with status query URLs. Use the statusQueryGetUri from the response to poll for completion:
# Replace with the statusQueryGetUri value from the 202 response
curl "<statusQueryGetUri>"Once completed, the chaining orchestration output greets Tokyo, Seattle, and London sequentially:
["Hello Tokyo!", "Hello Seattle!", "Hello London!"]The fan-out/fan-in orchestration output greets all five cities in parallel and returns combined results:
["Hello Tokyo!", "Hello Seattle!", "Hello London!", "Hello Paris!", "Hello Berlin!"]To use a Durable Task Scheduler in Azure instead of the emulator:
-
Update the connection string in
local.settings.json:{ "IsEncrypted": false, "Values": { "AzureWebJobsStorage": "UseDevelopmentStorage=true", "FUNCTIONS_WORKER_RUNTIME": "powershell", "DURABLE_TASK_SCHEDULER_CONNECTION_STRING": "Endpoint=<your-scheduler-endpoint>;TaskHub=<your-taskhub>;Authentication=ManagedIdentity" } } -
Run the sample using the same commands as above.
See the Durable Task Scheduler documentation for setup instructions.
- SayHello/ — Activity function that returns a greeting for a given city name.
- ChainingOrchestration/ — Orchestrator that calls
SayHellothree times in sequence. - FanOutFanInOrchestration/ — Orchestrator that calls
SayHellofor five cities in parallel. - StartChaining/ — HTTP trigger that starts the chaining orchestration.
- StartFanOutFanIn/ — HTTP trigger that starts the fan-out/fan-in orchestration.
- Emulator: Navigate to http://localhost:8082 → select the "default" task hub
- Azure: Navigate to your Scheduler resource in the Azure Portal → Task Hub → Dashboard URL