Announcing Tomcat support in Azure Container Apps

This post has been republished via RSS; it originally appeared at: Microsoft Tech Community - Latest Blogs - .

Last month, we introduced the code-to-cloud build process for Java on Azure Container Apps. This process brings simplicity, consistency, and a better mechanism to govern IT policies when deploying Java apps to the cloud. We’re now enhancing the build process with two new features: Tomcat and build environment variable support.

 

Tomcat is one of the most popular and widely used Java web servers, providing a fast and reliable platform for running Java applications on the web. By supporting Tomcat in the cloud build process, we make it easy for developers to migrate their existing Java web applications to Azure Container Apps without changing any code or configuration.

 

Build environment variables are variables that affect how the build process is executed. You can use them to specify the versions of tools and frameworks, such as Maven or Tomcat, that you need for building an application. For example, by setting the BP_TOMCAT_VERSION variable, you can choose which version of Tomcat to use for the cloud build process. This way, you can ensure that the build process matches your development environment and avoids compatibility issues. You can also use build environment variables to pass custom parameters and settings to the build process, such as the Java version and files to include and exclude in the final image.

 

Let’s go through these two features using our Petclinic example. Unlike a Spring Boot executable jar, which is the default way to package Spring apps with an embedded Tomcat. The version of Petclinic we’re referring to in this blog post is based on JSP and Spring MVC, and it requires a stand-alone Java web server.  Normally, to deploy this type of project to Azure Container Apps, we’d first have to run Tomcat or another compatible Java web server in a separate container, and then run the Java web app on top of it. This step is no longer necessary because we’ve incorporated Tomcat into the build process. Azure Container Apps cloud build is now equipped to know we’re deploying a Java app that requires a web server and that packages Tomcat into the build image.

 

Sean_Li_2-1709534380582.png

The “build-env-var BP_TOMCAT_VERSION” is an optional parameter, and when left unset, Tomcat version 9 is applied to the build image when appropriate.

In this particular project, it’s necessary to override the Tomcat version to version 10, since it relies on Jakarta EE / Java SE libraries that are only compatible with Tomcat 10. As of this writing, version 8,9 and 10 are supported in the Java cloud build process. There are also instances where you may want to change the default configurations of Tomcat. For example, you can specify values in server.xml to change the default connection timeout, or add values in web.xml to specify information that is used to deploy and configure components of a web application. To make those changes, simply upload the configuration files in a git repository and set the URI in “BP_TOMCAT_EXT_CONF_URI”.

 

--build-env-var BP_TOMCAT_VERSION="10.*" BP_TOMCAT_EXT_CONF_URI="https://github.com/<path to your rep>/tomcat-external-configuration.tar.gz" 
tomcat-external-configuration.tar.gz
+conf	
	+web.xml
	+ server.xml
	+ other configuration files

 

After the deployment finishes, you can browse to the Petclinic app from the endpoint printed out in the output.

Sean_Li_3-1709534482876.png

You can try this example from our documentation. For more information, see Deploy a WAR file on Tomcat in Azure Container Apps. And please stay tuned for the next episode.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.