0
votes

I'm working on a powershell function on Azure. The code works without any issue on my machine, but when I try to use the same on Azure I get this long error below:

2021-05-04T14:56:44.027 [Error] ERROR: Cannot process command because of one or more missing mandatory parameters: Name.Exception :Type : System.Management.Automation.ParameterBindingExceptionMessage : Cannot process command because of one or more missing mandatory parameters: Name.ParameterName : NameErrorId : MissingMandatoryParameterLine : 3Offset : 1CommandInvocation :MyCommand : Import-ModuleScriptLineNumber : 3OffsetInLine : 1HistoryId : 1ScriptName : D:\home\site\wwwroot\MYAPP1\run.ps1Line : Import-ModulePositionMessage : At D:\home\site\wwwroot\MYAPP1\run.ps1:3 char:1+ Import-Module+ ~~~~~~~~~~~~~PSScriptRoot : D:\home\site\wwwroot\MYAPP1PSCommandPath : D:\home\site\wwwroot\MYAPP1\run.ps1InvocationName : Import-ModulePipelineLength : 1PipelinePosition : 1CommandOrigin : InternalErrorRecord :Exception :Type : System.Management.Automation.ParentContainsErrorRecordExceptionMessage : Cannot process command because of one or more missing mandatory parameters: Name.HResult : -2146233087CategoryInfo : InvalidArgument: (:) [Import-Module], ParentContainsErrorRecordExceptionFullyQualifiedErrorId : MissingMandatoryParameter,Microsoft.PowerShell.Commands.ImportModuleCommandInvocationInfo :MyCommand : Import-ModuleScriptLineNumber : 3OffsetInLine : 1HistoryId : 1ScriptName : D:\home\site\wwwroot\MYAPP1\run.ps1Line : Import-ModulePositionMessage : At D:\home\site\wwwroot\MYAPP1\run.ps1:3 char:1+ Import-Module+ ~~~~~~~~~~~~~PSScriptRoot : D:\home\site\wwwroot\MYAPP1PSCommandPath : D:\home\site\wwwroot\MYAPP1\run.ps1CommandOrigin : InternalScriptStackTrace : at <ScriptBlock>, D:\home\site\wwwroot\MYAPP1\run.ps1: line 3TargetSite :Name : PromptForMissingMandatoryParametersDeclaringType : System.Management.Automation.CmdletParameterBinderController, System.Management.Automation, Version=7.0.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35MemberType : MethodModule : System.Management.Automation.dllStackTrace :at System.Management.Automation.CmdletParameterBinderController.PromptForMissingMandatoryParameters(Collection`1 fieldDescriptionList, Collection`1 missingMandatoryParameters)at System.Management.Automation.CmdletParameterBinderController.HandleUnboundMandatoryParameters(Int32 validParameterSetCount, Boolean processMissingMandatory, Boolean promptForMandatory, Boolean isPipelineInputExpected, Collection`1& missingMandatoryParameters)at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParameters(Collection`1 arguments)at System.Management.Automation.CommandProcessor.BindCommandLineParameters()at System.Management.Automation.CommandProcessor.Prepare(IDictionary psDefaultParameterValues)at System.Management.Automation.CommandProcessorBase.DoPrepare(IDictionary psDefaultParameterValues)at System.Management.Automation.Internal.PipelineProcessor.Start(Boolean incomingStream)at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)--- End of stack trace from previous location where exception was thrown ---at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)Data : System.Collections.ListDictionaryInternalSource : System.Management.AutomationHResult : -2146233087CategoryInfo : InvalidArgument: (:) [Import-Module], ParameterBindingExceptionFullyQualifiedErrorId : MissingMandatoryParameter,Microsoft.PowerShell.Commands.ImportModuleCommandInvocationInfo :MyCommand : Import-ModuleScriptLineNumber : 3OffsetInLine : 1HistoryId : 1ScriptName : D:\home\site\wwwroot\MYAPP1\run.ps1Line : Import-ModulePositionMessage : At D:\home\site\wwwroot\MYAPP1\run.ps1:3 char:1+ Import-Module+ ~~~~~~~~~~~~~PSScriptRoot : D:\home\site\wwwroot\MYAPP1PSCommandPath : D:\home\site\wwwroot\MYAPP1\run.ps1CommandOrigin : InternalScriptStackTrace : at <ScriptBlock>, D:\home\site\wwwroot\MYAPP1\run.ps1: line 3Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcException : Result: ERROR: Cannot process command because of one or more missing mandatory parameters: Name.Exception :Type : System.Management.Automation.ParameterBindingExceptionMessage : Cannot process command because of one or more missing mandatory parameters: Name.ParameterName : NameErrorId : MissingMandatoryParameterLine : 3Offset : 1CommandInvocation :MyCommand : Import-ModuleScriptLineNumber : 3OffsetInLine : 1HistoryId : 1ScriptName : D:\home\site\wwwroot\MYAPP1\run.ps1Line : Import-ModulePositionMessage : At D:\home\site\wwwroot\MYAPP1\run.ps1:3 char:1+ Import-Module+ ~~~~~~~~~~~~~PSScriptRoot : D:\home\site\wwwroot\MYAPP1PSCommandPath : D:\home\site\wwwroot\MYAPP1\run.ps1InvocationName : Import-ModulePipelineLength : 1PipelinePosition : 1CommandOrigin : InternalErrorRecord :Exception :Type : System.Management.Automation.ParentContainsErrorRecordExceptionMessage : Cannot process command because of one or more missing mandatory parameters: Name.HResult : -2146233087CategoryInfo : InvalidArgument: (:) [Import-Module], ParentContainsErrorRecordExceptionFullyQualifiedErrorId : MissingMandatoryParameter,Microsoft.PowerShell.Commands.ImportModuleCommandInvocationInfo :MyCommand : Import-ModuleScriptLineNumber : 3OffsetInLine : 1HistoryId : 1ScriptName : D:\home\site\wwwroot\MYAPP1\run.ps1Line : Import-ModulePositionMessage : At D:\home\site\wwwroot\MYAPP1\run.ps1:3 char:1+ Import-Module+ ~~~~~~~~~~~~~PSScriptRoot : D:\home\site\wwwroot\MYAPP1PSCommandPath : D:\home\site\wwwroot\MYAPP1\run.ps1CommandOrigin : InternalScriptStackTrace : at <ScriptBlock>, D:\home\site\wwwroot\MYAPP1\run.ps1: line 3TargetSite :Name : PromptForMissingMandatoryParametersDeclaringType : System.Management.Automation.CmdletParameterBinderController, System.Management.Automation, Version=7.0.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35MemberType : MethodModule : System.Management.Automation.dllStackTrace :at System.Management.Automation.CmdletParameterBinderController.PromptForMissingMandatoryParameters(Collection`1 fieldDescriptionList, Collection`1 missingMandatoryParameters)at System.Management.Automation.CmdletParameterBinderController.HandleUnboundMandatoryParameters(Int32 validParameterSetCount, Boolean processMissingMandatory, Boolean promptForMandatory, Boolean isPipelineInputExpected, Collection`1& missingMandatoryParameters)at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParameters(Collection`1 arguments)at System.Management.Automation.CommandProcessor.BindCommandLineParameters()at System.Management.Automation.CommandProcessor.Prepare(IDictionary psDefaultParameterValues)at System.Management.Automation.CommandProcessorBase.DoPrepare(IDictionary psDefaultParameterValues)at System.Management.Automation.Internal.PipelineProcessor.Start(Boolean incomingStream)at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)--- End of stack trace from previous location where exception was thrown ---at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)Data : System.Collections.ListDictionaryInternalSource : System.Management.AutomationHResult : -2146233087CategoryInfo : InvalidArgument: (:) [Import-Module], ParameterBindingExceptionFullyQualifiedErrorId : MissingMandatoryParameter,Microsoft.PowerShell.Commands.ImportModuleCommandInvocationInfo :MyCommand : Import-ModuleScriptLineNumber : 3OffsetInLine : 1HistoryId : 1ScriptName : D:\home\site\wwwroot\MYAPP1\run.ps1Line : Import-ModulePositionMessage : At D:\home\site\wwwroot\MYAPP1\run.ps1:3 char:1+ Import-Module+ ~~~~~~~~~~~~~PSScriptRoot : D:\home\site\wwwroot\MYAPP1PSCommandPath : D:\home\site\wwwroot\MYAPP1\run.ps1CommandOrigin : InternalScriptStackTrace : at <ScriptBlock>, D:\home\site\wwwroot\MYAPP1\run.ps1: line 3Exception: Cannot process command because of one or more missing mandatory parameters: Name.Stack: at System.Management.Automation.CmdletParameterBinderController.PromptForMissingMandatoryParameters(Collection`1 fieldDescriptionList, Collection`1 missingMandatoryParameters)at System.Management.Automation.CmdletParameterBinderController.HandleUnboundMandatoryParameters(Int32 validParameterSetCount, Boolean processMissingMandatory, Boolean promptForMandatory, Boolean isPipelineInputExpected, Collection`1& missingMandatoryParameters)at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParameters(Collection`1 arguments)at System.Management.Automation.CommandProcessor.BindCommandLineParameters()at System.Management.Automation.CommandProcessor.Prepare(IDictionary psDefaultParameterValues)at System.Management.Automation.CommandProcessorBase.DoPrepare(IDictionary psDefaultParameterValues)at System.Management.Automation.Internal.PipelineProcessor.Start(Boolean incomingStream)at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)--- End of stack trace from previous location where exception was thrown ---at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)



2021-05-04T14:57:06.367 [Warning] WARNING: INITIALIZATION: Fallback context save mode to process because of error during checking token cache persistence: Could not find file 'D:\home\site\wwwroot\.IdentityService'..

The function installs automatically the Module needed (Az and AzTable) and it actually work after the second message.

Any help?

From the stack trace in the first line, it looks like you've got a call to Import-Module with no -Name parameter - Cannot process command because of one or more missing mandatory parameters: Name. and PositionMessage : At D:\home\site\wwwroot\MYAPP1\run.ps1:3 char:1 + Import-Module. - mclayton
Thank you very much! I don't know how I missed the import! I'm now left with 2021-05-05T08:20:51.659 [Warning] WARNING: INITIALIZATION: Fallback context save mode to process because of error during checking token cache persistence: Could not find file 'D:\home\site\wwwroot\.IdentityService'..~ But I think is AzAccounts now that has issue - varVal