PDFIum works fine locally but not in Azure Functions

241 Views Asked by At

I made the Azure Function app which uses PDFium.Windows and PDFiumSharpV2. The function runs fine locally on the development machine and it can convert PDFs to images but when deployed on Azure as a function (Windows) attempt to convert fails with the following message:

[Error]   Unable to find an entry point named 'FPDF_LoadCustomDocument' in DLL 'pdfium_x86'.

DLLs are set to "Copy if newer" and publish/deploy is done using publish profile from Visual Studio. I've tried both Portable and Windows-x86 as Target runtime and there is no difference. Log reports x86 process on x64 OS.

What is wrong, why it won't work on Azure but works fine on the dev machine?

1

There are 1 best solutions below

0
nighthawk On

Problem is fixed now but I'm not sure why. Here is what I did before and what was done later to "fix" it.

I've made initial version of function which just accepts file and it checks is the received file PDF. Then I published that just to verify do the other apps connect to function correctly using API key and get appropriate response when PDF is sent, when you send invalid file etc.

Then I added two Nuget packages mentioned in question. When all changes were done, we tested locally and it worked fine - test is passing, everything works as expected, last step is to publish the function.

When we published and tested with hosted function on Azure, problems described in question have started. Contents of published ZIP are fine, all required files are there but it just throws error from question.

After some searching and trying to find out what is going on, I've decided to delete both Azure Function on Azure and publish profile from Visual Studio.

I made identical publish profile (Azure Functions Windows, portable, AnyCPU - basically default settings), published the function and it just started working, without any issues. Why? I have no idea.