[BUG]PnP.PowerShell module not loading in Azure Function App with PowerShell Core 7.2 #3111
-
I'm encountering a problem with the PnP.PowerShell module when executing my Azure Function App. The application uses PowerShell Core 7.2, and my requirements.psd1 includes 'PnP.PowerShell' = '2.1.46-nightly'. The issue arose recently and might be linked to a recent update of the PnP PowerShell module. The application logs indicate that the PnP.PowerShell module is not being loaded despite being declared in the requirements.psd1 file. The error message suggests the module is missing from any module directory. Subsequent errors include command not found exceptions for the Connect-PnPOnline and Get-PnPWeb cmdlets, which are part of the PnP.PowerShell module. I have attempted to import the module directly in my script using Import-Module PnP.PowerShell -DisableNameChecking, but this has not resolved the issue. Here is the log output from Application Insights:
Exception :
ScriptStackTrace : at , C:\home\site\wwwroot\s-test\run.ps1: line 6 2023-05-14T19:04:10Z [Warning] The Function app may be missing a module containing the 'Connect-PnPOnline' command definition. If this command belongs to a module available on the PowerShell Gallery, add a reference to this module to requirements.psd1. Make sure this module is compatible with PowerShell 7. For more details, see https://aka.ms/functions-powershell-managed-dependency. If the module is installed but you are still getting this error, try to import the module explicitly by invoking Import-Module just before the command that produces the error: this will not fix the issue but will expose the root cause. Exception :
at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandTypes commandTypes, SearchResolutionOptions searchResolutionOptions, CommandOrigin commandOrigin, ExecutionContext context)
ScriptStackTrace : at , C:\home\site\wwwroot\s-test\run.ps1: line 19 2023-05-14T19:04:10Z [Error] ERROR: The term 'Get-PnPWeb' is not recognized as a name of a cmdlet, function, script file, or executable program. Exception :
at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandTypes commandTypes, SearchResolutionOptions searchResolutionOptions, CommandOrigin commandOrigin, ExecutionContext context)
ScriptStackTrace : at , C:\home\site\wwwroot\s-test\run.ps1: line 22` it was working couple of days ago now i don't know what is generating the not loading of the pnp module to my azure function. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Updates i have fixed the issue it is from the Azure Function it slef since the requirements.psd1 is not loading the pnp module i don't know why exactly i have installed the module manually to my Azure Function storage then imported the module to The function and it works. |
Beta Was this translation helpful? Give feedback.
Updates i have fixed the issue it is from the Azure Function it slef since the requirements.psd1 is not loading the pnp module i don't know why exactly i have installed the module manually to my Azure Function storage then imported the module to The function and it works.