Skip to content

Commit d821d50

Browse files
committed
updated Start-DurableOrchestration to call Get-CurrentActivityForInvocation
1 parent 4a15459 commit d821d50

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/AzureFunctions.PowerShell.Durable.SDK.psm1

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,23 @@ function Start-DurableOrchestration {
113113
$InstanceId = (New-Guid).Guid
114114
}
115115

116+
$invocationId = GetInvocationIdFromModulePrivateData
117+
118+
$activityResponse = Get-CurrentActivityForInvocation -InvocationId $invocationId
119+
$activity = $activityResponse.activity
120+
121+
$traceId = $activity.TraceId
122+
$spanId = $activity.SpanId
123+
$traceFlags = $activity.TraceFlags
124+
$traceState = $activity.TraceStateString
125+
126+
$traceparent = "00-$traceId-$spanId-$traceFlags"
127+
128+
$headers = @{
129+
"traceparent" = $traceparent
130+
"tracestate" = $traceState
131+
}
132+
116133
$Uri =
117134
if ($DurableClient.rpcBaseUrl) {
118135
# Fast local RPC path
@@ -124,10 +141,8 @@ function Start-DurableOrchestration {
124141
}
125142

126143
$Body = $InputObject | ConvertTo-Json -Compress -Depth 100
127-
128-
$InvocationId = GetInvocationIdFromModulePrivateData
129144

130-
$null = Invoke-RestMethod -Uri $Uri -Method 'POST' -ContentType 'application/json' -Body $Body
145+
$null = Invoke-RestMethod -Uri $Uri -Method 'POST' -ContentType 'application/json' -Body $Body -Headers $headers
131146

132147
return $instanceId
133148
}

0 commit comments

Comments
 (0)