Containerize and Deploy Java Applications

Microsoft Developer · Intermediate ·☁️ DevOps & Cloud ·4mo ago

Key Takeaways

The video demonstrates containerizing and deploying Java applications using Docker and Azure Container Apps, with GitHub Copilot app modernization extension.

Full Transcript

Hello everyone. Welcome back to our app modernization series. Today we're talking about containerization and deploying to Azure and how co-pilot is able to help assist you with both of these tasks. We'll start back in VS Code with our ski shop application already upgraded to Java 21 and building successfully. This is an important prerequisite. Containerization or the containerization assist usually works best once an application is already running on a modern supported Java runtime. However, I did just for fun containerize this application before modernizing or upgrading and co-pilot did make some changes to the application and it was eventually able to containerize. This is the neat part about co-pilot. It can be proactive and take steps as needed to reach the end result, of course, with your permission. So at this point the app is functionally complete and ready to be packaged and deployed. So let's open up the app modernization extension. And on the left sidebar over here, we can see the section for tasks. And these are all pre-built tasks that are provided by Microsoft to cover some of the most common modernization scenarios. You don't have to script these workflows yourself. I'll explain I'll expand common tasks and in common tasks we can see containerization task. So we'll select that. And when I click on run task, co-pilot takes over and starts to understand the application. Before making any changes, co-pilot does exactly what a human engineer would do first. It analyzes the project, it scans the repository, and understands the structure, reviews the build systems, runtime configurations, and then creates a containerization plan. In addition, you can see eventually we should have a checklist show up at the bottom which shows us all the steps that Co-pilot will take. Sometimes it also shows up in the plan, so we'll wait for Co-pilot to finish thinking and present us with our upgrade plan so we can review all the steps that Co-pilot plans to take on our containerization journey. All right, so here we can see our to-dos. We have seven steps analyzing the application configuration dependencies, creating the containerization plan document, checking the prerequisites, reviewing configuration readiness, generating Docker files, and then building the Docker image. So, we can see it's asking for some permission. It wants to run a bash command. For the purpose of this demo, I will say allow all commands. Of course, I say this with a little bit of hesitancy. Do it at your own risk. You know, in production environments there's always a lot more weight on your shoulders. So, it is good to follow that human in the loop cycle and not rely too much on AI. So, we can see the plan has been created over here and it's in a nice little markdown file. So, this list this file lists exactly what services will be containerized and what steps Co-pilot intends to execute. Once the containerization plan is ready, Co-pilot opens it as a markdown file. This file lists exactly which services will be containerized and which steps Co-pilot intends to execute. If needed, you can edit this plan to fit your project's requirements. In this case, I'll say the defaults look good, so I'll continue to allow Co-pilot to run the commands. And real quick we can take a look at everything that's in this modernization plan. We have we see the configuration requirements, the execution steps. It's a procedure. Copilot follows the procedure, which is great for us because it's easy to understand. And in this case, because I had allowed Copilot to continue with auto-approval, it is continuing automatically. And in the time we reviewed in the containerization plan, we can see it's almost built the Docker image. And once it builds the image, we will see it validate the results and present us with a containerization summary. So, we'll wait a moment as it finishes up, and we'll be right back. Okay. So, we can see that containerization is complete. It is giving us a containerization summary of everything that Copilot did. It says successfully containerized. Here's what was accomplished. Created the Docker files. It did some code changes. The Docker image that was built. The size of the Docker image. Some key features. And it says to run with a PostgreSQL database, we can use this command. However, in this case, using the PostgreSQL database likely won't work because we do want to test it locally first. So, I'm going to ask Copilot to use our built-in H2 database. So, I'll tell it I want to test the application locally using my H2 database. Can you make the necessary changes? Enter. And we'll allow Copilot to make those changes. So, that way we can test locally before we deploy to Azure. At this point, the application is fully containerized, so we can see the pop-up which says the application is running on port 8080. Let's go ahead and open it, and we see it is up and running our ski shop. We can review all products. We can see all these products. We can see there's a slight bug. It's using the wrong currency, uh which is to be expected. This is a demo that was created by my colleague Yoshio who's in Japan, but nothing that Copilot can't easily fix. For this purpose, we won't worry too much about it. It's a pretty small issue. I'll take care of it real quick, and now let's jump back to VS Code. And get started with deploying to Azure. So, once again, I'll go back to the tasks section here on the left, and I'll explain I'll expand the deployment tasks this time, and we can see there's four different pre-built tasks, which is deploy to existing Azure infrastructure, provision infrastructure and deploy to Azure, generate infrastructure as code and provision, generate CICD pipelines to deploy to Azure. So, in this case, I will select provision infrastructure and deploy to Azure since we're starting from scratch. And we can see Copilot is scanning the project and taking over to figure out what needs to be done. So, we can see Copilot follows the same pattern as before. It will scan the project. It will generate a deployment plan, and finally, it will ask for approval before executing anything. So, we can see now let me create a comprehensive deployment plan. I'll click on allow. This time I have not selected the auto approval just yet because I do want it to pause for the deployment summary. So, we'll give it a moment as it thinks, and we should have a deployment plan in just a few moments. So, we can see that it has created plan the deployment plan over here. So, the goal of the deployment plan deployment plan is to deploy our ski shop application using the Azure developer CLI with Bicep used to define infrastructure as code. By default, it will be targeting Azure Container Apps. You can change it to AKS or something else if you would like. We can see everything that the plan includes, which includes a architecture diagram, includes the architecture relationships, recommended Azure resources that it will provision, dependencies, recommended supporting services, the security configurations, execution steps, which are very well laid out, and then progress tracking tools it will use. So, once again, you can make any changes as necessary, but in this case, it looks good. We'll open up Copilot once again. We will allow it to continue, and it will execute the deployment step by step, generating the Bicep YAML files, validating the infrastructure, provisioning Azure resources, deploying the container image, and finally generating a final deployment summary. Copilot handles the repetitive, error-prone error-prone work automatically, while keeping me in the driver's seat of the decisions. So, I won't make you wait through this whole process. Like we talked about earlier, it is an iterative cycle that can take some time, but you are free to go up and take a snack break. So, let's take a break, and I will be back once the application is deployed. Okay, we are back. So, the application deployed. We I have the Azure portal opened up. We can see all the different resources that were created and deployed. We see our container app. And we can click on the application URL to take a look. I did ask Copilot in between to fix the currency issue. Uh I don't think it actually converted it yet to dollars. It just changed the symbol, but that's okay. It's an easy fix. It's a database uh it's just a database information thing that we need to take care of. But, in terms of the application working, it is it seems to be you know, doing everything that it should. You can add things to cart, proceed to checkout. We have our checkout page. We can log in, sign up, so on and so forth. So, in this walk-through, we took our upgraded and modernized Java 21 application, containerized it using Build and Tasks, and GitHub Copilot validated it locally, and deployed it to Azure, all using the same agent-driven workflow. Copilot doesn't replace developer judgment, but it dramatically accelerates the mechanical steps that normally slow down teams. In the next episode, we'll go deeper into how we can use the Copilot CLI to scale up the modernization process with batch processing as well as CI/CD pipelines. Okay. We are almost done. We will see you in the next episode.

Original Description

Your Java app is upgraded and running on Java 21 — now what? In this episode, watch how the GitHub Copilot app modernization extension containerizes a Java application with Docker, validates it locally, and then provisions Azure infrastructure and deploys to Azure Container Apps — all using built-in tasks and an agent-driven workflow. In this episode, you'll learn: → How to use the built-in containerization task to generate Dockerfiles and build images automatically → How Copilot follows the same pattern every time — analyze, plan, get approval, execute → How to review and edit the containerization plan before Copilot executes → How to test the containerized app locally before deploying (switching to H2 for local testing) → How to use the "Provision Infrastructure and Deploy to Azure" task to generate Bicep/IaC and deploy to Azure Container Apps → How Copilot generates architecture diagrams, security configurations, and execution steps in the deployment plan 📺 This is Episode 6 of the Modernize Java Apps with AI series — a 9-part, hands-on guide to upgrading legacy Java applications using GitHub Copilot. 🔗 Series playlist: https://www.youtube.com/playlist?list=PLlrxD0HtieHhaBJWlcxGd-kTDikSD4xyD 🔗 GitHub Copilot Modernization extension: https://aka.ms/GHCPMod-Java 🔗 Azure Container Apps: https://aka.ms/containerapps 👤 Presented by Ayan Gupta, Java & AI Advocate, Microsoft Java #GitHubCopilot #Docker #Containerization #AzureContainerApps #Bicep #InfrastructureAsCode #JavaModernization #Azure #CloudDeployment
Sign in to unlock AI tutor explanation · ⚡30

This video teaches how to containerize and deploy Java applications using Docker and Azure Container Apps, with GitHub Copilot app modernization extension, and why it matters for efficient and scalable app deployment.

Key Takeaways
  1. Install Docker and GitHub Copilot extension
  2. Containerize Java application with Docker
  3. Validate container locally
  4. Provision Azure infrastructure
  5. Deploy to Azure Container Apps
💡 Using GitHub Copilot app modernization extension simplifies the process of containerizing and deploying Java applications to Azure Container Apps.

Related Reads

Up next
Hostinger Web Hosting Review 2026: Features, Pros & Cons 🔥
DroidCrunch
Watch →