-
-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue when deploying to Azure Function #43
Comments
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: Here is a list of loaded DLLs: 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: |
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) 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?
The text was updated successfully, but these errors were encountered: