Skip to content

Latest commit

 

History

History
 
 

asset-manager

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. Open the GitHub Copilot app modernization extension.

  3. In the QUICKSTART view, click the Migrate to Azure button to trigger app assessment.

    Trigger Assessment

  4. Wait for the assessment to be completed and the report to be generated.

  5. Review the Assessment Report. Select the Issues tab to view the proposed solutions for the issues identified in the report.

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.

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 first analyze the project and generate a migration plan.

  4. After the plan is generated, Copilot Chat will stop with two generated files: plan.md and progress.md. If prompted, enter "Continue" or "Proceed" in the chat to confirm and execute the plan.

  5. When the code is migrated, the extension will prepare the CVE Validation and Fixing process. Click Allow to proceed.

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

In this section, you will use custom tasks to expose health endpoints for your applications instead of writing code yourself. The following steps demonstrate how to generate custom tasks based on external web links and proper prompts.

Note: Custom tasks are not supported for the IntelliJ IDEA plugin. If you are using IntelliJ IDEA, you can skip this section.

  1. Open the sidebar of GITHUB COPILOT APP MODERNIZATION. Click the + button in the Tasks view to create a custom task.

    Create Formula From Source Control

  2. In the opened tab, enter the Task Name and Task Prompt as shown below:

    • Task Name: Expose health endpoint via Spring Boot Actuator
    • Task Prompt: 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 the Add References button to add the Spring Boot Actuator official documentation as references.

    Health endpoint task

  4. In the popped-up quick-pick window, select External links. Then paste the following link: https://docs.spring.io/spring-boot/reference/actuator/endpoints.html. Click Save to create the task.

  5. Click the Run button to trigger the custom task.

  6. Follow the same steps as the predefined task to review and apply the changes.

  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. Open the sidebar of GITHUB COPILOT APP MODERNIZATION. In Tasks view, click the Run Task button of Java -> Containerization Tasks -> 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. Open the sidebar of GITHUB COPILOT APP MODERNIZATION. In Tasks view, click the Run Task button of Java -> Deployment Tasks -> 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.