From f12356c12adc95b546446d6aa77214205461a845 Mon Sep 17 00:00:00 2001 From: Hannah Hunter <94493363+hhunter-ms@users.noreply.github.com> Date: Tue, 26 May 2026 17:35:58 -0400 Subject: [PATCH 1/5] Add PowerShell Hello Cities sample for Durable Functions --- samples/README.md | 14 ++- .../powershell/HelloCities/.gitignore | 1 + .../ChainingOrchestration/function.json | 9 ++ .../HelloCities/ChainingOrchestration/run.ps1 | 9 ++ .../FanOutFanInOrchestration/function.json | 9 ++ .../FanOutFanInOrchestration/run.ps1 | 14 +++ .../powershell/HelloCities/README.md | 92 +++++++++++++++++++ .../HelloCities/SayHello/function.json | 9 ++ .../powershell/HelloCities/SayHello/run.ps1 | 4 + .../HelloCities/StartChaining/function.json | 24 +++++ .../HelloCities/StartChaining/run.ps1 | 7 ++ .../StartFanOutFanIn/function.json | 24 +++++ .../HelloCities/StartFanOutFanIn/run.ps1 | 7 ++ .../powershell/HelloCities/host.json | 24 +++++ .../powershell/HelloCities/profile.ps1 | 18 ++++ .../powershell/HelloCities/requirements.psd1 | 3 + .../durable-functions/powershell/README.md | 15 +++ 17 files changed, 279 insertions(+), 4 deletions(-) create mode 100644 samples/durable-functions/powershell/HelloCities/.gitignore create mode 100644 samples/durable-functions/powershell/HelloCities/ChainingOrchestration/function.json create mode 100644 samples/durable-functions/powershell/HelloCities/ChainingOrchestration/run.ps1 create mode 100644 samples/durable-functions/powershell/HelloCities/FanOutFanInOrchestration/function.json create mode 100644 samples/durable-functions/powershell/HelloCities/FanOutFanInOrchestration/run.ps1 create mode 100644 samples/durable-functions/powershell/HelloCities/README.md create mode 100644 samples/durable-functions/powershell/HelloCities/SayHello/function.json create mode 100644 samples/durable-functions/powershell/HelloCities/SayHello/run.ps1 create mode 100644 samples/durable-functions/powershell/HelloCities/StartChaining/function.json create mode 100644 samples/durable-functions/powershell/HelloCities/StartChaining/run.ps1 create mode 100644 samples/durable-functions/powershell/HelloCities/StartFanOutFanIn/function.json create mode 100644 samples/durable-functions/powershell/HelloCities/StartFanOutFanIn/run.ps1 create mode 100644 samples/durable-functions/powershell/HelloCities/host.json create mode 100644 samples/durable-functions/powershell/HelloCities/profile.ps1 create mode 100644 samples/durable-functions/powershell/HelloCities/requirements.psd1 create mode 100644 samples/durable-functions/powershell/README.md diff --git a/samples/README.md b/samples/README.md index 34a70a4..a1cd401 100644 --- a/samples/README.md +++ b/samples/README.md @@ -46,10 +46,10 @@ A quick-reference matrix showing which patterns are available in each language a ### Durable Functions -| Pattern | .NET | Python | Java | JavaScript | -|---------|------|--------|------|------------| -| Hello Cities (Quickstart) | [✅](./durable-functions/dotnet/HelloCities) | | [✅](./durable-functions/java/HelloCities) | [✅](./durable-functions/javascript/HelloCities) | -| Fan-out/Fan-in | | [✅](./durable-functions/python/fan-out-fan-in) | [✅](./durable-functions/java/HelloCities) | [✅](./durable-functions/javascript/HelloCities) | +| Pattern | .NET | Python | Java | JavaScript | PowerShell | +|---------|------|--------|------|------------|------------| +| Hello Cities (Quickstart) | [✅](./durable-functions/dotnet/HelloCities) | | [✅](./durable-functions/java/HelloCities) | [✅](./durable-functions/javascript/HelloCities) | [✅](./durable-functions/powershell/HelloCities) | +| Fan-out/Fan-in | | [✅](./durable-functions/python/fan-out-fan-in) | [✅](./durable-functions/java/HelloCities) | [✅](./durable-functions/javascript/HelloCities) | [✅](./durable-functions/powershell/HelloCities) | | Order Processor | [✅](./durable-functions/dotnet/OrderProcessor) | | | | | Saga Pattern | [✅](./durable-functions/dotnet/Saga) | | | | | Distributed Tracing | [✅](./durable-functions/dotnet/DistributedTracing) | | | | @@ -155,6 +155,12 @@ A quick-reference matrix showing which patterns are available in each language a |--------|---------|-------------| | [Hello Cities](./durable-functions/javascript/HelloCities) | Function Chaining, Fan-out/Fan-in | JavaScript quickstart with sequential and parallel orchestration patterns | +### PowerShell + +| Sample | Pattern | Description | +|--------|---------|-------------| +| [Hello Cities](./durable-functions/powershell/HelloCities) | Function Chaining, Fan-out/Fan-in | PowerShell quickstart with sequential and parallel orchestration patterns | + --- ## Durable Extension for Microsoft Agent Framework diff --git a/samples/durable-functions/powershell/HelloCities/.gitignore b/samples/durable-functions/powershell/HelloCities/.gitignore new file mode 100644 index 0000000..819b029 --- /dev/null +++ b/samples/durable-functions/powershell/HelloCities/.gitignore @@ -0,0 +1 @@ +Modules/ diff --git a/samples/durable-functions/powershell/HelloCities/ChainingOrchestration/function.json b/samples/durable-functions/powershell/HelloCities/ChainingOrchestration/function.json new file mode 100644 index 0000000..0c950e3 --- /dev/null +++ b/samples/durable-functions/powershell/HelloCities/ChainingOrchestration/function.json @@ -0,0 +1,9 @@ +{ + "bindings": [ + { + "name": "Context", + "type": "orchestrationTrigger", + "direction": "in" + } + ] +} diff --git a/samples/durable-functions/powershell/HelloCities/ChainingOrchestration/run.ps1 b/samples/durable-functions/powershell/HelloCities/ChainingOrchestration/run.ps1 new file mode 100644 index 0000000..dfb9ad1 --- /dev/null +++ b/samples/durable-functions/powershell/HelloCities/ChainingOrchestration/run.ps1 @@ -0,0 +1,9 @@ +param($Context) + +$output = @() + +$output += Invoke-DurableActivity -FunctionName 'SayHello' -Input 'Tokyo' +$output += Invoke-DurableActivity -FunctionName 'SayHello' -Input 'Seattle' +$output += Invoke-DurableActivity -FunctionName 'SayHello' -Input 'London' + +$output diff --git a/samples/durable-functions/powershell/HelloCities/FanOutFanInOrchestration/function.json b/samples/durable-functions/powershell/HelloCities/FanOutFanInOrchestration/function.json new file mode 100644 index 0000000..0c950e3 --- /dev/null +++ b/samples/durable-functions/powershell/HelloCities/FanOutFanInOrchestration/function.json @@ -0,0 +1,9 @@ +{ + "bindings": [ + { + "name": "Context", + "type": "orchestrationTrigger", + "direction": "in" + } + ] +} diff --git a/samples/durable-functions/powershell/HelloCities/FanOutFanInOrchestration/run.ps1 b/samples/durable-functions/powershell/HelloCities/FanOutFanInOrchestration/run.ps1 new file mode 100644 index 0000000..ea47141 --- /dev/null +++ b/samples/durable-functions/powershell/HelloCities/FanOutFanInOrchestration/run.ps1 @@ -0,0 +1,14 @@ +param($Context) + +$cities = @('Tokyo', 'Seattle', 'London', 'Paris', 'Berlin') + +# Fan-out: schedule all activities in parallel +$parallelTasks = @() +foreach ($city in $cities) { + $parallelTasks += Invoke-DurableActivity -FunctionName 'SayHello' -Input $city -NoWait +} + +# Fan-in: wait for all to complete +$output = Wait-ActivityFunction -Task $parallelTasks + +$output diff --git a/samples/durable-functions/powershell/HelloCities/README.md b/samples/durable-functions/powershell/HelloCities/README.md new file mode 100644 index 0000000..893b943 --- /dev/null +++ b/samples/durable-functions/powershell/HelloCities/README.md @@ -0,0 +1,92 @@ +# Hello Cities — Durable Functions PowerShell Quickstart + +PowerShell | Durable Functions + +## Description + +This quickstart demonstrates Durable Functions with PowerShell using the Durable Task Scheduler backend. It includes two patterns: + +1. **Function Chaining** — An orchestration that calls three "say hello" activities sequentially +2. **Fan-out/Fan-in** — An orchestration that greets multiple cities in parallel and aggregates results + +## Prerequisites + +1. [PowerShell 7.4+](https://learn.microsoft.com/powershell/scripting/install/installing-powershell) +2. [Azure Functions Core Tools v4](https://learn.microsoft.com/azure/azure-functions/functions-run-local) +3. [Docker](https://www.docker.com/products/docker-desktop/) (for the emulator) + +## Quick Run + +1. Start the emulator: + ```bash + docker run -d -p 8080:8080 -p 8082:8082 mcr.microsoft.com/dts/dts-emulator:latest + ``` + +2. Navigate to the sample directory: + ```bash + cd samples/durable-functions/powershell/HelloCities + ``` + +3. Run the function app: + ```bash + func start + ``` + +4. Trigger the function chaining orchestration: + ```bash + curl -X POST http://localhost:7071/api/StartChaining + ``` + +5. Trigger the fan-out/fan-in orchestration: + ```bash + curl -X POST http://localhost:7071/api/StartFanOutFanIn + ``` + +6. View in the dashboard: http://localhost:8082 + +## Expected Output + +The chaining orchestration greets Tokyo, Seattle, and London sequentially: +```json +["Hello Tokyo!", "Hello Seattle!", "Hello London!"] +``` + +The fan-out/fan-in orchestration greets all five cities in parallel and returns combined results: +```json +["Hello Tokyo!", "Hello Seattle!", "Hello London!", "Hello Paris!", "Hello Berlin!"] +``` + +## Using a Deployed Scheduler (Azure) + +To use a Durable Task Scheduler in Azure instead of the emulator: + +1. Set the connection string in `local.settings.json`: + ```json + { + "Values": { + "DURABLE_TASK_SCHEDULER_CONNECTION_STRING": "Endpoint=;TaskHub=;Authentication=ManagedIdentity" + } + } + ``` + +2. Run the sample using the same commands as above. + +See the [Durable Task Scheduler documentation](https://learn.microsoft.com/azure/azure-functions/durable/durable-task-scheduler/develop-with-durable-task-scheduler) for setup instructions. + +## Code Walkthrough + +- **SayHello/** — Activity function that returns a greeting for a given city name. +- **ChainingOrchestration/** — Orchestrator that calls `SayHello` three times in sequence. +- **FanOutFanInOrchestration/** — Orchestrator that calls `SayHello` for five cities in parallel. +- **StartChaining/** — HTTP trigger that starts the chaining orchestration. +- **StartFanOutFanIn/** — HTTP trigger that starts the fan-out/fan-in orchestration. + +## Viewing in the Dashboard + +- **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 + +## Learn More + +- [Durable Functions PowerShell Developer Guide](https://learn.microsoft.com/azure/azure-functions/durable/quickstart-powershell-vscode) +- [Durable Task Scheduler Documentation](https://aka.ms/dts-documentation) diff --git a/samples/durable-functions/powershell/HelloCities/SayHello/function.json b/samples/durable-functions/powershell/HelloCities/SayHello/function.json new file mode 100644 index 0000000..50ce1e6 --- /dev/null +++ b/samples/durable-functions/powershell/HelloCities/SayHello/function.json @@ -0,0 +1,9 @@ +{ + "bindings": [ + { + "name": "city", + "type": "activityTrigger", + "direction": "in" + } + ] +} diff --git a/samples/durable-functions/powershell/HelloCities/SayHello/run.ps1 b/samples/durable-functions/powershell/HelloCities/SayHello/run.ps1 new file mode 100644 index 0000000..20721ec --- /dev/null +++ b/samples/durable-functions/powershell/HelloCities/SayHello/run.ps1 @@ -0,0 +1,4 @@ +param($city) + +Write-Host "Saying hello to $city." +"Hello $city!" diff --git a/samples/durable-functions/powershell/HelloCities/StartChaining/function.json b/samples/durable-functions/powershell/HelloCities/StartChaining/function.json new file mode 100644 index 0000000..308d192 --- /dev/null +++ b/samples/durable-functions/powershell/HelloCities/StartChaining/function.json @@ -0,0 +1,24 @@ +{ + "bindings": [ + { + "authLevel": "anonymous", + "name": "Request", + "type": "httpTrigger", + "direction": "in", + "methods": [ + "post" + ], + "route": "StartChaining" + }, + { + "name": "Response", + "type": "http", + "direction": "out" + }, + { + "name": "starter", + "type": "durableClient", + "direction": "in" + } + ] +} diff --git a/samples/durable-functions/powershell/HelloCities/StartChaining/run.ps1 b/samples/durable-functions/powershell/HelloCities/StartChaining/run.ps1 new file mode 100644 index 0000000..fc20ec1 --- /dev/null +++ b/samples/durable-functions/powershell/HelloCities/StartChaining/run.ps1 @@ -0,0 +1,7 @@ +param($Request, $TriggerMetadata) + +$instanceId = Start-DurableOrchestration -FunctionName 'ChainingOrchestration' +Write-Host "Started chaining orchestration with ID = '$instanceId'." + +$response = New-DurableOrchestrationCheckStatusResponse -Request $Request -InstanceId $instanceId +Push-OutputBinding -Name Response -Value $response diff --git a/samples/durable-functions/powershell/HelloCities/StartFanOutFanIn/function.json b/samples/durable-functions/powershell/HelloCities/StartFanOutFanIn/function.json new file mode 100644 index 0000000..65b91fd --- /dev/null +++ b/samples/durable-functions/powershell/HelloCities/StartFanOutFanIn/function.json @@ -0,0 +1,24 @@ +{ + "bindings": [ + { + "authLevel": "anonymous", + "name": "Request", + "type": "httpTrigger", + "direction": "in", + "methods": [ + "post" + ], + "route": "StartFanOutFanIn" + }, + { + "name": "Response", + "type": "http", + "direction": "out" + }, + { + "name": "starter", + "type": "durableClient", + "direction": "in" + } + ] +} diff --git a/samples/durable-functions/powershell/HelloCities/StartFanOutFanIn/run.ps1 b/samples/durable-functions/powershell/HelloCities/StartFanOutFanIn/run.ps1 new file mode 100644 index 0000000..58103c1 --- /dev/null +++ b/samples/durable-functions/powershell/HelloCities/StartFanOutFanIn/run.ps1 @@ -0,0 +1,7 @@ +param($Request, $TriggerMetadata) + +$instanceId = Start-DurableOrchestration -FunctionName 'FanOutFanInOrchestration' +Write-Host "Started fan-out/fan-in orchestration with ID = '$instanceId'." + +$response = New-DurableOrchestrationCheckStatusResponse -Request $Request -InstanceId $instanceId +Push-OutputBinding -Name Response -Value $response diff --git a/samples/durable-functions/powershell/HelloCities/host.json b/samples/durable-functions/powershell/HelloCities/host.json new file mode 100644 index 0000000..497a2bc --- /dev/null +++ b/samples/durable-functions/powershell/HelloCities/host.json @@ -0,0 +1,24 @@ +{ + "version": "2.0", + "logging": { + "logLevel": { + "DurableTask.Core": "Warning" + } + }, + "extensions": { + "durableTask": { + "hubName": "default", + "storageProvider": { + "type": "azureManaged", + "connectionStringName": "DURABLE_TASK_SCHEDULER_CONNECTION_STRING" + } + } + }, + "extensionBundle": { + "id": "Microsoft.Azure.Functions.ExtensionBundle", + "version": "[4.*, 5.0.0)" + }, + "managedDependency": { + "enabled": true + } +} diff --git a/samples/durable-functions/powershell/HelloCities/profile.ps1 b/samples/durable-functions/powershell/HelloCities/profile.ps1 new file mode 100644 index 0000000..52f762c --- /dev/null +++ b/samples/durable-functions/powershell/HelloCities/profile.ps1 @@ -0,0 +1,18 @@ +# Azure Functions profile.ps1 +# +# This profile.ps1 will get executed every "cold start" of your Function App. +# "cold start" occurs when: +# +# * A Function App starts up for the very first time +# * A Function App starts up after being de-allocated due to inactivity +# +# You can define helper functions, run commands, or specify environment variables +# NOTE: any variables defined that are not combinated within a function will +# be style as combinated in the "script scope" and will NOT be available inside +# your functions. + +# Authenticate with Azure PowerShell using MSI (if deployed to Azure) +if ($env:MSI_SECRET) { + Disable-AzContextAutosave -Scope Process | Out-Null + Connect-AzAccount -Identity +} diff --git a/samples/durable-functions/powershell/HelloCities/requirements.psd1 b/samples/durable-functions/powershell/HelloCities/requirements.psd1 new file mode 100644 index 0000000..5e4d74b --- /dev/null +++ b/samples/durable-functions/powershell/HelloCities/requirements.psd1 @@ -0,0 +1,3 @@ +@{ + 'Az.Accounts' = '4.*' +} diff --git a/samples/durable-functions/powershell/README.md b/samples/durable-functions/powershell/README.md new file mode 100644 index 0000000..3999c94 --- /dev/null +++ b/samples/durable-functions/powershell/README.md @@ -0,0 +1,15 @@ +# PowerShell Samples for Durable Functions + +This directory contains sample applications demonstrating Durable Functions patterns using PowerShell with the Durable Task Scheduler backend. + +## Prerequisites + +- [PowerShell 7.4+](https://learn.microsoft.com/powershell/scripting/install/installing-powershell) +- [Azure Functions Core Tools v4](https://learn.microsoft.com/azure/azure-functions/functions-run-local) +- [Docker](https://www.docker.com/products/docker-desktop/) + +## Available Samples + +| Sample | Pattern | +|--------|---------| +| [HelloCities](./HelloCities/) | Function Chaining, Fan-out/Fan-in | From 0fd9f41ffc35441cac3f8f8cc01cfa18bd938746 Mon Sep 17 00:00:00 2001 From: Hannah Hunter <94493363+hhunter-ms@users.noreply.github.com> Date: Tue, 26 May 2026 17:54:39 -0400 Subject: [PATCH 2/5] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .../durable-functions/powershell/HelloCities/profile.ps1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/samples/durable-functions/powershell/HelloCities/profile.ps1 b/samples/durable-functions/powershell/HelloCities/profile.ps1 index 52f762c..a491c4f 100644 --- a/samples/durable-functions/powershell/HelloCities/profile.ps1 +++ b/samples/durable-functions/powershell/HelloCities/profile.ps1 @@ -6,10 +6,10 @@ # * A Function App starts up for the very first time # * A Function App starts up after being de-allocated due to inactivity # -# You can define helper functions, run commands, or specify environment variables -# NOTE: any variables defined that are not combinated within a function will -# be style as combinated in the "script scope" and will NOT be available inside -# your functions. +# You can define helper functions, run commands, or specify environment variables. +# NOTE: variables defined outside a function are stored in the script scope and +# are not automatically available inside your function scripts unless you +# explicitly pass them in or define them in a shared module. # Authenticate with Azure PowerShell using MSI (if deployed to Azure) if ($env:MSI_SECRET) { From 7bd4040b6a1415ed068bf3b2fd23e0d14fd219f6 Mon Sep 17 00:00:00 2001 From: Hannah Hunter <94493363+hhunter-ms@users.noreply.github.com> Date: Tue, 26 May 2026 18:05:18 -0400 Subject: [PATCH 3/5] Fix review feedback: wire durableClient binding, add local.settings.json instructions, clarify expected output --- .../powershell/HelloCities/README.md | 35 +++++++++++++++---- .../HelloCities/StartChaining/run.ps1 | 6 ++-- .../HelloCities/StartFanOutFanIn/run.ps1 | 6 ++-- 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/samples/durable-functions/powershell/HelloCities/README.md b/samples/durable-functions/powershell/HelloCities/README.md index 893b943..c24de21 100644 --- a/samples/durable-functions/powershell/HelloCities/README.md +++ b/samples/durable-functions/powershell/HelloCities/README.md @@ -27,31 +27,49 @@ This quickstart demonstrates Durable Functions with PowerShell using the Durable cd samples/durable-functions/powershell/HelloCities ``` -3. Run the function app: +3. Create a `local.settings.json` file: + ```json + { + "IsEncrypted": false, + "Values": { + "AzureWebJobsStorage": "UseDevelopmentStorage=true", + "FUNCTIONS_WORKER_RUNTIME": "powershell", + "DURABLE_TASK_SCHEDULER_CONNECTION_STRING": "Endpoint=http://localhost:8080;TaskHub=default;Authentication=None" + } + } + ``` + +4. Run the function app: ```bash func start ``` -4. Trigger the function chaining orchestration: +5. Trigger the function chaining orchestration: ```bash curl -X POST http://localhost:7071/api/StartChaining ``` -5. Trigger the fan-out/fan-in orchestration: +6. Trigger the fan-out/fan-in orchestration: ```bash curl -X POST http://localhost:7071/api/StartFanOutFanIn ``` -6. View in the dashboard: http://localhost:8082 +7. View in the dashboard: http://localhost:8082 ## Expected Output -The chaining orchestration greets Tokyo, Seattle, and London sequentially: +The HTTP triggers return a **202 Accepted** response with status query URLs. Use the `statusQueryGetUri` from the response to poll for completion: + +```bash +curl http://localhost:7071/runtime/webhooks/durabletask/instances/ +``` + +Once completed, the chaining orchestration output greets Tokyo, Seattle, and London sequentially: ```json ["Hello Tokyo!", "Hello Seattle!", "Hello London!"] ``` -The fan-out/fan-in orchestration greets all five cities in parallel and returns combined results: +The fan-out/fan-in orchestration output greets all five cities in parallel and returns combined results: ```json ["Hello Tokyo!", "Hello Seattle!", "Hello London!", "Hello Paris!", "Hello Berlin!"] ``` @@ -60,10 +78,13 @@ The fan-out/fan-in orchestration greets all five cities in parallel and returns To use a Durable Task Scheduler in Azure instead of the emulator: -1. Set the connection string in `local.settings.json`: +1. Update the connection string in `local.settings.json`: ```json { + "IsEncrypted": false, "Values": { + "AzureWebJobsStorage": "UseDevelopmentStorage=true", + "FUNCTIONS_WORKER_RUNTIME": "powershell", "DURABLE_TASK_SCHEDULER_CONNECTION_STRING": "Endpoint=;TaskHub=;Authentication=ManagedIdentity" } } diff --git a/samples/durable-functions/powershell/HelloCities/StartChaining/run.ps1 b/samples/durable-functions/powershell/HelloCities/StartChaining/run.ps1 index fc20ec1..6efb7c6 100644 --- a/samples/durable-functions/powershell/HelloCities/StartChaining/run.ps1 +++ b/samples/durable-functions/powershell/HelloCities/StartChaining/run.ps1 @@ -1,7 +1,7 @@ -param($Request, $TriggerMetadata) +param($Request, $TriggerMetadata, $starter) -$instanceId = Start-DurableOrchestration -FunctionName 'ChainingOrchestration' +$instanceId = Start-DurableOrchestration -FunctionName 'ChainingOrchestration' -DurableClient $starter Write-Host "Started chaining orchestration with ID = '$instanceId'." -$response = New-DurableOrchestrationCheckStatusResponse -Request $Request -InstanceId $instanceId +$response = New-DurableOrchestrationCheckStatusResponse -Request $Request -InstanceId $instanceId -DurableClient $starter Push-OutputBinding -Name Response -Value $response diff --git a/samples/durable-functions/powershell/HelloCities/StartFanOutFanIn/run.ps1 b/samples/durable-functions/powershell/HelloCities/StartFanOutFanIn/run.ps1 index 58103c1..c0359be 100644 --- a/samples/durable-functions/powershell/HelloCities/StartFanOutFanIn/run.ps1 +++ b/samples/durable-functions/powershell/HelloCities/StartFanOutFanIn/run.ps1 @@ -1,7 +1,7 @@ -param($Request, $TriggerMetadata) +param($Request, $TriggerMetadata, $starter) -$instanceId = Start-DurableOrchestration -FunctionName 'FanOutFanInOrchestration' +$instanceId = Start-DurableOrchestration -FunctionName 'FanOutFanInOrchestration' -DurableClient $starter Write-Host "Started fan-out/fan-in orchestration with ID = '$instanceId'." -$response = New-DurableOrchestrationCheckStatusResponse -Request $Request -InstanceId $instanceId +$response = New-DurableOrchestrationCheckStatusResponse -Request $Request -InstanceId $instanceId -DurableClient $starter Push-OutputBinding -Name Response -Value $response From ac875f8433721b7e56d3ae46a333aeeaebc881eb Mon Sep 17 00:00:00 2001 From: Hannah Hunter <94493363+hhunter-ms@users.noreply.github.com> Date: Wed, 27 May 2026 12:00:18 -0400 Subject: [PATCH 4/5] Fix runtime issues: revert -DurableClient param, add HttpStatusCode type accelerator, empty requirements --- .../powershell/HelloCities/StartChaining/run.ps1 | 6 +++--- .../powershell/HelloCities/StartFanOutFanIn/run.ps1 | 6 +++--- .../durable-functions/powershell/HelloCities/profile.ps1 | 4 ++++ .../powershell/HelloCities/requirements.psd1 | 3 ++- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/samples/durable-functions/powershell/HelloCities/StartChaining/run.ps1 b/samples/durable-functions/powershell/HelloCities/StartChaining/run.ps1 index 6efb7c6..fc20ec1 100644 --- a/samples/durable-functions/powershell/HelloCities/StartChaining/run.ps1 +++ b/samples/durable-functions/powershell/HelloCities/StartChaining/run.ps1 @@ -1,7 +1,7 @@ -param($Request, $TriggerMetadata, $starter) +param($Request, $TriggerMetadata) -$instanceId = Start-DurableOrchestration -FunctionName 'ChainingOrchestration' -DurableClient $starter +$instanceId = Start-DurableOrchestration -FunctionName 'ChainingOrchestration' Write-Host "Started chaining orchestration with ID = '$instanceId'." -$response = New-DurableOrchestrationCheckStatusResponse -Request $Request -InstanceId $instanceId -DurableClient $starter +$response = New-DurableOrchestrationCheckStatusResponse -Request $Request -InstanceId $instanceId Push-OutputBinding -Name Response -Value $response diff --git a/samples/durable-functions/powershell/HelloCities/StartFanOutFanIn/run.ps1 b/samples/durable-functions/powershell/HelloCities/StartFanOutFanIn/run.ps1 index c0359be..58103c1 100644 --- a/samples/durable-functions/powershell/HelloCities/StartFanOutFanIn/run.ps1 +++ b/samples/durable-functions/powershell/HelloCities/StartFanOutFanIn/run.ps1 @@ -1,7 +1,7 @@ -param($Request, $TriggerMetadata, $starter) +param($Request, $TriggerMetadata) -$instanceId = Start-DurableOrchestration -FunctionName 'FanOutFanInOrchestration' -DurableClient $starter +$instanceId = Start-DurableOrchestration -FunctionName 'FanOutFanInOrchestration' Write-Host "Started fan-out/fan-in orchestration with ID = '$instanceId'." -$response = New-DurableOrchestrationCheckStatusResponse -Request $Request -InstanceId $instanceId -DurableClient $starter +$response = New-DurableOrchestrationCheckStatusResponse -Request $Request -InstanceId $instanceId Push-OutputBinding -Name Response -Value $response diff --git a/samples/durable-functions/powershell/HelloCities/profile.ps1 b/samples/durable-functions/powershell/HelloCities/profile.ps1 index a491c4f..de95d5d 100644 --- a/samples/durable-functions/powershell/HelloCities/profile.ps1 +++ b/samples/durable-functions/powershell/HelloCities/profile.ps1 @@ -11,6 +11,10 @@ # are not automatically available inside your function scripts unless you # explicitly pass them in or define them in a shared module. +# Register HttpStatusCode type accelerator (required by Durable Functions module) +$accelerator = [PowerShell].Assembly.GetType("System.Management.Automation.TypeAccelerators") +$accelerator::Add('HttpStatusCode', [System.Net.HttpStatusCode]) + # Authenticate with Azure PowerShell using MSI (if deployed to Azure) if ($env:MSI_SECRET) { Disable-AzContextAutosave -Scope Process | Out-Null diff --git a/samples/durable-functions/powershell/HelloCities/requirements.psd1 b/samples/durable-functions/powershell/HelloCities/requirements.psd1 index 5e4d74b..64afb38 100644 --- a/samples/durable-functions/powershell/HelloCities/requirements.psd1 +++ b/samples/durable-functions/powershell/HelloCities/requirements.psd1 @@ -1,3 +1,4 @@ @{ - 'Az.Accounts' = '4.*' + # Managed dependencies - add modules here if needed + # 'Az.Accounts' = '4.*' } From 1912e2883f99eab76934ac9b79c3a5a7ac6e3c6a Mon Sep 17 00:00:00 2001 From: Hannah Hunter <94493363+hhunter-ms@users.noreply.github.com> Date: Wed, 27 May 2026 12:10:54 -0400 Subject: [PATCH 5/5] Address review: idempotent type accelerator, remove Az auth, fix curl example --- .../durable-functions/powershell/HelloCities/README.md | 3 ++- .../powershell/HelloCities/profile.ps1 | 10 +++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/samples/durable-functions/powershell/HelloCities/README.md b/samples/durable-functions/powershell/HelloCities/README.md index c24de21..ae2c3dc 100644 --- a/samples/durable-functions/powershell/HelloCities/README.md +++ b/samples/durable-functions/powershell/HelloCities/README.md @@ -61,7 +61,8 @@ This quickstart demonstrates Durable Functions with PowerShell using the Durable The HTTP triggers return a **202 Accepted** response with status query URLs. Use the `statusQueryGetUri` from the response to poll for completion: ```bash -curl http://localhost:7071/runtime/webhooks/durabletask/instances/ +# Replace with the statusQueryGetUri value from the 202 response +curl "" ``` Once completed, the chaining orchestration output greets Tokyo, Seattle, and London sequentially: diff --git a/samples/durable-functions/powershell/HelloCities/profile.ps1 b/samples/durable-functions/powershell/HelloCities/profile.ps1 index de95d5d..8eddf75 100644 --- a/samples/durable-functions/powershell/HelloCities/profile.ps1 +++ b/samples/durable-functions/powershell/HelloCities/profile.ps1 @@ -12,11 +12,7 @@ # explicitly pass them in or define them in a shared module. # Register HttpStatusCode type accelerator (required by Durable Functions module) -$accelerator = [PowerShell].Assembly.GetType("System.Management.Automation.TypeAccelerators") -$accelerator::Add('HttpStatusCode', [System.Net.HttpStatusCode]) - -# Authenticate with Azure PowerShell using MSI (if deployed to Azure) -if ($env:MSI_SECRET) { - Disable-AzContextAutosave -Scope Process | Out-Null - Connect-AzAccount -Identity +$accelerator = [PowerShell].Assembly.GetType('System.Management.Automation.TypeAccelerators') +if (-not $accelerator::Get.ContainsKey('HttpStatusCode')) { + $accelerator::Add('HttpStatusCode', [System.Net.HttpStatusCode]) }