Skip to content

Commit c53ede6

Browse files
authored
Add suborch sample, change requirements to latest version of SDK (#64)
1 parent 6a13ab5 commit c53ede6

File tree

19 files changed

+227
-3
lines changed

19 files changed

+227
-3
lines changed

samples/functionChaining/.funcignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@
33
__azurite_db*__.json
44
__blobstorage__
55
__queuestorage__
6-
local.settings.json
76
test

samples/functionChaining/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Pre-requisites
44

55
You'll need core tools version v4.0.5095+. Please run `func --version` to ensure your core tools version is compatible.
6+
If you need to install core tools, please see these [installation instructions](https://github.com/Azure/azure-functions-core-tools#installing).
67

78
## How to try it out
89

@@ -14,7 +15,7 @@ You may use this as the starting point for experimentation.
1415
This has been done for you in `requirements.psd1`, by including the following line:
1516

1617
```json
17-
'AzureFunctions.PowerShell.Durable.SDK' = '1.0.0-alpha'
18+
'AzureFunctions.PowerShell.Durable.SDK' = '1.*'
1819
```
1920

2021
### 2. Import the SDK in your `profile.ps1`.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"IsEncrypted": false,
3+
"Values": {
4+
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
5+
"FUNCTIONS_WORKER_RUNTIME_VERSION": "7.2",
6+
"FUNCTIONS_WORKER_RUNTIME": "powershell",
7+
"ExternalDurablePowerShellSDK": "true"
8+
}
9+
}

samples/functionChaining/profile.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,6 @@ if ($env:MSI_SECRET) {
2020
# Enable-AzureRmAlias
2121

2222
# You can also define functions or aliases that can be referenced in any of your PowerShell functions.
23+
24+
# Import standalone Durable Functions SDK
2325
Import-Module AzureFunctions.PowerShell.Durable.SDK -ErrorAction Stop

samples/functionChaining/requirements.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
# For latest supported version, go to 'https://www.powershellgallery.com/packages/Az'.
66
# To use the Az module in your function app, please uncomment the line below.
77
# 'Az' = '9.*'
8-
'AzureFunctions.PowerShell.Durable.SDK' = '1.0.0-alpha'
8+
'AzureFunctions.PowerShell.Durable.SDK' = '1.*'
99
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.git*
2+
.vscode
3+
__azurite_db*__.json
4+
__blobstorage__
5+
__queuestorage__
6+
test
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"bindings": [
3+
{
4+
"authLevel": "anonymous",
5+
"name": "Request",
6+
"type": "httpTrigger",
7+
"direction": "in",
8+
"route": "orchestrators/{FunctionName}",
9+
"methods": [
10+
"post",
11+
"get"
12+
]
13+
},
14+
{
15+
"type": "http",
16+
"direction": "out",
17+
"name": "Response"
18+
},
19+
{
20+
"name": "starter",
21+
"type": "durableClient",
22+
"direction": "in"
23+
}
24+
]
25+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using namespace System.Net
2+
3+
param($Request, $TriggerMetadata)
4+
5+
$FunctionName = $Request.Params.FunctionName
6+
$InstanceId = Start-DurableOrchestration -FunctionName $FunctionName
7+
Write-Host "Started orchestration with ID = '$InstanceId'"
8+
9+
$Response = New-DurableOrchestrationCheckStatusResponse -Request $Request -InstanceId $InstanceId
10+
Push-OutputBinding -Name Response -Value $Response
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"bindings": [
3+
{
4+
"name": "Context",
5+
"type": "orchestrationTrigger",
6+
"direction": "in"
7+
}
8+
]
9+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
param($Context)
2+
3+
$output = @()
4+
5+
# inputs to process
6+
$inputs = @('Tokyo', 'Seattle', 'London', 'Lima', 'Cairo', 'New York', 'Sydney', 'Berlin', 'Paris')
7+
8+
# batch inputs into sub-lists of 3 items
9+
$subOrchestrators = @()
10+
for ($i = 0; $i -lt $inputs.Length; $i += 3) {
11+
# create a sub-orchestration task for each batch
12+
# each sub-orchestration will then fan-out over its own batch of inputs
13+
$batchedInput = $inputs[$i..($i+2)]
14+
$subOrchestrators += Invoke-DurableSubOrchestrator -FunctionName 'SubOrchestrator' -Input $batchedInput -NoWait
15+
}
16+
17+
# fan-out over all sub-orchestrator tasks and aggregate results
18+
$output = Wait-DurableTask -Task $subOrchestrators
19+
20+
# final expression is the return statement
21+
$output

0 commit comments

Comments
 (0)