[JAVA] War deploy to Azure Web Apps (maven)

Purpose

Now that GitActions is in preview, have git do the maven build and deploy it to WebApps

1: App preparation

First, create a Maven + Tomcat Java application

maven wrote as follows

  <properties>
  	<java.version>1.8</java.version>
  	<maven.compiler.source>1.8</maven.compiler.source>
  	<maven.compiler.target>1.8</maven.compiler.target>
  	<RESOURCEGROUP_NAME>DeployTest</RESOURCEGROUP_NAME>
  	<WEBAPP_NAME>MavenJsptest</WEBAPP_NAME>
  </properties>
  <dependencies>
  	<dependency>
	    <groupId>javax.servlet</groupId>
	    <artifactId>javax.servlet-api</artifactId>
	    <version>4.0.1</version>
	    <scope>provided</scope>
	</dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <finalName>ROOT</finalName> <!-- Azure default root pass -->
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.6</version>
        <configuration>
          <packagingExcludes>WEB-INF/lib/javax.servlet-api-3.0.1.jar</packagingExcludes>
        </configuration>
      </plugin>
    </plugins>
  </build>

Especially packed is the finalName </ font> part, which is the name of the war file name generated by mvn install. Since WebApps goes to refer to ROOT and below by default, an error occurred if it was specified other than this.

  • If there is a way to prevent the error even with another name, please let me know!

Once you've created your app, push it to GitHub

2: WebApps settings

Create an App Service Plan and Web Apps (Java environment matches the app), select "Deploy Center", and select GitAction or the repository of the created app.

At the end, yaml is output, but if you look inside it, you can see that Java version selection and mvn clean install are done.

3: Confirmation

If you do so far, you can see that the action on GitHub is working. If there are no problems, it will be deployed and can be accessed normally.

Impressions

Jenkins and Azure Pipeline are also great tools, but I was worried that setting and building was a little troublesome, so this time GitActions was very easy because I could use it without building if I registered GitHub and Azure.

I didn't edit yaml this time, but I think that it can be developed more effectively by customizing it (running unit tests, etc.).

Recommended Posts

War deploy to Azure Web Apps (maven)
Deploy Java web app to Azure with maven
Creating Java Web Applications to Azure Web Apps
Deploy Rails apps to Azure App Service using Docker & Continuous Deployment
Introduction to Java Web Apps Performance Troubleshooting
Deploy the WEB application by Spring Boot to Tomcat server as WAR
Deploy Azure Functions using Maven under Proxy environment
How to deploy
To manually deploy Struts2 as a war file
Remote debugging of Java applications in Azure Web Apps
Steps to deploy to Heroku
Steps to deploy Struts 2.5.8
Create Maven Web Project
[Java] Deploy the Spring Boot application to Azure App Service