diff --git a/src/DurableWorker/DurableController.cs b/src/DurableWorker/DurableController.cs index 2fa1780e..4e32ea67 100644 --- a/src/DurableWorker/DurableController.cs +++ b/src/DurableWorker/DurableController.cs @@ -66,22 +66,27 @@ public void BeforeFunctionInvocation(IList inputData) } else if (_durableFunctionInfo.IsOrchestrationFunction) { - _orchestrationBindingInfo = CreateOrchestrationBindingInfo(inputData); - _powerShellServices.SetOrchestrationContext(_orchestrationBindingInfo.Context); - - // Bote: Cannot find the DurableSDK module here, somehow. - Collection output2 = this.pwsh.AddCommand("Get-Module") - .InvokeAndClearCommands(); - - var context = inputData[0]; - Collection> output = this.pwsh.AddCommand("Set-BindingData") - .AddParameter("Input", context.Data.String) - .AddParameter("SetResult", (Action)_orchestrationBindingInfo.Context.SetExternalResult) - .InvokeAndClearCommands>(); - if (output.Count() == 1) + try { - this._orchestrationInvoker.SetExternalInvoker(output[0]); + _orchestrationBindingInfo = CreateOrchestrationBindingInfo(inputData); + var context = inputData[0]; + Collection> output = this.pwsh.AddCommand("Set-BindingData") + .AddParameter("Input", context.Data.String) + .AddParameter("SetResult", (Action)_orchestrationBindingInfo.Context.SetExternalResult) + .InvokeAndClearCommands>(); + if (output.Count() == 1) + { + this._orchestrationInvoker.SetExternalInvoker(output[0]); + } + + _powerShellServices.SetOrchestrationContext(_orchestrationBindingInfo.Context); } + catch + { + _orchestrationBindingInfo = CreateOrchestrationBindingInfo(inputData); + _powerShellServices.SetOrchestrationContext(_orchestrationBindingInfo.Context); + } + } } diff --git a/src/PowerShell/PowerShellManager.cs b/src/PowerShell/PowerShellManager.cs index 168aeb26..95feb796 100644 --- a/src/PowerShell/PowerShellManager.cs +++ b/src/PowerShell/PowerShellManager.cs @@ -208,6 +208,7 @@ public Hashtable InvokeFunction( try { + durableController.BeforeFunctionInvocation(inputData); AddEntryPointInvocationCommand(functionInfo); @@ -216,10 +217,11 @@ public Hashtable InvokeFunction( SetInputBindingParameterValues(functionInfo, inputData, durableController, triggerMetadata, traceContext, retryContext); stopwatch.OnCheckpoint(FunctionInvocationPerformanceStopwatch.Checkpoint.InputBindingValuesReady); - if (!durableController.ShouldSuppressPipelineTraces()) + /* This has been moved to the DF SDK (although it should also be moved down within the worker) + * if (!durableController.ShouldSuppressPipelineTraces()) { _pwsh.AddCommand("Microsoft.Azure.Functions.PowerShellWorker\\Trace-PipelineObject"); - } + }*/ stopwatch.OnCheckpoint(FunctionInvocationPerformanceStopwatch.Checkpoint.InvokingFunctionCode); Logger.Log(isUserOnlyLog: false, LogLevel.Trace, CreateInvocationPerformanceReportMessage(functionInfo.FuncName, stopwatch)); @@ -270,9 +272,15 @@ private void SetInputBindingParameterValues( { var bindingInfo = functionInfo.InputBindings[binding.Name]; valueToUse = Utils.TransformInBindingValueAsNeeded(paramInfo, bindingInfo, binding.Data.ToObject()); + _pwsh.AddParameter(binding.Name, valueToUse); + } + else + { + // move this further down in the worker + // _pwsh.AddParameter(binding.Name, valueToUse); + } - _pwsh.AddParameter(binding.Name, valueToUse); } }