[JAVA] Minimal configuration to run Spring Boot application on Azure Web Apps

Thing you want to do

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.

deployment.png

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.

Creating a web apps resource

Configure your Java app.

Select [Code] in [Publish], Select Java SE in the runtime stack. The operating system seems to currently support Linux only.

webapps-create.png

Deploy

Creating an FTP user

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.

ftp.png

file upload

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.

deploy.png

Startup configuration

Of the portal [Configuration] menu → [General settings] Set from.

configure.png

--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.

Summary

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

Minimal configuration to run Spring Boot application on Azure Web Apps
Run WEB application with Spring Boot + Thymeleaf
Spring Boot on Microsoft Azure
[Spring Boot] Web application creation
Sign in to a Spring Boot web application on the Microsoft ID platform
[Java] Deploy the Spring Boot application to Azure App Service
War deploy to Azure Web Apps (maven)
Start web application development with Spring Boot
Creating Java Web Applications to Azure Web Apps
Java beginner tried to make a simple web application using Spring Boot
Deploy the WEB application by Spring Boot to Tomcat server as WAR
Deploy a Spring Boot application on Elastic Beanstalk
I tried to clone a web application full of bugs with Spring Boot
Deploy the Spring Boot project to Tomcat on XAMPP
Spring Boot 2.3 Application Availability
A story that stumbled when deploying a web application created with Spring Boot to EC2
Deploy the application created by Spring Boot to Heroku (public) ②
Sample web application that handles multiple databases in Spring Boot 1.5
Deploy the application created by Spring Boot to Heroku (public) ①
Run LIFF with Spring Boot
Introduction to Spring Boot ① ~ DI ~
Introduction to Spring Boot ② ~ AOP ~
CICS-Run Java application-(4) Spring Boot application
Introduction to Spring Boot Part 1
Try Spring Boot on Mac
Let's make a book management web application with Spring Boot part1
Let's make a book management web application with Spring Boot part3
Let's make a book management web application with Spring Boot part2
How to make CsrfRequestDataValueProcessor and original RequestDataValueProcessor coexist on Spring Boot
[Spring Boot] Precautions when developing a web application with Spring Boot and placing war on an independent Tomcat server
Spring Boot application development in Eclipse
Spring Boot application code review points
gRPC on Spring Boot with grpc-spring-boot-starter
Steps to run docker on Mac
Run Java application in Azure Batch
How to set Spring Boot + PostgreSQL
Inquiry application creation with Spring Boot
How to run JavaFX on Docker
Run GUI application on Docker container
Implement Spring Boot application in Gradle
How to use ModelMapper (Spring boot)
Upgrade spring boot from 1.5 series to 2.0 series
Try running Spring Boot on Kubernetes
Spring Boot2 Web application development with Visual Studio Code SQL Server connection
Personal memo Run Spring Boot + Gradle web project with Codenvy (Eclipse Che)
Spring Boot2 Web application development with Visual Studio Code Hello World creation
Automatically deploy a web application developed in Java using Jenkins [Spring Boot application]
Volume of trying to create a Java Web application on Windows Server 2016
Introduction to Java development environment & Spring Boot application created with VS Code