PDF won't Generate in Azure Website

JORGE MALDONADO BARRERA 211 Reputation points

I just deployed my first website in Azure. In that website, there is a button to generate a PDF file dynamically using QuestPDF. When my app runs locally, the PDF is correctly generated creating the file under the main project folder. However, after deploying the website and running it on the server (azurewebsites.net), I get an error in a popup window saying "Failed to receive the data". Using the developer tools (F12 in Chrome) in the Console tab I get a 500 internal server error. It seems to me that it has to do with the privileges/permissions on creating/writing a new file in the published project.
I will appreciate your feedback.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,217 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Lex Li (Microsoft) 5,072 Reputation points Microsoft Employee

    Azure App Service isn't the local IIS environment you have, so you cannot expect the same code to work everywhere. Either you switch to your own Azure VM to host this web app, or you use a library that is compatible with Azure App Service (an open source project like QuestPDF is unlikely). You can ask the vendor of QuestPDF for more assistance, https://github.com/QuestPDF/QuestPDF/issues

    0 comments No comments

  2. ajkuma 23,911 Reputation points Microsoft Employee

    Adding to lextm's pointers.

    All Azure Web Apps (as well as Mobile App/Services, WebJobs and Functions) run in a secure environment called a sandbox. Each app runs inside its own sandbox, isolating its execution from other instances on the same machine as well as providing an additional degree of security and privacy which would otherwise not be available.

    Many Windows/.NET specific versions leverage IE APIs and therefore leverage User32/GDI32 extensively. These APIs are largely blocked in the sandbox (regardless of plan) and therefore these frameworks do not work in the sandbox.

    Kindly see the supported and unsupported PDF generators on sandbox - Azure Web App sandbox

    Also, checkout the discussion thread -How can I enable wkhtmltopdf in Azure Windows App.

    0 comments No comments

  3. JORGE MALDONADO BARRERA 211 Reputation points

    We found the problem. The issue was with an image in the wrong location. Such image has to be part of the PDF file.
    QuestPDF is fully compatible with Azure.

    Best regards,
    Jorge Maldonado