I wanted to deploy a Spring Boot web app to Azure Web Apps for a little trial, but when I was looking at the official tutorial, I was told "First, configure the Maven plugin" and said "No". Now that it is, I would like to summarize the minimum configuration of Java application that does not depend on the development environment.
[(Reference) Deploy the Web app of Spring Boot JAR file to Azure App Service for Linux](https://docs.microsoft.com/ja-jp/java/azure/spring-framework/deploy-spring-boot -java-app-with-maven-plugin? view = azure-java-stable)
As of August 2019, there are three main types of application deployment methods.
--Build a build pipeline in cooperation with the repository --Get the container from the container registry and start it --FTP upload
It seems that there was a deployment via OneDrive before, but it is almost gone.
It seems that FTP is basically not recommended, so there is a trend of effectively choosing between container startup and build pipeline.
When it comes to building, is it basically either using Azure Pipelines or building with Kudu? If you can use ACR, containerizing and creating WebApps via ACR is probably the easiest configuration method. There are various detailed articles on both, so I will omit the details.
However, since it is a big deal, I will leave only the Dockerfile used for this verification as a reference.
FROM azul/zulu-openjdk-alpine
VOLUME /tmp
RUN mkdir /app
WORKDIR /app
ENV JAVA_OPTS="-Duser.timezone=Asia/Tokyo"
COPY build/libs/SampleApp.jar /app/SampleApp.jar
ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app/SampleApp.jar --server.port=80" ]
An image with zulu installed on an alpine-based OS is officially provided, so just copy the jar and define the ENTRYPOINT. After that, register this in ACR and set it to PULL on the Web Apps side, and you're done. It's easy.
The rest of this article summarizes how to configure with legacy FTP for when you want to try the fastest in the free range.
Configure your Java app.
Select [Code] in [Publish], Select Java SE in the runtime stack. The operating system seems to currently support Linux only.
Select FTP from [Deployment Center] on the portal screen you pasted earlier, and press [Dashboard]. Then, the connection information on the FTP server will be displayed, so copy various information and make an FTP connection.
Upload the executable jar file via FTP.
If you use the connection information displayed on the portal as it is, / site / wwwroot /
will be the current directory by default.
You can leave the upload destination as it is.
Of the portal [Configuration] menu → [General settings] Set from.
--Stack: (this time) Java8
--Major version: Java SE
--Minor version: Java SE
--Startup command: java -jar /home/site/wwwroot/SampleApp.jar --server.port = 80
The path starts with / home / and is specified as a full path. The point is that it is slightly different from the root of the FTP server.
Environment variables [Configuration] menu → [Application Settings] If you set it with, it will be passed as it is.
If you execute [Save] in this state, the settings will be saved and reflected in Web Apps. You can check the operation by waiting for a while until it starts and accessing it.
When it's over, it's not really a big deal, but when I entered from the keyword "Run Spring Boot with Azure Web Apps", I couldn't find any information that seems to be the standard for building a pipeline, so I myself I feel like I had a hard time organizing it. Next, I would like to try building with Azure Pipelines linked with Azure Repos.
Recommended Posts