Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions samples/functionChaining/.funcignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.git*
.vscode
__azurite_db*__.json
__blobstorage__
__queuestorage__
local.settings.json
test
25 changes: 25 additions & 0 deletions samples/functionChaining/DurableFunctionsHttpStart/function.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"bindings": [
{
"authLevel": "anonymous",
"name": "Request",
"type": "httpTrigger",
"direction": "in",
"route": "orchestrators/{FunctionName}",
"methods": [
"post",
"get"
]
},
{
"type": "http",
"direction": "out",
"name": "Response"
},
{
"name": "starter",
"type": "durableClient",
"direction": "in"
}
]
}
10 changes: 10 additions & 0 deletions samples/functionChaining/DurableFunctionsHttpStart/run.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using namespace System.Net

param($Request, $TriggerMetadata)

$FunctionName = $Request.Params.FunctionName
$InstanceId = Start-DurableOrchestration -FunctionName $FunctionName -Input "I wrote this in DurableFunctionsHttpStart"
Write-Host "Started orchestration with ID = '$InstanceId'"

$Response = New-DurableOrchestrationCheckStatusResponse -Request $Request -InstanceId $InstanceId
Push-OutputBinding -Name Response -Value $Response
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"bindings": [
{
"name": "Context",
"type": "orchestrationTrigger",
"direction": "in"
}
]
}
11 changes: 11 additions & 0 deletions samples/functionChaining/DurableFunctionsOrchestrator/run.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
param($Context)

$output = @()

# Function chaining
$output += Invoke-DurableActivity -FunctionName 'Hello' -Input 'Tokyo'
$output += Invoke-DurableActivity -FunctionName 'Hello' -Input 'Seattle'
$output += Invoke-DurableActivity -FunctionName 'Hello' -Input 'London'

# final expression is the return statement
$output
9 changes: 9 additions & 0 deletions samples/functionChaining/Hello/function.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"bindings": [
{
"name": "name",
"type": "activityTrigger",
"direction": "in"
}
]
}
3 changes: 3 additions & 0 deletions samples/functionChaining/Hello/run.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
param($name)

"Hello $name!"
46 changes: 46 additions & 0 deletions samples/functionChaining/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Function Chaining sample

## Pre-requisites

You'll need core tools version v4.0.5095+. Please run `func --version` to ensure your core tools version is compatible.

## How to try it out

This repo already contains the basic project structure for a function-chaining Durable Functions PowerShell app.
You may use this as the starting point for experimentation.

### 1. Install the SDK from the PowerShell Gallery

This has been done for you in `requirements.psd1`, by including the following line:

```json
'AzureFunctions.PowerShell.Durable.SDK' = '1.0.0-alpha'
```

### 2. Import the SDK in your `profile.ps1`.

This has been done for you in this starter project.
Please verify that the `profile.ps1` file contains the following line:

```powershell
Import-Module AzureFunctions.PowerShell.Durable.SDK -ErrorAction Stop
```

### 3. Set the env variable `ExternalDurablePowerShellSDK` to `"true"`.

This has been done for you in this repo's starter project.
Please verify that this setting is set in your `local.settings.json`.

### 4. Try it!

Run `func host start` and run the orchestrator with a GET request to `http://localhost:7071/api/orchestrators/DurableFunctionsOrchestrator`.

### 6. Confirm you're using the new SDK

Since the new SDK is backwards compatible with the old one, it's worth doing a sanity check that you are actually using the new experience.

To do this, run `func host start --verbose`, start the orchestrator by performing a GET request to `http://localhost:7071/api/orchestrators/DurableFunctionsOrchestrator`, and finally CTRL+F for the following log: `Utilizing external Durable Functions SDK: 'True'`. If you can find it, you're using the new experience.

## If you deploy to Azure

You will need to set the `ExternalDurablePowerShellSDK` application setting to `"true"`.
18 changes: 18 additions & 0 deletions samples/functionChaining/host.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
},
"managedDependency": {
"enabled": true
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[3.*, 4.0.0)"
},
}
23 changes: 23 additions & 0 deletions samples/functionChaining/profile.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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 environment variables will get reset after the first execution

# Authenticate with Azure PowerShell using MSI.
# Remove this if you are not planning on using MSI or Azure PowerShell.
if ($env:MSI_SECRET) {
Disable-AzContextAutosave -Scope Process | Out-Null
Connect-AzAccount -Identity
}

# Uncomment the next line to enable legacy AzureRm alias in Azure PowerShell.
# Enable-AzureRmAlias

# You can also define functions or aliases that can be referenced in any of your PowerShell functions.
Import-Module AzureFunctions.PowerShell.Durable.SDK -ErrorAction Stop
9 changes: 9 additions & 0 deletions samples/functionChaining/requirements.psd1
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This file enables modules to be automatically managed by the Functions service.
# See https://aka.ms/functionsmanageddependency for additional information.
#
@{
# For latest supported version, go to 'https://www.powershellgallery.com/packages/Az'.
# To use the Az module in your function app, please uncomment the line below.
# 'Az' = '9.*'
'AzureFunctions.PowerShell.Durable.SDK' = '1.0.0-alpha'
}