Skip to content

Commit 6e81658

Browse files
authored
Merge pull request #163217 from stefanushinardi/powershell-binding
Added bindings example for powershell
2 parents 1c222b2 + c6e7885 commit 6e81658

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

articles/azure-functions/durable/durable-functions-bindings.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,17 @@ def orchestrator_function(context: df.DurableOrchestrationContext):
100100
main = df.Orchestrator.create(orchestrator_function)
101101
```
102102

103+
# [PowerShell](#tab/powershell)
104+
105+
```powershell
106+
param($Context)
107+
108+
$input = $Context.Input
109+
110+
# Do some work
111+
112+
$output
113+
```
103114
---
104115

105116
Most orchestrator functions call activity functions, so here is a "Hello World" example that demonstrates how to call an activity function:
@@ -145,6 +156,18 @@ def orchestrator_function(context: df.DurableOrchestrationContext):
145156
main = df.Orchestrator.create(orchestrator_function)
146157
```
147158

159+
# [PowerShell](#tab/powershell)
160+
161+
```powershell
162+
param($Context)
163+
164+
$name = $Context.Input.Name
165+
166+
$output = Invoke-DurableActivity -FunctionName 'SayHello' -Input $name
167+
168+
$output
169+
```
170+
148171
---
149172

150173
## Activity trigger
@@ -233,6 +256,12 @@ def main(name: str) -> str:
233256
return f"Hello {name}!"
234257
```
235258

259+
# [PowerShell](#tab/powershell)
260+
```powershell
261+
param($name)
262+
263+
"Hello $name!"
264+
```
236265
---
237266

238267
### Using input and output bindings
@@ -380,6 +409,34 @@ async def main(msg: func.QueueMessage, starter: str) -> None:
380409
instance_id = await client.start_new("HelloWorld", client_input=payload)
381410
```
382411

412+
# [PowerShell](#tab/powershell)
413+
414+
**function.json**
415+
```json
416+
{
417+
"bindings": [
418+
{
419+
"name": "input",
420+
"type": "queueTrigger",
421+
"queueName": "durable-function-trigger",
422+
"direction": "in"
423+
},
424+
{
425+
"name": "starter",
426+
"type": "durableClient",
427+
"direction": "in"
428+
}
429+
]
430+
}
431+
```
432+
433+
**run.ps1**
434+
```powershell
435+
param($[string] $input, $TriggerMetadata)
436+
437+
$InstanceId = Start-DurableOrchestration -FunctionName $FunctionName -Input $input
438+
```
439+
383440
---
384441

385442
More details on starting instances can be found in [Instance management](durable-functions-instance-management.md).

0 commit comments

Comments
 (0)