Error with wkhtmltopdf in python

newToAzure 0 Reputation points
2024-08-13T19:10:34.22+00:00

i have deployed a python application with pdf download to azure. now, i have to manually run the commands "apt -get update" and "apt -get install -y wkhtmltopdf" in the azure app ssh shell then, my api to download pdf works but after some time(like couple of hours) the api responds with 500 internal server error and then after again running the same command, the api again works. How can i solve this issue permanently so that i don't have to run these command again and again?

**I even tried including an startup.sh script and specifying the path to this file in the startup command of the web app. After restarting, the application error :( is shown in the browser window and requests from postman gives 503 and 504. so that solution isn't working.

What can i do to solve this issue?

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

1 answer

Sort by: Most helpful
  1. Grmacjon-MSFT 19,151 Reputation points Moderator
    2024-08-27T21:41:13.1833333+00:00

    Hello @newToAzure thanks for bringing this to our attention. we're sorry to hear you're experiencing this issue.

    seems like there is a problem with the wkhtmltopdf dependence and the installation isn't persisting across restarts. To troubleshoot this further:

    • The first step in troubleshooting is to check the server logs. Look for any error messages or exceptions related to the wkhtmltopdf package. You can find these logs in your Azure portal or by using tools like Application Insights. Ensure that the logs provide detailed information about what’s going wrong during the execution of your API.
    • Consider using Python dependency management tools like pip to manage your dependencies within your application code. This approach avoids relying on package managers like apt-get. Create a requirements.txt file that lists the required dependencies, including wkhtmltopdf. During deployment, use tools like pip to install these dependencies from your requirements file. Azure App Service can be configured to run deployment scripts during deployment. Make sure that the wkhtmltopdf package is listed in your requirements.txt file with the correct version.

    Hope that helps.

    -Grace

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.