Open CDSFounder opened 2 years ago
You would need to try to run the GitHub version instead of PSGallery one. It has additional logic in PSM1 that could potentially show what the error is about (not guaranteed - but should).
We could also try and update library to 7.2.4, as it was released last month. Probably some library is missing in the end system, that is available on most Windows 10/11 machines maybe.
Thanks @PrzemyslawKlys . I am embarrassed to say I don't actually know (or understand) how to install modules without "Managed Dependency" for Azure Functions.
I used Azure file explorer to find the Managed Dependency files and I replaced all PSWritePDF files with the version I downloaded from Github. This caused log to show that there was a missing dependency "SharedPSGoods". I added SharedPSGoods to the required dependency list, and now I'm back the same error I posted before.
Perhaps I am doing something wrong?
I would really appreciate any other guidance you can provide. Would love to not have this great script I wrote with your awesome module go to waste. :D
well not nessecary, but hard to say. I've never used Azure functions. I do test my modules on Azure Devops and it works fine there.
@PrzemyslawKlys I see. We are willing to engage your services (paid) to help us figure this out if you are available? Could be helpful for the rest of the community to get it working in Azure Functions as well. :)
If it would be that easy. You should try PSWriteOffice module whether you get similar issues. Maybe it's related to something specific in my way I build modules, store DLLs or something. Or maybe it would be even better then using PSWritePDF.
Not sure if I will have time this week, but maybe if I will not be busy I'll give it a try.
I will give it a shot and report back what happens with that module. Do you think that updating the library as mentioned previously could help? Not sure if that's something we can try (don't know how).
Thanks again for your help.
@PrzemyslawKlys I haven't tried the PsWriteOffice as a test yet, but I did add a link of code in the PowerShell Azure Function script so that I can see which DLL files are loaded.
The list was obtained by running this in the script right after calling a PSWritePDF function: [System.AppDomain]::CurrentDomain.GetAssemblies() | Where-Object Location | Sort-Object -Property FullName | Select-Object -Property FullName, Location, GlobalAssemblyCache, IsFullyTrusted
Here is a list of loaded DLLs:
2022-12-02T03:16:47.636 [Information] OUTPUT: FullName : BouncyCastle.Crypto, Version=1.9.0.0, Culture=neutral, PublicKeyToken=0e99375e54769942 2022-12-02T03:16:47.636 [Information] OUTPUT: Location : C:\home\data\ManagedDependencies\2211302012115368258.r\PSWritePDF\0.0.20\Lib\Core\BouncyCastle.Crypto.dll 2022-12-02T03:16:47.637 [Information] OUTPUT: GlobalAssemblyCache : False 2022-12-02T03:16:47.637 [Information] OUTPUT: IsFullyTrusted : True 2022-12-02T03:16:47.637 [Information] OUTPUT: 2022-12-02T03:16:47.637 [Information] OUTPUT: 2022-12-02T03:16:47.637 [Information] OUTPUT: FullName : commandline, Version=2.0.275.0, Culture=neutral, PublicKeyToken=de6f01bd326f8c32 2022-12-02T03:16:47.637 [Information] OUTPUT: Location : C:\Program Files (x86)\SiteExtensions\Functions\4.14.0\workers\powershell\7.2\CommandLine.dll 2022-12-02T03:16:47.638 [Information] OUTPUT: GlobalAssemblyCache : False 2022-12-02T03:16:47.638 [Information] OUTPUT: IsFullyTrusted : True 2022-12-02T03:16:47.639 [Information] OUTPUT: 2022-12-02T03:16:47.639 [Information] OUTPUT: 2022-12-02T03:16:47.639 [Information] OUTPUT: FullName : Google.Protobuf, Version=3.19.4.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604 2022-12-02T03:16:47.639 [Information] OUTPUT: Location : C:\Program Files (x86)\SiteExtensions\Functions\4.14.0\workers\powershell\7.2\Google.Protobuf.dll 2022-12-02T03:16:47.639 [Information] OUTPUT: GlobalAssemblyCache : False 2022-12-02T03:16:47.639 [Information] OUTPUT: IsFullyTrusted : True 2022-12-02T03:16:47.640 [Information] OUTPUT: 2022-12-02T03:16:47.640 [Information] OUTPUT: 2022-12-02T03:16:47.640 [Information] OUTPUT: FullName : Grpc.Core.Api, Version=2.0.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad 2022-12-02T03:16:47.640 [Information] OUTPUT: Location : C:\Program Files (x86)\SiteExtensions\Functions\4.14.0\workers\powershell\7.2\Grpc.Core.Api.dll 2022-12-02T03:16:47.640 [Information] OUTPUT: GlobalAssemblyCache : False 2022-12-02T03:16:47.640 [Information] OUTPUT: IsFullyTrusted : True 2022-12-02T03:16:47.640 [Information] OUTPUT: 2022-12-02T03:16:47.641 [Information] OUTPUT: 2022-12-02T03:16:47.641 [Information] OUTPUT: FullName : Grpc.Net.Client, Version=2.0.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad 2022-12-02T03:16:47.641 [Information] OUTPUT: Location : C:\Program Files (x86)\SiteExtensions\Functions\4.14.0\workers\powershell\7.2\Grpc.Net.Client.dll 2022-12-02T03:16:47.641 [Information] OUTPUT: GlobalAssemblyCache : False 2022-12-02T03:16:47.641 [Information] OUTPUT: IsFullyTrusted : True 2022-12-02T03:16:47.641 [Information] OUTPUT: 2022-12-02T03:16:47.642 [Information] OUTPUT: 2022-12-02T03:16:47.642 [Information] OUTPUT: FullName : Grpc.Net.Common, Version=2.0.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad 2022-12-02T03:16:47.642 [Information] OUTPUT: Location : C:\Program Files (x86)\SiteExtensions\Functions\4.14.0\workers\powershell\7.2\Grpc.Net.Common.dll 2022-12-02T03:16:47.642 [Information] OUTPUT: GlobalAssemblyCache : False 2022-12-02T03:16:47.643 [Information] OUTPUT: IsFullyTrusted : True 2022-12-02T03:16:47.643 [Information] OUTPUT: 2022-12-02T03:16:47.643 [Information] OUTPUT: 2022-12-02T03:16:47.643 [Information] OUTPUT: FullName : itext.barcodes, Version=7.2.2.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca 2022-12-02T03:16:47.643 [Information] OUTPUT: Location : C:\home\data\ManagedDependencies\2211302012115368258.r\PSWritePDF\0.0.20\Lib\Core\itext.barcodes.dll 2022-12-02T03:16:47.643 [Information] OUTPUT: GlobalAssemblyCache : False 2022-12-02T03:16:47.643 [Information] OUTPUT: IsFullyTrusted : True 2022-12-02T03:16:47.643 [Information] OUTPUT: 2022-12-02T03:16:47.644 [Information] OUTPUT: 2022-12-02T03:16:47.644 [Information] OUTPUT: FullName : itext.commons, Version=7.2.2.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca 2022-12-02T03:16:47.644 [Information] OUTPUT: Location : C:\home\data\ManagedDependencies\2211302012115368258.r\PSWritePDF\0.0.20\Lib\Core\itext.commons.dll 2022-12-02T03:16:47.644 [Information] OUTPUT: GlobalAssemblyCache : False 2022-12-02T03:16:47.644 [Information] OUTPUT: IsFullyTrusted : True 2022-12-02T03:16:47.644 [Information] OUTPUT: 2022-12-02T03:16:47.644 [Information] OUTPUT: 2022-12-02T03:16:47.645 [Information] OUTPUT: FullName : itext.forms, Version=7.2.2.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca 2022-12-02T03:16:47.645 [Information] OUTPUT: Location : C:\home\data\ManagedDependencies\2211302012115368258.r\PSWritePDF\0.0.20\Lib\Core\itext.forms.dll 2022-12-02T03:16:47.645 [Information] OUTPUT: GlobalAssemblyCache : False 2022-12-02T03:16:47.645 [Information] OUTPUT: IsFullyTrusted : True 2022-12-02T03:16:47.645 [Information] OUTPUT: 2022-12-02T03:16:47.645 [Information] OUTPUT: 2022-12-02T03:16:47.645 [Information] OUTPUT: FullName : itext.html2pdf, Version=4.0.2.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca 2022-12-02T03:16:47.645 [Information] OUTPUT: Location : C:\home\data\ManagedDependencies\2211302012115368258.r\PSWritePDF\0.0.20\Lib\Core\itext.html2pdf.dll 2022-12-02T03:16:47.646 [Information] OUTPUT: GlobalAssemblyCache : False 2022-12-02T03:16:47.646 [Information] OUTPUT: IsFullyTrusted : True 2022-12-02T03:16:47.646 [Information] OUTPUT: 2022-12-02T03:16:47.646 [Information] OUTPUT: 2022-12-02T03:16:47.646 [Information] OUTPUT: FullName : itext.hyph, Version=7.2.2.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca 2022-12-02T03:16:47.646 [Information] OUTPUT: Location : C:\home\data\ManagedDependencies\2211302012115368258.r\PSWritePDF\0.0.20\Lib\Core\itext.hyph.dll 2022-12-02T03:16:47.646 [Information] OUTPUT: GlobalAssemblyCache : False 2022-12-02T03:16:47.646 [Information] OUTPUT: IsFullyTrusted : True 2022-12-02T03:16:47.646 [Information] OUTPUT: 2022-12-02T03:16:47.646 [Information] OUTPUT: 2022-12-02T03:16:47.646 [Information] OUTPUT: FullName : itext.io, Version=7.2.2.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca 2022-12-02T03:16:47.646 [Information] OUTPUT: Location : C:\home\data\ManagedDependencies\2211302012115368258.r\PSWritePDF\0.0.20\Lib\Core\itext.io.dll 2022-12-02T03:16:47.646 [Information] OUTPUT: GlobalAssemblyCache : False 2022-12-02T03:16:47.646 [Information] OUTPUT: IsFullyTrusted : True 2022-12-02T03:16:47.646 [Information] OUTPUT: 2022-12-02T03:16:47.646 [Information] OUTPUT: 2022-12-02T03:16:47.646 [Information] OUTPUT: FullName : itext.kernel, Version=7.2.2.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca 2022-12-02T03:16:47.647 [Information] OUTPUT: Location : C:\home\data\ManagedDependencies\2211302012115368258.r\PSWritePDF\0.0.20\Lib\Core\itext.kernel.dll 2022-12-02T03:16:47.647 [Information] OUTPUT: GlobalAssemblyCache : False 2022-12-02T03:16:47.647 [Information] OUTPUT: IsFullyTrusted : True 2022-12-02T03:16:47.647 [Information] OUTPUT: 2022-12-02T03:16:47.647 [Information] OUTPUT: 2022-12-02T03:16:47.647 [Information] OUTPUT: FullName : itext.layout, Version=7.2.2.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca 2022-12-02T03:16:47.647 [Information] OUTPUT: Location : C:\home\data\ManagedDependencies\2211302012115368258.r\PSWritePDF\0.0.20\Lib\Core\itext.layout.dll 2022-12-02T03:16:47.647 [Information] OUTPUT: GlobalAssemblyCache : False 2022-12-02T03:16:47.647 [Information] OUTPUT: IsFullyTrusted : True 2022-12-02T03:16:47.647 [Information] OUTPUT: 2022-12-02T03:16:47.647 [Information] OUTPUT: 2022-12-02T03:16:47.647 [Information] OUTPUT: FullName : itext.pdfa, Version=7.2.2.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca 2022-12-02T03:16:47.647 [Information] OUTPUT: Location : C:\home\data\ManagedDependencies\2211302012115368258.r\PSWritePDF\0.0.20\Lib\Core\itext.pdfa.dll 2022-12-02T03:16:47.647 [Information] OUTPUT: GlobalAssemblyCache : False 2022-12-02T03:16:47.647 [Information] OUTPUT: IsFullyTrusted : True 2022-12-02T03:16:47.647 [Information] OUTPUT: 2022-12-02T03:16:47.647 [Information] OUTPUT: 2022-12-02T03:16:47.647 [Information] OUTPUT: FullName : itext.sign, Version=7.2.2.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca 2022-12-02T03:16:47.648 [Information] OUTPUT: Location : C:\home\data\ManagedDependencies\2211302012115368258.r\PSWritePDF\0.0.20\Lib\Core\itext.sign.dll 2022-12-02T03:16:47.648 [Information] OUTPUT: GlobalAssemblyCache : False 2022-12-02T03:16:47.648 [Information] OUTPUT: IsFullyTrusted : True 2022-12-02T03:16:47.648 [Information] OUTPUT: 2022-12-02T03:16:47.648 [Information] OUTPUT: 2022-12-02T03:16:47.648 [Information] OUTPUT: FullName : itext.styledxmlparser, Version=7.2.2.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca 2022-12-02T03:16:47.648 [Information] OUTPUT: Location : C:\home\data\ManagedDependencies\2211302012115368258.r\PSWritePDF\0.0.20\Lib\Core\itext.styledxmlparser.dll 2022-12-02T03:16:47.648 [Information] OUTPUT: GlobalAssemblyCache : False 2022-12-02T03:16:47.648 [Information] OUTPUT: IsFullyTrusted : True 2022-12-02T03:16:47.648 [Information] OUTPUT: 2022-12-02T03:16:47.648 [Information] OUTPUT: 2022-12-02T03:16:47.648 [Information] OUTPUT: FullName : itext.svg, Version=7.2.2.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca 2022-12-02T03:16:47.648 [Information] OUTPUT: Location : C:\home\data\ManagedDependencies\2211302012115368258.r\PSWritePDF\0.0.20\Lib\Core\itext.svg.dll 2022-12-02T03:16:47.649 [Information] OUTPUT: GlobalAssemblyCache : False 2022-12-02T03:16:47.649 [Information] OUTPUT: IsFullyTrusted : True 2022-12-02T03:16:47.649 [Information] OUTPUT: 2022-12-02T03:16:47.649 [Information] OUTPUT: 2022-12-02T03:16:47.649 [Information] OUTPUT: FullName : Microsoft.ApplicationInsights, Version=2.18.0.315, Culture=neutral, PublicKeyToken=31bf3856ad364e35 2022-12-02T03:16:47.649 [Information] OUTPUT: Location : C:\Program Files (x86)\SiteExtensions\Functions\4.14.0\workers\powershell\7.2\Microsoft.ApplicationInsights.dll 2022-12-02T03:16:47.649 [Information] OUTPUT: GlobalAssemblyCache : False 2022-12-02T03:16:47.649 [Information] OUTPUT: IsFullyTrusted : True 2022-12-02T03:16:47.649 [Information] OUTPUT: 2022-12-02T03:16:47.649 [Information] OUTPUT: 2022-12-02T03:16:47.650 [Information] OUTPUT: Location : C:\Program Files (x86)\SiteExtensions\Functions\4.14.0\workers\powershell\7.2\Microsoft.Azure.Functions.PowerShellWorker.dll 2022-12-02T03:16:47.650 [Information] OUTPUT: FullName : Microsoft.Azure.Functions.PowerShellWorker, Version=4.0.2304.0, Culture=neutral, PublicKeyToken=null 2022-12-02T03:16:47.650 [Information] OUTPUT: GlobalAssemblyCache : False 2022-12-02T03:16:47.650 [Information] OUTPUT: IsFullyTrusted : True 2022-12-02T03:16:47.650 [Information] OUTPUT: 2022-12-02T03:16:47.650 [Information] OUTPUT: 2022-12-02T03:16:47.650 [Information] OUTPUT: FullName : Microsoft.CodeAnalysis, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 2022-12-02T03:16:47.650 [Information] OUTPUT: Location : C:\Program Files (x86)\SiteExtensions\Functions\4.14.0\workers\powershell\7.2\Microsoft.CodeAnalysis.dll 2022-12-02T03:16:47.650 [Information] OUTPUT: GlobalAssemblyCache : False 2022-12-02T03:16:47.650 [Information] OUTPUT: IsFullyTrusted : True 2022-12-02T03:16:47.650 [Information] OUTPUT: 2022-12-02T03:16:47.651 [Information] OUTPUT: 2022-12-02T03:16:47.651 [Information] OUTPUT: FullName : Microsoft.CodeAnalysis.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 2022-12-02T03:16:47.651 [Information] OUTPUT: Location : C:\Program Files (x86)\SiteExtensions\Functions\4.14.0\workers\powershell\7.2\Microsoft.CodeAnalysis.CSharp.dll 2022-12-02T03:16:47.651 [Information] OUTPUT: GlobalAssemblyCache : False 2022-12-02T03:16:47.651 [Information] OUTPUT: IsFullyTrusted : True 2022-12-02T03:16:47.651 [Information] OUTPUT: 2022-12-02T03:16:47.651 [Information] OUTPUT: 2022-12-02T03:16:47.651 [Information] OUTPUT: FullName : Microsoft.CSharp, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 2022-12-02T03:16:47.651 [Information] OUTPUT: Location : C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.9\Microsoft.CSharp.dll 2022-12-02T03:16:47.651 [Information] OUTPUT: GlobalAssemblyCache : False 2022-12-02T03:16:47.651 [Information] OUTPUT: IsFullyTrusted : True 2022-12-02T03:16:47.651 [Information] OUTPUT: 2022-12-02T03:16:47.651 [Information] OUTPUT: 2022-12-02T03:16:47.651 [Information] OUTPUT: FullName : Microsoft.DotNet.PlatformAbstractions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60 2022-12-02T03:16:47.651 [Information] OUTPUT: Location : C:\home\data\ManagedDependencies\2211302012115368258.r\PSWritePDF\0.0.20\Lib\Core\Microsoft.DotNet.PlatformAbstractions.dll 2022-12-02T03:16:47.652 [Information] OUTPUT: GlobalAssemblyCache : False 2022-12-02T03:16:47.652 [Information] OUTPUT: IsFullyTrusted : True 2022-12-02T03:16:47.652 [Information] OUTPUT: 2022-12-02T03:16:47.652 [Information] OUTPUT: 2022-12-02T03:16:47.652 [Information] OUTPUT: FullName : Microsoft.Extensions.DependencyModel, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60 2022-12-02T03:16:47.652 [Information] OUTPUT: Location : C:\home\data\ManagedDependencies\2211302012115368258.r\PSWritePDF\0.0.20\Lib\Core\Microsoft.Extensions.DependencyModel.dll 2022-12-02T03:16:47.652 [Information] OUTPUT: GlobalAssemblyCache : False 2022-12-02T03:16:47.652 [Information] OUTPUT: IsFullyTrusted : True 2022-12-02T03:16:47.652 [Information] OUTPUT: 2022-12-02T03:16:47.652 [Information] OUTPUT: 2022-12-02T03:16:47.652 [Information] OUTPUT: FullName : Microsoft.Extensions.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60 2022-12-02T03:16:47.652 [Information] OUTPUT: Location : C:\home\data\ManagedDependencies\2211302012115368258.r\PSWritePDF\0.0.20\Lib\Core\Microsoft.Extensions.Logging.dll 2022-12-02T03:16:47.652 [Information] OUTPUT: GlobalAssemblyCache : False 2022-12-02T03:16:47.652 [Information] OUTPUT: IsFullyTrusted : True 2022-12-02T03:16:47.652 [Information] OUTPUT: 2022-12-02T03:16:47.652 [Information] OUTPUT: 2022-12-02T03:16:47.652 [Information] OUTPUT: FullName : Microsoft.Extensions.Logging.Abstractions, Version=3.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60 2022-12-02T03:16:47.652 [Information] OUTPUT: Location : C:\Program Files (x86)\SiteExtensions\Functions\4.14.0\workers\powershell\7.2\Microsoft.Extensions.Logging.Abstractions.dll 2022-12-02T03:16:47.652 [Information] OUTPUT: GlobalAssemblyCache : False 2022-12-02T03:16:47.652 [Information] OUTPUT: IsFullyTrusted : True 2022-12-02T03:16:47.653 [Information] OUTPUT: 2022-12-02T03:16:47.653 [Information] OUTPUT: 2022-12-02T03:16:47.653 [Information] OUTPUT: FullName : Microsoft.Extensions.Options, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60 2022-12-02T03:16:47.653 [Information] OUTPUT: Location : C:\home\data\ManagedDependencies\2211302012115368258.r\PSWritePDF\0.0.20\Lib\Core\Microsoft.Extensions.Options.dll 2022-12-02T03:16:47.653 [Information] OUTPUT: GlobalAssemblyCache : False 2022-12-02T03:16:47.653 [Information] OUTPUT: IsFullyTrusted : True 2022-12-02T03:16:47.653 [Information] OUTPUT: 2022-12-02T03:16:47.653 [Information] OUTPUT: 2022-12-02T03:16:47.653 [Information] OUTPUT: FullName : Microsoft.Management.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 2022-12-02T03:16:47.653 [Information] OUTPUT: Location : C:\Program Files (x86)\SiteExtensions\Functions\4.14.0\workers\powershell\7.2\runtimes\win10-x64\lib\netstandard1.6\Microsoft.Management.Infrastructure.dll 2022-12-02T03:16:47.653 [Information] OUTPUT: GlobalAssemblyCache : False 2022-12-02T03:16:47.653 [Information] OUTPUT: IsFullyTrusted : True 2022-12-02T03:16:47.653 [Information] OUTPUT: 2022-12-02T03:16:47.653 [Information] OUTPUT: 2022-12-02T03:16:47.653 [Information] OUTPUT: FullName : Microsoft.PowerShell.Commands.Diagnostics, Version=7.2.6.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35 2022-12-02T03:16:47.653 [Information] OUTPUT: Location : C:\Program Files (x86)\SiteExtensions\Functions\4.14.0\workers\powershell\7.2\runtimes\win\lib\net6.0\Microsoft.PowerShell.Commands.Diagnostics.dll 2022-12-02T03:16:47.653 [Information] OUTPUT: GlobalAssemblyCache : False 2022-12-02T03:16:47.653 [Information] OUTPUT: IsFullyTrusted : True 2022-12-02T03:16:47.654 [Information] OUTPUT: 2022-12-02T03:16:47.654 [Information] OUTPUT: 2022-12-02T03:16:47.654 [Information] OUTPUT: FullName : Microsoft.PowerShell.Commands.Management, Version=7.2.6.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35 2022-12-02T03:16:47.654 [Information] OUTPUT: Location : C:\Program Files (x86)\SiteExtensions\Functions\4.14.0\workers\powershell\7.2\runtimes\win\lib\net6.0\Microsoft.PowerShell.Commands.Management.dll 2022-12-02T03:16:47.654 [Information] OUTPUT: GlobalAssemblyCache : False 2022-12-02T03:16:47.654 [Information] OUTPUT: IsFullyTrusted : True 2022-12-02T03:16:47.654 [Information] OUTPUT: 2022-12-02T03:16:47.654 [Information] OUTPUT: 2022-12-02T03:16:47.654 [Information] OUTPUT: FullName : Microsoft.PowerShell.Commands.Utility, Version=7.2.6.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35 2022-12-02T03:16:47.654 [Information] OUTPUT: Location : C:\Program Files (x86)\SiteExtensions\Functions\4.14.0\workers\powershell\7.2\runtimes\win\lib\net6.0\Microsoft.PowerShell.Commands.Utility.dll 2022-12-02T03:16:47.654 [Information] OUTPUT: GlobalAssemblyCache : False 2022-12-02T03:16:47.654 [Information] OUTPUT: IsFullyTrusted : True 2022-12-02T03:16:47.654 [Information] OUTPUT: 2022-12-02T03:16:47.654 [Information] OUTPUT: 2022-12-02T03:16:47.654 [Information] OUTPUT: FullName : Microsoft.PowerShell.ConsoleHost, Version=7.2.6.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35 2022-12-02T03:16:47.654 [Information] OUTPUT: Location : C:\Program Files (x86)\SiteExtensions\Functions\4.14.0\workers\powershell\7.2\runtimes\win\lib\net6.0\Microsoft.PowerShell.ConsoleHost.dll 2022-12-02T03:16:47.654 [Information] OUTPUT: GlobalAssemblyCache : False 2022-12-02T03:16:47.654 [Information] OUTPUT: IsFullyTrusted : True 2022-12-02T03:16:47.654 [Information] OUTPUT: 2022-12-02T03:16:47.654 [Information] OUTPUT: 2022-12-02T03:16:47.655 [Information] OUTPUT: FullName : Microsoft.PowerShell.CoreCLR.Eventing, Version=7.2.6.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35 2022-12-02T03:16:47.655 [Information] OUTPUT: Location : C:\Program Files (x86)\SiteExtensions\Functions\4.14.0\workers\powershell\7.2\runtimes\win\lib\net6.0\Microsoft.PowerShell.CoreCLR.Eventing.dll 2022-12-02T03:16:47.655 [Information] OUTPUT: GlobalAssemblyCache : False 2022-12-02T03:16:47.655 [Information] OUTPUT: IsFullyTrusted : True 2022-12-02T03:16:47.655 [Information] OUTPUT: 2022-12-02T03:16:47.655 [Information] OUTPUT: 2022-12-02T03:16:47.655 [Information] OUTPUT: FullName : Microsoft.PowerShell.MarkdownRender, Version=7.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 2022-12-02T03:16:47.655 [Information] OUTPUT: Location : C:\Program Files (x86)\SiteExtensions\Functions\4.14.0\workers\powershell\7.2\Microsoft.PowerShell.MarkdownRender.dll 2022-12-02T03:16:47.655 [Information] OUTPUT: GlobalAssemblyCache : False 2022-12-02T03:16:47.655 [Information] OUTPUT: IsFullyTrusted : True 2022-12-02T03:16:47.655 [Information] OUTPUT: 2022-12-02T03:16:47.655 [Information] OUTPUT: 2022-12-02T03:16:47.655 [Information] OUTPUT: FullName : Microsoft.PowerShell.Security, Version=7.2.6.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35 2022-12-02T03:16:47.655 [Information] OUTPUT: Location : C:\Program Files (x86)\SiteExtensions\Functions\4.14.0\workers\powershell\7.2\runtimes\win\lib\net6.0\Microsoft.PowerShell.Security.dll 2022-12-02T03:16:47.656 [Information] OUTPUT: GlobalAssemblyCache : False 2022-12-02T03:16:47.656 [Information] OUTPUT: IsFullyTrusted : True 2022-12-02T03:16:47.656 [Information] OUTPUT: 2022-12-02T03:16:47.656 [Information] OUTPUT: 2022-12-02T03:16:47.656 [Information] OUTPUT: FullName : Microsoft.Win32.Primitives, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 2022-12-02T03:16:47.656 [Information] OUTPUT: Location : C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.9\Microsoft.Win32.Primitives.dll 2022-12-02T03:16:47.656 [Information] OUTPUT: GlobalAssemblyCache : False 2022-12-02T03:16:47.656 [Information] OUTPUT: IsFullyTrusted : True 2022-12-02T03:16:47.656 [Information] OUTPUT: 2022-12-02T03:16:47.656 [Information] OUTPUT: 2022-12-02T03:16:47.656 [Information] OUTPUT: FullName : Microsoft.Win32.Registry, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 2022-12-02T03:16:47.656 [Information] OUTPUT: Location : C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.9\Microsoft.Win32.Registry.dll 2022-12-02T03:16:47.656 [Information] OUTPUT: GlobalAssemblyCache : False 2022-12-02T03:16:47.656 [Information] OUTPUT: IsFullyTrusted : True 2022-12-02T03:16:47.656 [Information] OUTPUT: 2022-12-02T03:16:47.656 [Information] OUTPUT: 2022-12-02T03:16:47.657 [Information] OUTPUT: FullName : Microsoft.WSMan.Management, Version=7.2.6.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35 2022-12-02T03:16:47.657 [Information] OUTPUT: Location : C:\Program Files (x86)\SiteExtensions\Functions\4.14.0\workers\powershell\7.2\runtimes\win\lib\net6.0\Microsoft.WSMan.Management.dll
Is this helpful at all? It seems that some (all?) of the iText DLLs are loading.
@PrzemyslawKlys ok I think I got somewhere. I was able to get it to give me more detailed logging. It seems that Microsoft.Extensions.Logging.Abstractions fails to load. I'm not sure what that is. Full error below.
I also observed that this problem does not exist when I choose PowerShell Core 7.0 instead of 7.2. Perhaps something with PSWritePDF is not fully compatible with PowerShell Core 7.2? That would be strange because my local machine runs PowerShell Core 7.2 and it works totally fine.
Unfortunately, PowerShell Core 7.0 will deprecate in Azure Functions on Dec 3rd - less than two days from now.
I hope this helps someone smarter than me get to the root of the problem. :)
Error when loading the PSWritePDF module in Azure Function with PowerShell Core 7.2:
2022-12-02T03:38:33.083 [Error] ERROR: Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.Exception :Type : System.IO.FileLoadExceptionMessage : Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.TargetSite :Name : LoadFromPathDeclaringType : System.Runtime.Loader.AssemblyLoadContextMemberType : MethodModule : System.Private.CoreLib.dllSource : System.Private.CoreLibHResult : -2146232799StackTrace :at System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, String ilPath, String niPath, ObjectHandleOnStack retAssembly)at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)at System.Reflection.Assembly.LoadFrom(String assemblyFile)at Microsoft.PowerShell.Commands.AddTypeCommand.LoadAssemblies(IEnumerable1 assemblies)at Microsoft.PowerShell.Commands.AddTypeCommand.EndProcessing()at System.Management.Automation.Cmdlet.DoEndProcessing()at System.Management.Automation.CommandProcessorBase.Complete()CategoryInfo : NotSpecified: (:) [Add-Type], FileLoadExceptionFullyQualifiedErrorId : System.IO.FileLoadException,Microsoft.PowerShell.Commands.AddTypeCommandInvocationInfo :MyCommand : Add-TypeScriptLineNumber : 17OffsetInLine : 5HistoryId : 1ScriptName : C:\home\data\ManagedDependencies\2212020324498769391.r\PSWritePDF\0.0.20\PSWritePDF.Libraries.ps1Line : Add-Type -Path $PSScriptRoot\Lib\Core\Microsoft.Extensions.Logging.Abstractions.dllPositionMessage : At C:\home\data\ManagedDependencies\2212020324498769391.r\PSWritePDF\0.0.20\PSWritePDF.Libraries.ps1:17 char:5+ Add-Type -Path $PSScriptRoot\Lib\Core\Microsoft.Extensions.Loggin …+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~PSScriptRoot : C:\home\data\ManagedDependencies\2212020324498769391.r\PSWritePDF\0.0.20PSCommandPath : C:\home\data\ManagedDependencies\2212020324498769391.r\PSWritePDF\0.0.20\PSWritePDF.Libraries.ps1InvocationName : Add-TypeCommandOrigin : InternalScriptStackTrace : at <ScriptBlock>, C:\home\data\ManagedDependencies\2212020324498769391.r\PSWritePDF\0.0.20\PSWritePDF.Libraries.ps1: line 17at <ScriptBlock>, C:\home\site\wwwroot\Split-NewSignupPacketPDF\run.ps1: line 32Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcException : Result: ERROR: Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.Exception :Type : System.IO.FileLoadExceptionMessage : Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.TargetSite :Name : LoadFromPathDeclaringType : System.Runtime.Loader.AssemblyLoadContextMemberType : MethodModule : System.Private.CoreLib.dllSource : System.Private.CoreLibHResult : -2146232799StackTrace :at System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, String ilPath, String niPath, ObjectHandleOnStack retAssembly)at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)at System.Reflection.Assembly.LoadFrom(String assemblyFile)at Microsoft.PowerShell.Commands.AddTypeCommand.LoadAssemblies(IEnumerable
1 assemblies)at Microsoft.PowerShell.Commands.AddTypeCommand.EndProcessing()at System.Management.Automation.Cmdlet.DoEndProcessing()at System.Management.Automation.CommandProcessorBase.Complete()CategoryInfo : NotSpecified: (:) [Add-Type], FileLoadExceptionFullyQualifiedErrorId : System.IO.FileLoadException,Microsoft.PowerShell.Commands.AddTypeCommandInvocationInfo :MyCommand : Add-TypeScriptLineNumber : 17OffsetInLine : 5HistoryId : 1ScriptName : C:\home\data\ManagedDependencies\2212020324498769391.r\PSWritePDF\0.0.20\PSWritePDF.Libraries.ps1Line : Add-Type -Path $PSScriptRoot\Lib\Core\Microsoft.Extensions.Logging.Abstractions.dllPositionMessage : At C:\home\data\ManagedDependencies\2212020324498769391.r\PSWritePDF\0.0.20\PSWritePDF.Libraries.ps1:17 char:5+ Add-Type -Path $PSScriptRoot\Lib\Core\Microsoft.Extensions.Loggin …+ ~~~~~~~~~~~~~PSScriptRoot : C:\home\data\ManagedDependencies\2212020324498769391.r\PSWritePDF\0.0.20PSCommandPath : C:\home\data\ManagedDependencies\2212020324498769391.r\PSWritePDF\0.0.20\PSWritePDF.Libraries.ps1InvocationName : Add-TypeCommandOrigin : InternalScriptStackTrace : at
You can try running it on Linux on PS 7.2 and see if it's different.
We need to try and update the package or go thru dependencies of iText:
And see if we missed something critical - seeing this:
Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.Exception :Type : System.IO.FileLoadExceptionMessage : Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.TargetSite :Name : LoadFromPathDeclaringType : System.Runtime.Loader.AssemblyLoadContextMemberType : MethodModule : System.Private.CoreLib.dllSource : System.Private.CoreLibHResult : -2146232799StackTrace :at System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, String ilPath, String niPath, ObjectHandleOnStack retAssembly)at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)at System.Reflection.Assembly.LoadFrom(String assemblyFile)at Microsoft.PowerShell.Commands.AddTypeCommand.LoadAssemblies(IEnumerable1 asse
One could go here:
and notice more dependencies:
Microsoft.Bcl.AsyncInterfaces (>= 7.0.0) Microsoft.Extensions.DependencyInjection (>= 7.0.0) Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0.0) Microsoft.Extensions.Logging.Abstractions (>= 7.0.0) Microsoft.Extensions.Options (>= 7.0.0) System.Diagnostics.DiagnosticSource (>= 7.0.0)
We probably need to download those DLLs and see which one is required for Azure Functions.
if anyone is here with the same problem - i determined that it was version incompatibility between loaded versions of BouncyCastle.Crypto.dll. in my case, Az.KeyVault comes with 1.8.8.2 which is an older version. bringing the older version dll into \lib\core resolved the conflict.
i'm not sure how you could resolve this in Azure Functions off the shelf, you would probably need to use some kind of custom runtime env.
Hello,
I am new to using this module. It works great in scripts on my local machine with Powershell Core 7.2, but it does not work when deployed to an Azure Function with the same Ppowershell Core 7.2. I am getting the following error:
"[Warning] WARNING: Get-PDF - Processing document C:\local\Temp\tmp72B6.pdf failed with error: Exception calling ".ctor" with "1" argument(s): "The type initializer for 'iText.Commons.Actions.EventManager' threw an exception."
I am not sure how to further debug this since it works great on my local machine, but not when deploying the same code to Azure function.
Can anyone shine some light on what is going on?