Events
Take the Microsoft Learn Challenge
Nov 19, 11 PM - Jan 10, 11 PM
Ignite Edition - Build skills in Microsoft Azure and earn a digital badge by January 10!
Register nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
In this article, you'll learn how to containerize Java web applications (running on Apache Tomcat) and migrate them to Azure App Service using the Azure Migrate: App Containerization tool. The containerization process doesn’t require access to your codebase and provides an easy way to containerize existing applications. The tool works by using the running state of the applications on a server to determine the application components and helps you package them in a container image. The containerized application can then be deployed on Azure App Service.
The Azure Migrate: App Containerization tool currently supports:
The Azure Migrate: App Containerization tool helps you to:
Note
While all applications won't benefit from a straight shift to containers without significant rearchitecting, some of the benefits of moving existing apps to containers without rewriting include:
In this tutorial, you'll learn how to:
Note
Tutorials show you the simplest deployment path for a scenario so that you can quickly set up a proof-of-concept. Tutorials use default options where possible, and don't show all possible settings and paths.
Before you begin this tutorial, you should:
Requirement | Details |
---|---|
Identify a machine to install the tool | A Windows machine to install and run the Azure Migrate: App Containerization tool. The Windows machine could be a server (Windows Server 2016 or later) or client (Windows 10) operating system, meaning that the tool can run on your desktop as well. The Windows machine running the tool should have network connectivity to the servers/virtual machines hosting the Java web applications to be containerized. Ensure that 6-GB space is available on the Windows machine running the Azure Migrate: App Containerization tool for storing application artifacts. The Windows machine should have internet access, directly or via a proxy. |
Application servers | Enable Secure Shell (SSH) connection on port 22 on the server(s) running the Java application(s) to be containerized. |
Java web application | The tool currently supports: - Applications running on Tomcat 8 or Tomcat 9. - Application servers on Ubuntu Linux 16.04/18.04/20.04, Debian 7/8, Red Hat Enterprise Linux 5/6/7. - Applications using Java 7 or Java 8. If you have version outside of this, find an image that supports your required versions and modify the dockerfile to replace image The tool currently doesn't support: - Application servers running multiple Tomcat instances |
If you don't have an Azure subscription, create a free account before you begin.
Once your subscription is set up, you'll need an Azure user account with:
If you just created a free Azure account, you're the owner of your subscription. If you're not the subscription owner, work with the owner to assign the permissions as follows:
In the Azure portal, search for "subscriptions", and under Services, select Subscriptions.
In the Subscriptions page, select the subscription in which you want to create an Azure Migrate project.
In the subscription, select Access control (IAM) > Check access.
In Check access, search for the relevant user account.
In Add a role assignment, click Add.
In Add role assignment, select the Owner role, and select the account (azmigrateuser in our example). Click Save.
Your Azure account also needs permissions to register Microsoft Entra apps. 8. In the Azure portal, navigate to Microsoft Entra ID > Users > User Settings. 9. In User settings, verify if Microsoft Entra users can register applications (set to Yes by default).
Important
Microsoft recommends that you use roles with the fewest permissions. This helps improve security for your organization. Global Administrator is a highly privileged role that should be limited to emergency scenarios when you can't use an existing role.
Download the Azure Migrate: App Containerization installer on a Windows machine.
Launch PowerShell in administrator mode and change the PowerShell directory to the folder containing the installer.
Run the installation script using the command
.\AppContainerizationInstaller.ps1
Note
For Windows Server 2022, edit line 135 and remove PowerShell-ISE
from the feature list, as it's no longer supported.
Open a browser on any machine that can connect to the Windows machine running the App Containerization tool and open the tool URL: https://machine name or IP address: 44369.
Alternately, you can open the app from the desktop by selecting the app shortcut.
If you see a warning stating that your connection isn’t private, click Advanced and choose to proceed to the website. This warning appears as the web interface uses a self-signed TLS/SSL certificate.
At the sign-in screen, use the local administrator account on the machine to sign in.
Select Java web apps on Tomcat as the type of application you want to containerize.
To specify target Azure service, select Containers on Azure App Service.
Click Sign in to log in to your Azure account.
You'll need a device code to authenticate with Azure. Clicking Sign in will open a modal with the device code.
Click Copy code & sign in to copy the device code and open an Azure sign-in prompt in a new browser tab. If it doesn't appear, make sure you've disabled the pop-up blocker in the browser.
On the new tab, paste the device code and complete sign in using your Azure account credentials. You can close the browser tab after sign in is complete and return to the App Containerization tool's web interface.
Select the Azure tenant that you want to use.
Specify the Azure subscription that you want to use.
The App Containerization helper tool connects remotely to the application servers using the provided credentials and attempts to discover Java web applications (running on Apache Tomcat) hosted on the application servers.
Specify the IP address/FQDN and the credentials of the server running the Java web application that should be used to remotely connect to the server for application discovery.
Click Validate to verify that the application server is reachable from the machine running the tool and that the credentials are valid. Upon successful validation, the status column will show the status as Mapped.
Click Continue to start application discovery on the selected application servers.
Upon successful completion of application discovery, you can select the list of applications to containerize.
Use the checkbox to select the applications to containerize.
Specify container name: Specify a name for the target container for each selected application. The container name should be specified as <name:tag> where the tag is used for container image. For example, you can specify the target container name as appname:v1.
Parameterizing the configuration makes it available as a deployment time parameter. This allows you to configure this setting while deploying the application as opposed to having it hard-coded to a specific value in the container image. For example, this option is useful for parameters like database connection strings.
Click App configurations to review detected configurations.
Select the checkbox to parameterize the detected application configurations.
Click Apply after selecting the configurations to parameterize.
You can add other folders that your application uses. Specify if they should be part of the container image or are to be externalized to persistent storage through Azure file share. Using external persistent storage works great for stateful applications that store state outside the container or have other static content stored on the file system.
Click Edit under App Folders to review the detected application folders. The detected application folders have been identified as mandatory artifacts needed by the application and will be copied into the container image.
Click Add folders and specify the folder paths to be added.
To add multiple folders to the same volume, provide comma (,
) separated values.
Select Azure file share as the storage option if you want the folders to be stored outside the container on persistent storage.
Click Save after reviewing the application folders.
Click Continue to proceed to the container image build phase.
Select Azure Container Registry: Use the dropdown to select an Azure Container Registry that will be used to build and store the container images for the apps. You can use an existing Azure Container Registry or choose to create a new one using the Create new registry option.
Note
Only Azure container registries with admin user enabled are displayed. The admin account is currently required for deploying an image from an Azure container registry to Azure App Service. Learn more.
Review the Dockerfile: The Dockerfile needed to build the container images for each selected application are generated at the beginning of the build step. Click Review to review the Dockerfile. You can also add any necessary customizations to the Dockerfile in the review step and save the changes before starting the build process.
Configure Application Insights: You can enable monitoring for your Java apps running on App Service without instrumenting your code. The tool will install the Java standalone agent as part of the container image. Once configured during deployment, the Java agent will automatically collect a multitude of requests, dependencies, logs, and metrics for your application that can be used for monitoring with Application Insights. This option is enabled by default for all Java applications.
Trigger build process: Select the applications to build images for and click Build. Clicking Build will start the container image build for each application. The tool keeps monitoring the build status continuously and will let you proceed to the next step upon successful completion of the build.
Track build status: You can also monitor progress of the build step by clicking the Build in Progress link under the Build status column. The link takes a couple of minutes to be active after you've triggered the build process.
Once the build is completed, click Continue to specify the deployment settings.
Once the container image is built, the next step is to deploy the application as a container on Azure App Service.
Select the Azure App Service plan: Specify the Azure App Service plan that the application should use.
Specify secret store and monitoring workspace: If you had opted to parameterize application configurations, then specify the secret store to be used for the application. You can choose Azure Key Vault or App Service application settings for managing your application secrets. Learn more.
Specify Azure file share: If you had added more directories/folders and selected the Azure file share option for persistent storage, then specify the Azure file share to be used by Azure Migrate: App Containerization tool during the deployment process. The tool will copy over the application directories/folders that are configured for Azure Files and mount them on the application container during deployment.
Application deployment configuration: Once you've completed the steps above, you'll need to specify the deployment configuration for the application. Click Configure to customize the deployment for the application. In the configure step you can provide the following customizations:
Deploy the application: Once the deployment configuration for the application is saved, the tool will generate the Kubernetes deployment YAML for the application.
Click Review to review the deployment configuration for the applications.
Select the application to deploy.
Click Deploy to start deployments for the selected applications
Once the application is deployed, you can click the Deployment status column to track the resources that were deployed for the application.
To troubleshoot any issues with the tool, you can look at the log files on the Windows machine running the App Containerization tool. Tool log files are available in the C:\ProgramData\Microsoft Azure Migrate App Containerization\Logs folder.
Events
Take the Microsoft Learn Challenge
Nov 19, 11 PM - Jan 10, 11 PM
Ignite Edition - Build skills in Microsoft Azure and earn a digital badge by January 10!
Register nowTraining
Module
Containerize and deploy a Java app to Azure - Training
Containerize a Java app, push the container image to Azure Container Registry, and then deploy to Azure Kubernetes Service.
Certification
Microsoft Certified: Azure Developer Associate - Certifications
Build end-to-end solutions in Microsoft Azure to create Azure Functions, implement and manage web apps, develop solutions utilizing Azure storage, and more.