There are various ways to deploy Java applications on an app service. ZIP or WAR files can be uploaded or it can be deployed using a Maven plugin. But Java applications can also be deployed via FTP and executed using an appropriate startup command.
In a new Java App Service, the parkingpage.jar
application is started as a placeholder:
The corresponding application is started by the init_container.sh
script, because the Java environment is hosted as a container in the App Service. All app service variants are available as open source on GitHub and the Java variant in particular.
As an example for the deployment, I put a simple Java application on GitHub. It is a simple server that respons with the current date and time. It is compiled accordingly and packed in a JAR file:
javac SimpleHTTPServer.java jar cfe SimpleHTTPServer.jar SimpleHTTPServer SimpleHTTPServer.class
According to https://docs.microsoft.com/de-de/azure/app-service/containers/app-service-linux-faq#built-in-images, the startup command can look like java -jar my-app.jar
. After uploading the SimpleHTTPServer.jar file via FTP and configure the startup command java -jar SimpleHTTPServer.jar:
The Log Stream shows the error:
After taking a deeper look in the init_container.sh
file, it tries to load the application from the /home/site/wwwroot/
path. According to line 150:
if [ ! -f /home/site/wwwroot/app.jar ] then APP_JAR_PATH=/tmp/appservice/parkingpage.jar echo "Using parking page app with APP_JAR_PATH=$APP_JAR_PATH" elif [[ "$WEBSITE_LOCAL_CACHE_OPTION" = "Always" || "$WEBSITE_SKIP_LOCAL_COPY" = "1" || "$WEBSITE_SKIP_LOCAL_COPY" = "true" ]] then APP_JAR_PATH=/home/site/wwwroot/app.jar echo "No local copy needed. APP_JAR_PATH=$APP_JAR_PATH" else
The application could simply be renamed to app.jar
, which would run it directly. Alternatively, only the above mentioned command path must be specified so that the application loads correctly: java -jar /home/site/wwwroot/SimpleHTTPServer.jar
Schreibe einen Kommentar