Skip to content

Commit e2e73d1

Browse files
authored
Use local RPC endpoint when starting an orchestration (#626)
* Use fast local RPC path in Start-NewOrchestration * Stop on errors in Start-NewOrchestration
1 parent 5053bbd commit e2e73d1

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/Modules/Microsoft.Azure.Functions.PowerShellWorker/Microsoft.Azure.Functions.PowerShellWorker.psm1

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,24 @@ function Start-DurableOrchestration {
5454
[object] $DurableClient
5555
)
5656

57+
$ErrorActionPreference = 'Stop'
58+
5759
if ($null -eq $DurableClient) {
5860
$DurableClient = GetDurableClientFromModulePrivateData
5961
}
6062

6163
$InstanceId = (New-Guid).Guid
6264

63-
$UriTemplate = $DurableClient.creationUrls.createNewInstancePostUri
64-
$Uri = $UriTemplate.Replace('{functionName}', $FunctionName).Replace('[/{instanceId}]', "/$InstanceId")
65+
$Uri =
66+
if ($DurableClient.rpcBaseUrl) {
67+
# Fast local RPC path
68+
"$($DurableClient.rpcBaseUrl)orchestrators/$FunctionName$($InstanceId ? "/$InstanceId" : '')"
69+
} else {
70+
# Legacy app frontend path
71+
$UriTemplate = $DurableClient.creationUrls.createNewInstancePostUri
72+
$UriTemplate.Replace('{functionName}', $FunctionName).Replace('[/{instanceId}]', "/$InstanceId")
73+
}
74+
6575
$Body = $InputObject | ConvertTo-Json -Compress
6676

6777
$null = Invoke-RestMethod -Uri $Uri -Method 'POST' -ContentType 'application/json' -Body $Body

0 commit comments

Comments
 (0)