@@ -114,6 +114,34 @@ function Start-DurableOrchestration {
114114 }
115115
116116 $invocationId = GetInvocationIdFromModulePrivateData
117+ $headers = Get-TraceHeaders - InvocationId $invocationId
118+
119+ $Uri =
120+ if ($DurableClient.rpcBaseUrl ) {
121+ # Fast local RPC path
122+ " $ ( $DurableClient.rpcBaseUrl ) orchestrators/$FunctionName $ ( $InstanceId ? " /$InstanceId " : ' ' ) "
123+ } else {
124+ # Legacy app frontend path
125+ $UriTemplate = $DurableClient.creationUrls.createNewInstancePostUri
126+ $UriTemplate.Replace (' {functionName}' , $FunctionName ).Replace(' [/{instanceId}]' , " /$InstanceId " )
127+ }
128+
129+ $Body = $InputObject | ConvertTo-Json - Compress - Depth 100
130+
131+ $null = Invoke-RestMethod - Uri $Uri - Method ' POST' - ContentType ' application/json' - Body $Body - Headers $headers
132+
133+ return $instanceId
134+ }
135+
136+ function Get-TraceHeaders {
137+ param (
138+ [Parameter (Mandatory = $true )]
139+ [string ] $InvocationId
140+ )
141+
142+ if ($null -eq $InvocationId ) {
143+ return @ {} # Return an empty headers object
144+ }
117145
118146 $activityResponse = Get-CurrentActivityForInvocation - InvocationId $invocationId
119147 $activity = $activityResponse.activity
@@ -135,21 +163,7 @@ function Start-DurableOrchestration {
135163 " tracestate" = $traceState
136164 }
137165
138- $Uri =
139- if ($DurableClient.rpcBaseUrl ) {
140- # Fast local RPC path
141- " $ ( $DurableClient.rpcBaseUrl ) orchestrators/$FunctionName $ ( $InstanceId ? " /$InstanceId " : ' ' ) "
142- } else {
143- # Legacy app frontend path
144- $UriTemplate = $DurableClient.creationUrls.createNewInstancePostUri
145- $UriTemplate.Replace (' {functionName}' , $FunctionName ).Replace(' [/{instanceId}]' , " /$InstanceId " )
146- }
147-
148- $Body = $InputObject | ConvertTo-Json - Compress - Depth 100
149-
150- $null = Invoke-RestMethod - Uri $Uri - Method ' POST' - ContentType ' application/json' - Body $Body - Headers $headers
151-
152- return $instanceId
166+ return $headers
153167}
154168
155169function Stop-DurableOrchestration {
0 commit comments