@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.shand add your changes to the top of the file as shown below
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.