I am using the following to add in the AzureAD
Import-Module AzureAD -UseWindowsPowerShell
I have also added in 'AzureAD' = '2.*'
in the requirements.psd1
Yet when I run the function I am getting the following error message:
ERROR: Failed to generate proxies for remote module 'AzureAD'. The -OutputModule parameter does not resolve to a path, and a user module path cannot be found for the provided name.Exception :Type : System.InvalidOperationExceptionMessage : Failed to generate proxies for remote module 'AzureAD'. The -OutputModule parameter does not resolve to a path, and a user module path cannot be found for the provided name.InnerException :Type : System.Management.Automation.CmdletInvocationExceptionErrorRecord :Exception :Type : System.ArgumentExceptionMessage : The -OutputModule parameter does not resolve to a path, and a user module path cannot be found for the provided name.TargetSite :Name : ThrowTerminatingErrorDeclaringType : System.Management.Automation.MshCommandRuntime, System.Management.Automation, Version=7.2.4.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35MemberType : MethodModule : System.Management.Automation.dllSource : System.Management.AutomationHResult : -2147024809StackTrace :at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)TargetObject : Microsoft.PowerShell.Commands.ExportPSSessionCommandCategoryInfo : InvalidArgument: (Microsoft.PowerShel…ortPSSessionCommand:ExportPSSessionCommand) [Export-PSSession], ArgumentExceptionFullyQualifiedErrorId : ExportPSSession_ErrorModuleNameOrPath,Microsoft.PowerShell.Commands.ExportPSSessionCommandInvocationInfo :MyCommand : Export-PSSessionHistoryId : 1InvocationName : Export-PSSessionCommandOrigin : InternalScriptStackTrace : at , C:\home\site\wwwroot\TimerTrigger1\run.ps1: line 3TargetSite :Name : InvokeDeclaringType : System.Management.Automation.Runspaces.PipelineBase, System.Management.Automation, Version=7.2.4.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35MemberType : MethodModule : System.Management.Automation.dllMessage : The -OutputModule parameter does not resolve to a path, and a user module path cannot be found for the provided name.InnerException :Type : System.ArgumentExceptionMessage : The -OutputModule parameter does not resolve to a path, and a user module path cannot be found for the provided name.TargetSite :Name : ThrowTerminatingErrorDeclaringType : System.Management.Automation.MshCommandRuntime, System.Management.Automation, Version=7.2.4.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35MemberType : MethodModule : System.Management.Automation.dllSource : System.Management.AutomationHResult : -2147024809StackTrace :at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)Source : System.Management.AutomationHResult : -2146233087StackTrace :at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)at System.Management.Automation.Runspaces.Pipeline.Invoke()at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection1 input, PSDataCollection
1 output, PSInvocationSettings settings)at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection1 input, PSDataCollection
1 output, PSInvocationSettings settings)at System.Management.Automation.RemoteDiscoveryHelper.InvokeNestedPowerShell(PowerShell powerShell, PSCmdlet cmdlet, PSInvocationSettings invocationSettings, String errorMessageTemplate, CancellationToken cancellationToken) MoveNext()at System.Management.Automation.RemoteDiscoveryHelper.EnumerateWithCatch[T](IEnumerable1 enumerable, Action
1 exceptionHandler) MoveNext()HResult : -2146233079CategoryInfo : NotSpecified: (:) [Import-Module], InvalidOperationExceptionFullyQualifiedErrorId :
CodePudding user response:
I tried to reproduce the same in my environment and got the same error:
I created a Function App with configuration settings like below:
To resolve the error, make sure to set the Runtime version as 4
like below:
I added 'AzureAD' = '2.*'
in the requirements.psd1 file:
I created Http trigger function and got the module imported successfully like below:
using namespace System.Net
param($Request, $TriggerMetadata)
Import-Module -Name 'AzureAD' -UseWindowsPowershell
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::OK
Body = $body
})
Response:
If still the error persists, try creating a new Function App from scratch with latest versions.
Alternatively, you can also invoke the Http trigger multiple times to get the response successfully.
Reference: