Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Asset Manager

This document serves as a comprehensive workshop guide that will walk you through the process of migrating a Java application to Azure using GitHub Copilot app modernization. The workshop covers assessment, Java/framework upgrades, migration to Azure services, containerization, and deployment.

What the modernization Process Will Do: The modernization will transform your application from the outdated technologies to a modern Azure-native solution. This includes upgrading from Java 8 to Java 21, migrating from Spring Boot 2.x to 3.x, replacing AWS S3 with Azure Blob Storage, switching from RabbitMQ to Azure Service Bus, migrating to Azure Database for PostgreSQL, implementing managed identity authentication, adding health checks, containerizing the applications, and preparing them for cloud deployment with proper monitoring.

Table of Contents

Overview

The main branch of the asset-manager project is the original state before being migrated to Azure services. It is organized as follows:

  • AWS S3 for image storage, using password-based authentication (access key/secret key)
  • RabbitMQ for message queuing, using password-based authentication
  • PostgreSQL database for metadata storage, using password-based authentication

In this workshop, you will use the GitHub Copilot app modernization extension to assess, upgrade, migrate, and finally deploy the project to Azure.

Time Estimates: The complete workshop takes approximately 2 hours to complete. Here's the breakdown for each major step:

  • Assess Your Java Application: ~5 minutes
  • Upgrade Runtime & Frameworks: ~10 minutes
  • Migrate to Azure Database for PostgreSQL: ~15 minutes
  • Migrate to Azure Blob Storage: ~15 minutes
  • Migrate to Azure Service Bus: ~15 minutes
  • Expose Health Endpoints: ~15 minutes
  • Containerize Applications: ~5 minutes
  • Deploy to Azure: ~40 minutes

There are 3 branches we have prepared for you in case you have any problems with any steps in this workshop:

Current Architecture

flowchart TD

%% Applications
WebApp[Web Application]
Worker[Worker Service]

%% Storage Components
S3[(AWS S3)]
LocalFS[("Local File System<br/>dev only")]

%% Message Broker
RabbitMQ(RabbitMQ)

%% Database
PostgreSQL[(PostgreSQL)]

%% Queues
Queue[image-processing queue]
RetryQueue[image-processing.retry queue]

%% User
User([User])

%% User Flow
User -->|Upload Image| WebApp
User -->|View Images| WebApp

%% Web App Flows
WebApp -->|Store Original Image| S3
WebApp -->|Store Original Image| LocalFS
WebApp -->|Send Processing Message| RabbitMQ
WebApp -->|Store Metadata| PostgreSQL
WebApp -->|Retrieve Images| S3
WebApp -->|Retrieve Images| LocalFS
WebApp -->|Retrieve Metadata| PostgreSQL

%% RabbitMQ Flow
RabbitMQ -->|Push Message| Queue
Queue -->|Processing Failed| RetryQueue
RetryQueue -->|After 1 min delay| Queue
Queue -->|Consume Message| Worker

%% Worker Flow
Worker -->|Download Original| S3
Worker -->|Download Original| LocalFS
Worker -->|Upload Thumbnail| S3
Worker -->|Upload Thumbnail| LocalFS
Worker -->|Store Metadata| PostgreSQL
Worker -->|Retrieve Metadata| PostgreSQL

%% Styling
classDef app fill:#90caf9,stroke:#0d47a1,color:#0d47a1
classDef storage fill:#a5d6a7,stroke:#1b5e20,color:#1b5e20
classDef broker fill:#ffcc80,stroke:#e65100,color:#e65100
classDef db fill:#ce93d8,stroke:#4a148c,color:#4a148c
classDef queue fill:#fff59d,stroke:#f57f17,color:#f57f17
classDef user fill:#ef9a9a,stroke:#b71c1c,color:#b71c1c

class WebApp,Worker app
class S3,LocalFS storage
class RabbitMQ broker
class PostgreSQL db
class Queue,RetryQueue queue
class User user
Loading

Password-based authentication

Run Locally

Clone the repository and open the asset-manager folder to run the current project locally:

git clone https://github.com/Azure-Samples/java-migration-copilot-samples.git
cd java-migration-copilot-samples/asset-manager

Prerequisites:

  • JDK 8: Required for running the initial application locally.
  • Maven 3.6.0+: Required to build the application locally.
  • Docker: Required for running the application locally.

Run the following commands to start the apps locally. This will:

  • Use the local file system instead of S3 to store images
  • Launch RabbitMQ and PostgreSQL using Docker

Windows:

scripts\startapp.cmd

Linux:

scripts/startapp.sh

To stop, run stopapp.cmd or stopapp.sh in the scripts directory.

App Modernization

The following sections guide you through the process of modernizing the sample Java application asset-manager to Azure using GitHub Copilot app modernization.

Prerequisites:

Note: If you're using Gradle, only the Gradle wrapper version 5+ is supported. The Kotlin Domain Specific Language (DSL) isn't supported.

The function My Tasks isn't supported yet for IntelliJ IDEA.

Install GitHub Copilot app modernization

In VSCode, open the Extensions view from the Activity Bar, search for the GitHub Copilot app modernization extension in the marketplace. Click the Install button for the extension. After installation completes, you should see a notification in the bottom-right corner of VSCode confirming success.

Alternative: IntelliJ IDEA Alternatively, you can use IntelliJ IDEA. Open File > Settings (or IntelliJ IDEA > Preferences on macOS), navigate to Plugins > Marketplace, search for GitHub Copilot app modernization, and click Install. Restart IntelliJ IDEA if prompted.

Assess Your Java Application

The first step is to assess the sample Java application asset-manager. The assessment provides insights into the application's readiness for migration to Azure.

  1. Open VS Code with all the prerequisites installed for the asset manager by changing the directory to the asset-manager directory and running code . in that directory.

  2. In the Activity sidebar, open the GitHub Copilot app modernization extension pane.

  3. In the QUICKSTART section, click Start Assessment to trigger the app assessment.

    Trigger Assessment

  4. Wait for the assessment to be completed. This step could take several minutes.

  5. Upon completion, an Assessment Report tab opens. This report provides a categorized view of cloud readiness issues and recommended solutions. Select the Issues tab to view proposed solutions and proceed with migration steps.

Upgrade Runtime & Frameworks

  1. In the Java Upgrade table at the bottom of the Issues tab, click the Run Task button of the first entry Java Version Upgrade.

    Java Upgrade

  2. After clicking the Run Task button, the Copilot Chat panel will open with Agent Mode. The agent will check out a new branch and start upgrading the JDK version and Spring/Spring Boot framework. Click Allow for any requests from the agent.

Note: The upgrading tool also supports upgrading to JDK 25 (the latest LTS version). To do this, click on the generated chat message, edit the target Java version to 25, and then click Send to apply the change.

Migrate to Azure Database for PostgreSQL Flexible Server using Predefined Tasks

Then you can migrate the sample Java application asset-manager to Azure.

Note: We've set up a workshop/java-upgrade branch where the Java upgrade has already been completed. Feel free to switch to this branch if you'd like to skip ahead and continue with the rest of the workshop.

  1. For this workshop, select Migrate to Azure Database for PostgreSQL (Spring) in the Solution list, then click Run Task.

    Confirm Solution

  2. After clicking the Run Task button in the Assessment Report, the Copilot Chat panel will open with Agent Mode.

  3. The Copilot Agent will analyze the project, generate and open plan.md and progress.md, then automatically proceed with the migration process.

  4. The agent checks the version control system status and checks out a new branch for migration, then performs the code changes. Click Allow for any tool call requests from the agent.

  5. When the code migration is complete, the agent will automatically run a validation and fix iteration loop which includes:

    • CVE Validation: Detects Common Vulnerabilities and Exposures in current dependencies and fixes them.
    • Build Validation: Attempts to resolve any build errors.
    • Consistency Validation: Analyzes the code for functional consistency.
    • Test Validation: Runs unit tests and automatically fixes any failures.
    • Completeness Validation: Catches migration items missed in the initial code migration and fixes them.
  6. After all validations complete, the agent generates a summary.md as the final step.

  7. Review the proposed code changes and click Keep to apply them.

Migrate to Azure Blob Storage using Predefined Tasks

  1. Click the Run Task in the Assessment Report, on the right of the row Storage Migration (AWS S3) - Migrate from AWS S3 to Azure Blob Storage.
  2. The following steps are the same as the above PostgreSQL server migration.

Migrate to Azure Service Bus using Predefined Tasks

  1. Click the Run Task in the Assessment Report, on the right of the row Messaging Service Migration (Spring AMQP RabbitMQ) - Migrate from RabbitMQ(AMQP) to Azure Service Bus.
  2. The following steps are the same as the above PostgreSQL server migration.

Expose health endpoints using Custom Skills

In this section, you will use custom skills to expose health endpoints for your applications instead of writing code yourself. The following steps demonstrate how to create a custom skill with references and proper prompts.

Note: Custom skills (My Skills) are not supported for the IntelliJ IDEA plugin. If you are using IntelliJ IDEA, you can skip this section.

  1. In the Activity sidebar, open the GitHub Copilot app modernization extension pane. Hover over the TASKS section, and then select Create a Custom Skill.

    Create Custom Skill

  2. A Create a Skill form opens with the following fields. Fill them in as shown below:

    • Skill Name: expose-health-endpoint
    • Skill Description: This skill helps add Spring Boot Actuator health endpoints for Azure Container Apps deployment readiness.
    • Skill Content: You are a Spring Boot developer assistant, follow the Spring Boot Actuator documentation to add basic health endpoints for Azure Container Apps deployment.
  3. Click Add Resources to add the Spring Boot Actuator official documentation as a resource. Paste the following link: https://docs.spring.io/spring-boot/reference/actuator/endpoints.html.

    Create a Skill form

  4. Click Save to create the skill. Your custom skill now appears in the TASKS > My Skills section.

  5. Click Run to execute it.

  6. The Copilot chat window opens in Agent Mode and automatically generates the migration plan, checks out a new branch, performs code changes, and runs the validation and fix iteration loop. Click Allow for any tool call requests from the agent.

  7. Review the proposed code changes and click Keep to apply them.

Containerize Applications

Now that you have successfully migrated your Java application to use Azure services, the next step is to prepare it for cloud deployment by containerizing both the web and worker modules. In this section, you will use Containerization Tasks to containerize your migrated applications.

Note: If you encounter any issues with the previous migration step, you can directly proceed with the containerization step using the workshop/expected branch.

  1. In the Activity sidebar, open the GitHub Copilot app modernization extension pane. In the TASKS section, expand Common Tasks > Containerize Tasks and click the run button for Containerize Application.

    Run Containerize Application task

  2. A predefined prompt will be populated in the Copilot Chat panel with Agent Mode. Copilot Agent will start to analyze the workspace and to create a containerization-plan.copiotmd with the containerization plan.

    Containerization prompt and plan

  3. View the plan and collaborate with Copilot Agent as it follows the Execution Steps in the plan by clicking Continue/Allow in pop-up chat notifications to run commands. Some of the execution steps leverage agentic tools of Container Assist.

  4. Copilot Agent will help generate Dockerfile, build Docker images and fix build errors if there are any. Click Keep to apply the generated code.

Deploy to Azure

At this point, you have successfully migrated the sample Java application asset-manager to Azure Database for PostgreSQL (Spring), Azure Blob Storage, and Azure Service Bus, and exposed health endpoints via Spring Boot Actuator. Now, you can start the deployment to Azure.

Note: If you encounter any issues with the previous migration step, you can directly proceed with the deployment step using the workshop/expected branch.

  1. In the Activity sidebar, open the GitHub Copilot app modernization extension pane. In the TASKS section, expand Common Tasks > Deployment Tasks. Click the run button for Provision Infrastructure and Deploy to Azure.

    Run Deployment task

  2. A predefined prompt will be populated in the Copilot Chat panel with Agent Mode. The default hosting Azure service is Azure Container Apps.To change the hosting service to Azure Kubernetes Service (AKS), click on the prompt in the Copilot Chat panel and edit the last sentence of the prompt to Hosting service: AKS.

    Deployment prompt

  3. Click **Continue/Allow if pop-up notifications to let Copilot Agent analyze the project and create a deployment plan in plan.copilotmd with Azure resources architecture, recommended Azure resources for project and security configurations, and execution steps for deployment.

  4. View the architecture diagram, resource configurations, and execution steps in the plan. Click Keep to save the plan and type in Execute the plan to start the deployment.

    Deployment execute

  5. When prompted, click Continue/Allow in chat notifications or type y/yes in terminal as Copilot Agent follows the plan and leverages agent tools to create and run provisioning and deployment scripts, fix potential errors, and finish the deployment. You can also check the deployment status in progress.copilotmd. DO NOT interrupt when provisioning or deployment scripts are running.

    Deployment progress

Note: If you encounter any issues with the deployment step, you can refer to the expected Copilot-generated deployment scripts in /.azure folder of the workshop/deployment-expected branch to compare your deployment scripts and troubleshoot the problems.

Clean up

When no longer needed, you can delete all related resources using the following scripts.

Windows:

scripts\cleanup-azure-resources.cmd -ResourceGroupName <your resource group name>

Linux:

scripts/cleanup-azure-resources.sh -ResourceGroupName <your resource group name>

If you deploy the app using GitHub Codespaces, delete the Codespaces environment by navigating to your forked repository in GitHub and selecting Code > Codespaces > Delete.