Java 17 and Tomcat 10.0 available on Azure App Service

Earlier this year we reported that the Microsoft Build of OpenJDK was coming to Azure App Service in an upcoming platform update. That update has now rolled out to all regions and includes Java 17 and Tomcat 10.0, which are both brand new on App Service! These runtimes are now generally available for both Linux and Windows on App Service. Follow the instructions below to learn more and get started.

Java 17

Java 17 on App Service is distributed via the Microsoft Build of OpenJDK, a no-cost long-term supported distribution of the OpenJDK and Microsoft’s new way to collaborate and contribute to the Java ecosystem. You can learn more about the Microsoft Build of OpenJDK from the documentation. Watch the video for an interview with Martijn Verburg – the Principal Engineering Group Manager for the Java Engineering Group at Microsoft – on the Microsoft Build of OpenJDK 17.

Get Started

Download and install Java 17.
Clone the Spring Boot Getting Started sample project

git clone https://github.com/spring-guides/gs-spring-boot

Change directories to the completed project

cd gs-spring-boot/complete

Build and run the application locally.

mvn package
java -jar target/spring-boot-complete-0.0.1-SNAPSHOT.jar

Browse to the app at http://127.0.0.1:8080 and confirm the application is running
Configure the Maven plugin
mvn com.microsoft.azure:azure-webapp-maven-plugin:2.5.0:config

The previous command will start a wizard. Select your desired operating system, Java version, and App Service Plan type. In this case, we suggest LinuxJava 17, and P1v2.
Define value for OS [Linux]:
1: Windows
* 2: Linux
3: Docker
Enter your choice: 2
Define value for javaVersion [Java 8]:
* 1: Java 8
2: Java 11
3: Java 17
Enter your choice: 3
Define value for pricingTier [P1v2]:
1: B1
2: B2
3: B3
4: D1
5: EP1
6: EP2
7: EP3
8: F1
* 9: P1v2
10: P1v3
11: P2v2
12: P2v3
13: P3v2
14: P3v3
15: S1
16: S2
17: S3
18: Y1
Enter your choice: 9
Please confirm webapp properties
Subscription Id : xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
AppName : spring-boot-complete-1646864850428
ResourceGroup : spring-boot-complete-1646864850428-rg
Region : centralus
PricingTier : P1v2
OS : Linux
Java : Java 17
Web server stack: Java SE
Deploy to slot : false
Confirm (Y/N) [Y]: Y
[INFO] Saving configuration to pom.
[INFO] ————————————————————————
[INFO] BUILD SUCCESS
[INFO] ————————————————————————
[INFO] Total time: 02:12 min
[INFO] Finished at: 2022-03-09T14:28:27-08:00
[INFO] ————————————————————————

Deploy the web app using the Maven plugin. This will create the App Service Plan and Web App in a new resource group.
mvn azure-webapp:deploy

Browse to your newly created web app! In the log output from the previous command there will be a URL to your web app.
[INFO] Successfully deployed the artifact to https://spring-boot-complete-1646864850428.azurewebsites.net
[INFO] ————————————————————————
[INFO] BUILD SUCCESS
[INFO] ————————————————————————
[INFO] Total time: 02:58 min
[INFO] Finished at: 2022-03-09T15:25:36-08:00
[INFO] ————————————————————————

Prefer Gradle? See the Azure Plugins for Gradle! You can accomplish the same tasks shown in this article using the Azure Web App Plugin for Gradle. Version 1.3.0 supports Java 17. Updates to the Azure integrations for VS Code and IntelliJ will be available soon.

Tomcat 10.0

Tomcat 10.0 builds on Tomcat 9.0.x, supports Java 8 and later, and is the first Tomcat release to migrate from the Java EE 8 specification to Jakarta EE 9. This means that Tomcat 9.0 or 8.5 applications will require a refactor and rebuild to run on Tomcat 10.0 in almost all cases. This sample application illustrates the code changes that must be made to migrate a Tomcat 9 application from Java EE APIs to Jakarta EE APIs. For more information, please refer to the official Tomcat 10.0 migration guide on the Apache Tomcat website for guidance on migrating Tomcat 9.0 and 8.5 applications to Tomcat 10.0. Tomcat 10 on App Service is supported for Java 8, 11, and 17. It is distributed with Eclipse Temurin for Java 8, and Microsoft Builds of OpenJDK for Java 11 and 17.

Note that Tomcat 10.1 is currently in alpha and will be a separate release of Tomcat from Tomcat 10.0. Tomcat 10.1 will only support Java 11 and later. App Service will support Tomcat 10.1 once a stable release is published by the Apache Foundation. For more information about Tomcat versions and their support statuses, see the Tomcat support matrix on the official Apache Tomcat site.

Get Started

Ensure that you’re using Java 8 or greater on your local machine
Use Maven to generate a sample application

mvn archetype:generate “-DgroupId=example.demo” “-DartifactId=helloworld” “-DarchetypeArtifactId=maven-archetype-webapp” “-Dversion=1.0-SNAPSHOT”

Move into the project folder

cd helloworld

Configure the Maven plugin
mvn com.microsoft.azure:azure-webapp-maven-plugin:2.5.0:config

The previous command will start a wizard. Select your desired operating system, Java version, and App Service Plan type. In this case, we suggest Linux, Tomcat 10.0, Java 17, and P1v2.
Define value for OS [Linux]:
1: Windows
* 2: Linux
3: Docker
Enter your choice: 2
Define value for webContainer [Tomcat 8.5]:
1: Jbosseap 7
2: Tomcat 10.0
* 3: Tomcat 8.5
4: Tomcat 9.0
Define value for javaVersion [Java 8]:
* 1: Java 8
2: Java 11
3: Java 17
Enter your choice: 3
Define value for pricingTier [P1v2]:
1: B1
2: B2
3: B3
4: D1
5: EP1
6: EP2
7: EP3
8: F1
* 9: P1v2
10: P1v3
11: P2v2
12: P2v3
13: P3v2
14: P3v3
15: S1
16: S2
17: S3
18: Y1
Enter your choice: 9
Please confirm webapp properties
Subscription Id : xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
AppName : spring-boot-complete-1646864850428
ResourceGroup : spring-boot-complete-1646864850428-rg
Region : centralus
PricingTier : P1v2
OS : Linux
Java : Java 17
Web server stack: Java SE
Deploy to slot : false
Confirm (Y/N) [Y]: Y
[INFO] Saving configuration to pom.
[INFO] ————————————————————————
[INFO] BUILD SUCCESS
[INFO] ————————————————————————
[INFO] Total time: 02:12 min
[INFO] Finished at: 2022-03-09T14:28:27-08:00
[INFO] ————————————————————————

Build and deploy the web app using the Maven plugin. This will create the App Service Plan and Web App in a new resource group.
mvn package azure-webapp:deploy

Browse to your newly created web app! In the log output from the previous command there will be a URL to your web app. Follow that URL to your web app.
[INFO] Successfully deployed the artifact to https://helloworld-1646868651868.azurewebsites.net
[INFO] ————————————————————————
[INFO] BUILD SUCCESS
[INFO] ————————————————————————
[INFO] Total time: 01:06 min
[INFO] Finished at: 2022-03-09T15:47:24-08:00
[INFO] ————————————————————————

Prefer Gradle? See the Azure Plugins for Gradle! You can accomplish the same tasks shown in this article using the Azure Web App Plugin for Gradle. Version 1.3.0 supports Tomcat 10.0. Updates to the Azure integrations for VS Code and IntelliJ will be available soon.

Resources

Configure Java apps – Azure App Service | Microsoft Docs
Introduction to Java on Azure – Learn | Microsoft Docs

The post Java 17 and Tomcat 10.0 available on Azure App Service appeared first on Java at Microsoft.

Leave a Reply

Your email address will not be published.