need to have java while running python webapp on linux

Kesavamurthi D 106 Reputation points
2022-09-02T02:40:04.607+00:00

hi admin

i am trying to have PDF to jpeg conversion in my python code , for that i have installed pdf2jpg python librariy , during run time it requires java .
so i have a startup command
apt-get update;apt-get install -y openjdk-8-jdk

2022-09-02T02:37:28.591Z INFO - Initiating warmup request to container conversion12_0_3b7bc9d7 for site conversion12
2022-09-02T02:37:45.222Z INFO - Waiting for response to warmup request for container conversion12_0_3b7bc9d7. Elapsed time = 16.6313512 sec
2022-09-02T02:38:03.160Z INFO - Waiting for response to warmup request for container conversion12_0_3b7bc9d7. Elapsed time = 34.5689005 sec
2022-09-02T02:38:19.040Z INFO - Waiting for response to warmup request for container conversion12_0_3b7bc9d7. Elapsed time = 50.4491218 sec

it doesn't work while restarting the app ,but when i run this command in ssh console it has been executed successfully and code is giving correct results.
but after restarting the app the code is not workign container instance also changed.
could you pls guide how to install java while starting the container..

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

Accepted answer
  1. VenkateshDodda-MSFT 19,616 Reputation points Microsoft Employee
    2022-09-02T07:35:33.833+00:00

    @Kesavamurthi D Thank you for reaching out to Microsoft Q&A. Apologize for the inconvenience caused on this.

    This is a known phenomenon on App Service, as data only persists under /home directory only and to make the installations persist it is advisable to use a custom start up script.

    You can follow the below steps, to add the Java installation steps in the existing python webapp startup script.

    • Go to the Kudu site for your App (i.e. https://<sitename>.azurewebsites.net) and select SSH from the menu.
    • SSH into the container and copy the current startup script by typing using the command cp /opt/startup/startup.sh /home
    • Using your favorite editor, edit the startup.sh under /home/startup.sh and add your changes to the top of the file as shown below

    237194-image.png

    If you want to install Java 11 you need to add the below set of lines to your startup.sh script.

     apt-get update && apt-get install -y default-jdk  
    

    If you want to install Java 8, you need to add the below set of lines in your startup.sh script as mentioned here

    apt-get update && apt-get install -y software-properties-common  
    apt-add-repository 'deb http://security.debian.org/debian-security stretch/updates main'  
    apt-get update && apt-get install openjdk-8-jdk  
    

    - Save the file.

    • In the Azure Portal configurations, add “/home/startup.sh” as the Startup Command and restart the site.

    We have tested the above and it is working fine from our end, and I would recommend you test it from your end as well.

    For more information, you can refer to this documentation on Custom startup script on Nodejs & python. Feel free to reach back to me if you have any further questions on this.

    Note: I would suggest you Increase the container startup time to 1800 seconds by adding the application setting WEBSITES_CONTAINER_START_TIME_LIMIT=1800 which is the amount of time in seconds to wait for the container to complete start-up before restarting the container.


0 additional answers

Sort by: Most helpful