Announcing Tomcat support in Azure Container Apps
Published Mar 03 2024 10:52 PM 2,053 Views

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



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="<path to your rep>/tomcat-external-configuration.tar.gz" 
	+ server.xml
	+ other configuration files


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


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.

Version history
Last update:
‎Mar 07 2024 09:56 PM
Updated by: