File tree Expand file tree Collapse file tree 4 files changed +36
-0
lines changed
DurableSDK/Commands/Internals Expand file tree Collapse file tree 4 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,17 @@ function GetDurableClientFromModulePrivateData {
2222 }
2323}
2424
25+ function GetInvocationIdFromModulePrivateData {
26+ $PrivateData = $PSCmdlet.MyInvocation.MyCommand.Module.PrivateData
27+ if ($null -eq $PrivateData -or $null -eq $PrivateData [' InvocationId' ]) {
28+ # Return null instead of throwing - invocation ID is optional for correlation/tracing
29+ return $null
30+ }
31+ else {
32+ $PrivateData [' InvocationId' ]
33+ }
34+ }
35+
2536function Get-DurableStatus {
2637 [CmdletBinding ()]
2738 param (
@@ -114,6 +125,8 @@ function Start-DurableOrchestration {
114125 }
115126
116127 $Body = $InputObject | ConvertTo-Json - Compress - Depth 100
128+
129+ $InvocationId = GetInvocationIdFromModulePrivateData
117130
118131 $null = Invoke-RestMethod - Uri $Uri - Method ' POST' - ContentType ' application/json' - Body $Body
119132
Original file line number Diff line number Diff line change @@ -13,6 +13,8 @@ public interface IPowerShellServices
1313 {
1414 void SetDurableClient ( object durableClient ) ;
1515
16+ void SetInvocationId ( string invocationId ) ;
17+
1618 void SetOrchestrationContext ( OrchestrationContext orchestrationContext ) ;
1719
1820 void ClearOrchestrationContext ( ) ;
Original file line number Diff line number Diff line change @@ -45,6 +45,15 @@ public void SetDurableClient(object durableClient)
4545 _hasSetOrchestrationContext = true ;
4646 }
4747
48+ public void SetInvocationId ( string invocationId )
49+ {
50+ _pwsh . AddCommand ( SetFunctionInvocationContextCommand )
51+ . AddParameter ( "InvocationId" , invocationId )
52+ . InvokeAndClearCommands ( ) ;
53+
54+ _hasSetOrchestrationContext = true ;
55+ }
56+
4857 public void SetOrchestrationContext ( OrchestrationContext orchestrationContext )
4958 {
5059 _pwsh . AddCommand ( SetFunctionInvocationContextCommand )
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ public class SetFunctionInvocationContextCommand : PSCmdlet
2323 {
2424 private const string ContextKey = "OrchestrationContext" ;
2525 private const string DurableClientKey = "DurableClient" ;
26+ private const string InvocationIdKey = "InvocationId" ;
2627
2728 /// <summary>
2829 /// The orchestration context.
@@ -36,6 +37,12 @@ public class SetFunctionInvocationContextCommand : PSCmdlet
3637 [ Parameter ( Mandatory = true , ParameterSetName = DurableClientKey ) ]
3738 public object DurableClient { get ; set ; }
3839
40+ /// <summary>
41+ /// The function invocation ID.
42+ /// </summary>
43+ [ Parameter ( Mandatory = true , ParameterSetName = InvocationIdKey ) ]
44+ public string InvocationId { get ; set ; }
45+
3946 /// <summary>
4047 /// Whether or not to clear the privateData of this module.
4148 /// </summary>
@@ -70,11 +77,16 @@ protected override void EndProcessing()
7077 privateData [ DurableClientKey ] = DurableClient ;
7178 break ;
7279
80+ case InvocationIdKey :
81+ privateData [ InvocationIdKey ] = InvocationId ;
82+ break ;
83+
7384 default :
7485 if ( Clear . IsPresent )
7586 {
7687 privateData . Remove ( ContextKey ) ;
7788 privateData . Remove ( DurableClientKey ) ;
89+ privateData . Remove ( InvocationIdKey ) ;
7890 }
7991 break ;
8092 }
You can’t perform that action at this time.
0 commit comments