Skip to content

Azure-Samples/PhotoAlbum-Java-Lite

Repository files navigation

Photo Album Application - Migration Workshop

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, database migration from Oracle to PostgreSQL, and deployment to Azure.

What the Migration Process Will Do: The migration will transform your application from using Oracle Database to a modern Azure-native solution. This includes migrating from Oracle Database to Azure Database for PostgreSQL Flexible Server with managed identity authentication, and deploying it to Azure with proper monitoring and health checks.

Table of Contents

Overview

The Photo Album application is a Spring Boot web application that allows users to:

  • Upload photos via drag-and-drop or file selection
  • View photos in a responsive gallery
  • View photo details with metadata
  • Navigate between photos
  • Delete photos

Original State (Before Migration):

  • Oracle Database 21c Express Edition for photo storage
  • Photos stored as BLOBs in Oracle Database
  • Password-based authentication
  • Running in Docker containers locally

After Migration:

  • Azure Database for PostgreSQL Flexible Server
  • Managed Identity passwordless authentication
  • Deployed to Azure Container Apps

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

  • Assess Your Java Application: ~5 minutes
  • Migrate from Oracle to PostgreSQL: ~15 minutes
  • Deploy to Azure: ~20 minutes

Prerequisites

Before starting this workshop, ensure you have:

Required Software

  • Operating System: Windows, macOS, or Linux
  • Java Development Kit (JDK): JDK 21 or higher
  • Maven: 3.8.0 or higher
  • Git: For version control
    • Download from Git

IDE and Extensions

Azure Requirements

  • Azure Account: Active Azure subscription
  • Azure CLI: Latest version
    • Download from Azure CLI
    • After installation, login and set your subscription:
      az login
      az account set --subscription "<your-subscription-id>"
    • Install the Container Apps extension:
      az extension add --name containerapp

Configuration

  • Ensure chat.extensionTools.enabled is set to true in VS Code settings

  • In the Visual Studio Code settings, make sure this setting is enabled (it might be controlled by your organization)

  • Access to public Maven Central repository for Maven-based projects

  • Git-managed Java project using Maven

  • Ensure the following tools are selected:

    • Built-in
    • GitHub Copilot app modernization Deploy
    • GitHub Copilot app modernization
    • GitHub Copilot modernization - upgrade for Java

    Tools Selection

Running Locally (Optional, Pre-Migration)

This section is optional. Before starting the migration, you can run the original Oracle-based application locally to understand how it works.

Required: Docker Desktop (Latest version)

  1. Clone the repository (if not already done):

    git clone https://github.com/Azure-Samples/PhotoAlbum-Java-Lite.git
    cd PhotoAlbum-Java-Lite
  2. Start the application:

    docker-compose up --build -d

    This will:

    • Start Oracle Database 21c Express Edition container
    • Build and start the Photo Album application container
    • Automatically create the database schema
  3. Wait for services to start (~2-3 minutes for Oracle DB initialization on first run)

  4. Access the application:

  5. Stop the application:

    docker-compose down

    To remove data volumes as well:

    docker-compose down -v

Workshop Steps

Step 1: Assess Your Java Application

The first step is to assess the Photo Album application to identify migration opportunities and potential issues.

1.1 Open the Project

  1. Clone or open the Photo Album project in Visual Studio Code:
git clone https://github.com/Azure-Samples/PhotoAlbum-Java-Lite.git
cd PhotoAlbum-Java-Lite
code .

1.2 Install GitHub Copilot App Modernization Extension

In VS Code, 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 VS Code confirming success.

1.3 Run Assessment

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

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

    Trigger Assessment

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

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

1.4 Review Assessment Report

The Assessment Report provides:

  • Application Information: Summary of detected technologies and frameworks
  • Issues: Categorized list of migration opportunities
    • Database Migration: Oracle Database → Azure Database for PostgreSQL
    • Security: Current password-based authentication
  • Recommended Solutions: Predefined migration tasks for each issue

Look for the following in your report:

  1. Database Migration (Oracle Database)

    • Detected: Oracle Database 21c
    • Recommendation: Migrate to Azure Database for PostgreSQL Flexible Server
    • Action: Run Task button available

    Assessment Report

Step 2: Migrate from Oracle to PostgreSQL

Before running the migration task in Copilot Chat, make sure the chat is configured to use your preferred LLM model, to choose the model:

  1. Open Copilot Chat in Agent mode.

  2. Select the custom agent modernize-azure-java from the agent picker.

  3. Select the a model from the model picker, e.g., GPT-5.3-Codex.

    Custom Agent

Now that you've assessed the application, let's begin the database migration from Oracle to Azure Database for PostgreSQL.

  1. In the Assessment Report, locate the Database Migration (Oracle) issue

  2. Click the Run Task button next to Migrate to Azure Database for PostgreSQL (Spring)

  3. The Copilot Chat panel opens in Agent Mode with a pre-populated migration prompt

    Run Task Prompt

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

  5. The agent checks the version control system status and checks out a new branch for migration, then performs the code changes. When prompted to confirm an action, click Allow for tool call requests. Tip: To minimize disruption, open the dropdown menu and select Allow all commands in this session.

  6. 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.
  7. After all validations complete, the agent generates a summary.md as the final step.

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

Step 3: Deploy to Azure

At this point, you have successfully migrated the database to PostgreSQL. Now, you can deploy the application to Azure. You can choose one of the two options:

  • Provision New Infrastructure and Deploy
  • Deploy to Existing Azure Resources

3.1 Provision New Infrastructure and Deploy

Follow this section when you don't have any prepared Azure resources and let the Copilot Agent help provision the necessary infrastructure and deploy the application.

  1. Switch to the default agent for deployment:

    • Open Copilot Chat
    • Select the agent from the agent picker (not modernize-azure-java)
    • Be sure to enable the "GitHub Copilot app modernization Deploy" in the tool picker
  2. 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

  3. The Copilot Chat panel opens in Agent Mode and will be populated with a predefined prompt.

    Deployment Prompt

  4. Select Azure Container Apps in pop-up question box. Provide information as requested. Click Continue/Allow in 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.

    Deployment questions

  5. View the architecture diagram, resource configurations, and execution steps in the plan. Copilot will automatically execute the deployment steps.

  6. When prompted, click Continue/Allow in chat notifications 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.

    Deployment progress

  7. Clean up new provisioned resources after the workshop. Find the resource group name used for deployment in the plan.copilotmd, progress.copilotmd, or summary.copilotmd file. Navigate to the resource group in the Azure Portal, review the resources, and delete the resource group to clean up all resources created during the deployment. You can also use Azure CLI to list the resources and delete the resource group:

    az resource list --resource-group <your-resource-group-name>
    az group delete --name <your-resource-group-name> --yes --no-wait

3.2 Deploy to Existing Azure Resources

Follow this section if you already have the necessary Azure resources provisioned and just want to deploy the application to those existing resources.

  1. Switch to the default agent for deployment:

    • Open Copilot Chat
    • Select the agent from the agent picker (not modernize-azure-java)
    • Be sure to enable the "GitHub Copilot app modernization Deploy" in the tool picker
  2. Check if you have the necessary Azure resources in a resource group for this project. Refer to azure-setup.ps1 to set up the required resources, which include:

    • Azure Container Apps (with Azure Container Apps Environment and Azure Log Analytics Workspace as dependencies)
    • Azure Database for PostgreSQL Flexible Server with a database created
    • Azure Container Registry
    • Azure Key Vault (to securely store database credentials and other secrets)
    • Azure User-assigned Managed Identity (for secure access to ACR and Key Vault)
  3. 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 Deploy to Existing Azure Infrastructure.

    Run Deployment to existing task

  4. The Copilot Chat panel opens in Agent Mode and will be populated with a predefined prompt. Provide the necessary information such as Azure subscription, resource group name in pop-up notifications or use direct prompt, e.g. The resource group name is <resource-group-name>. Click Continue/Allow to let Copilot Agent take some time to analyze the project and validate the existing infrastructure.

    Deployment to existing prompt

  5. Copilot will then create a deployment plan in plan.copilotmd with execution steps for deployment. Copilot will automatically start to execute the deployment steps. Click Continue/Allow to let Copilot Agent proceed. Check the deployment progress in progress.copilotmd.

    Deployment to existing execution

  6. Ask Copilot Agent to visit the application URL with a prompt e.g. Visit the application URL and check if the application is running fine after deployment.

    Visit application prompt

About

A simplified photo gallery application built with Spring Boot and Oracle Database - streamlined version with unused code removed

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors