pnp / pnpframework

PnP Framework is a .NET library targeting Microsoft 365 containing the PnP Provisioning engine and a ton of other useful extensions
https://pnp.github.io/pnpframework/
MIT License
211 stars 145 forks source link

Get-PnPSiteTemplate -Out not working in a function app #813

Open TMVUpShare opened 1 year ago

TMVUpShare commented 1 year ago

I use manage identities in my function app and i'm trying to use Get-PnPSiteTemplate to generate a site template.

All my code works if i run it locally in PowerShell but when i move the code to my function app i get an error when it tries to save the file via the Get-PnPSiteTemplate -Out.

It seems like the -Out won't work with the local storrage in a Function App.

What i'm trying to solve is that i use Get-PnPSiteTemplate and save the file as .pnp in a SharePoint library.

This is the error i get

2022-12-10T06:50:01Z [Error] ERROR: Could not load type 'Microsoft.Extensions.Logging.Abstractions.Internal.NullScope' from assembly 'Microsoft.Extensions.Logging.Abstractions, Version=3.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.

Exception : Type : System.Management.Automation.PSInvalidOperationException ErrorRecord : Exception : Type : System.Management.Automation.ParentContainsErrorRecordException Message : Could not load type 'Microsoft.Extensions.Logging.Abstractions.Internal.NullScope' from assembly 'Microsoft.Extensions.Logging.Abstractions, Version=3.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. HResult : -2146233087 CategoryInfo : InvalidOperation: (:) [], ParentContainsErrorRecordException FullyQualifiedErrorId : InvalidOperation TargetSite : Name : ProcessRecord DeclaringType : PnP.PowerShell.Commands.Base.PnPConnectedCmdlet MemberType : Method Module : PnP.PowerShell.dll Message : Could not load type 'Microsoft.Extensions.Logging.Abstractions.Internal.NullScope' from assembly 'Microsoft.Extensions.Logging.Abstractions, Version=3.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. Source : PnP.PowerShell HResult : -2146233079 StackTrace : at PnP.PowerShell.Commands.Base.PnPConnectedCmdlet.ProcessRecord() in c:\build\src\Commands\Base\PnPConnectedCmdlet.cs:line 79 at PnP.PowerShell.Commands.PnPSharePointCmdlet.ProcessRecord() in c:\build\src\Commands\Base\PnPSharePointCmdlet.cs:line 121 at System.Management.Automation.Cmdlet.DoProcessRecord() at System.Management.Automation.CommandProcessor.ProcessRecord() CategoryInfo : InvalidOperation: (:) [Get-PnPSiteTemplate], PSInvalidOperationException FullyQualifiedErrorId : InvalidOperation,PnP.PowerShell.Commands.Provisioning.Site.GetSiteTemplate InvocationInfo : MyCommand : Get-PnPSiteTemplate ScriptLineNumber : 60 OffsetInLine : 5 HistoryId : 1 ScriptName : C:\home\site\wwwroot\CreateTemplate\run.ps1 Line : Get-PnPSiteTemplate -Out $tempFile -Force -Connection $c1

PositionMessage  : At C:\home\site\wwwroot\CreateTemplate\run.ps1:60 char:5
                   +     Get-PnPSiteTemplate -Out $tempFile -Force -Connection $c1
                   +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PSScriptRoot     : C:\home\site\wwwroot\CreateTemplate
PSCommandPath    : C:\home\site\wwwroot\CreateTemplate\run.ps1
InvocationName   : Get-PnPSiteTemplate
CommandOrigin    : Internal

ScriptStackTrace : at , C:\home\site\wwwroot\CreateTemplate\run.ps1: line 60

TMVUpShare commented 1 year ago

And if i try to write directly to the function app local storrage i get this error

2022-12-10T07:01:00Z [Error] ERROR: Could not load type 'Microsoft.Extensions.Logging.Abstractions.Internal.NullScope' from assembly 'Microsoft.Extensions.Logging.Abstractions, Version=3.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.

Exception : Type : System.Management.Automation.PSInvalidOperationException ErrorRecord : Exception : Type : System.Management.Automation.ParentContainsErrorRecordException Message : Could not load type 'Microsoft.Extensions.Logging.Abstractions.Internal.NullScope' from assembly 'Microsoft.Extensions.Logging.Abstractions, Version=3.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. HResult : -2146233087 CategoryInfo : InvalidOperation: (:) [], ParentContainsErrorRecordException FullyQualifiedErrorId : InvalidOperation TargetSite : Name : ProcessRecord DeclaringType : PnP.PowerShell.Commands.Base.PnPConnectedCmdlet MemberType : Method Module : PnP.PowerShell.dll Message : Could not load type 'Microsoft.Extensions.Logging.Abstractions.Internal.NullScope' from assembly 'Microsoft.Extensions.Logging.Abstractions, Version=3.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. Source : PnP.PowerShell HResult : -2146233079 StackTrace : at PnP.PowerShell.Commands.Base.PnPConnectedCmdlet.ProcessRecord() in c:\build\src\Commands\Base\PnPConnectedCmdlet.cs:line 79 at PnP.PowerShell.Commands.PnPSharePointCmdlet.ProcessRecord() in c:\build\src\Commands\Base\PnPSharePointCmdlet.cs:line 121 at System.Management.Automation.Cmdlet.DoProcessRecord() at System.Management.Automation.CommandProcessor.ProcessRecord() CategoryInfo : InvalidOperation: (:) [Get-PnPSiteTemplate], PSInvalidOperationException FullyQualifiedErrorId : InvalidOperation,PnP.PowerShell.Commands.Provisioning.Site.GetSiteTemplate InvocationInfo : MyCommand : Get-PnPSiteTemplate ScriptLineNumber : 63 OffsetInLine : 5 HistoryId : 1 ScriptName : C:\home\site\wwwroot\CreateTemplate\run.ps1 Line : Get-PnPSiteTemplate -Out "D:\home\data\tmp.pnp" -Force -Connection $c1

PositionMessage  : At C:\home\site\wwwroot\CreateTemplate\run.ps1:63 char:5
                   +     Get-PnPSiteTemplate -Out "D:\home\data\tmp.pnp" -Force -Connectio …
                   +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PSScriptRoot     : C:\home\site\wwwroot\CreateTemplate
PSCommandPath    : C:\home\site\wwwroot\CreateTemplate\run.ps1
InvocationName   : Get-PnPSiteTemplate
CommandOrigin    : Internal

ScriptStackTrace : at , C:\home\site\wwwroot\CreateTemplate\run.ps1: line 63