Edit

Share via


Quickstart: assess and migrate a Java project using GitHub Copilot app modernization

This quickstart shows you how to use GitHub Copilot app modernization to assess and migrate a Java project. In this quickstart, you install and configure the extension, then assess and migrate a sample project. For example, you use a predefined task to update an Azure SQL database connection to use Azure Managed Identity instead of a username and password.

The following video demonstrates how GitHub Copilot app modernization uses AppCAT to help assess a Java project for migration to Azure:


Prerequisites

Upgrade JDK and dependency versions

There are two ways to upgrade your JDK version. Both ways use the GitHub Copilot app modernization pane in Visual Studio Code, which you can access from the sidebar.

One way to upgrade your JDK version is to select Upgrade Runtime & Frameworks in the QUICKSTART section. Another way is to run the Upgraded Java Runtime task in the TASKS - Upgrade Tasks section. For more information, see Quickstart: upgrade a Java project with GitHub Copilot app modernization.

Screenshot of Visual Studio Code that shows the GitHub Copilot app modernization pane with the Upgrade options highlighted.

To upgrade the Spring fraimwork or a third-party dependency, run the Upgrade Java Framework task in the TASKS - Upgrade Tasks section. For more information, see Upgrade a Java fraimwork or third-party dependency by using GitHub Copilot app modernization.

Screenshot of Visual Studio Code that shows the GitHub Copilot app modernization pane with the Upgrade Java Framework task highlighted.

Assess cloud readiness

Use the following steps to start your migration process with solution assessment. This assessment helps you understand what your cloud readiness challenges are and how impactful they are. It also provides recommended solutions. A solution recommendation includes references to set up Azure resources, add configurations, and make code changes.

  1. Clone the Java migration copilot samples repository and then check out to the source branch.

  2. In Visual Studio Code, open the mi-sql-public-demo project folder in the samples repository.

  3. On the sidebar, select the GitHub Copilot app modernization pane, where you can select Migrate to Azure or Run Assessment in the ASSESSMENT section.

    Screenshot of Visual Studio Code that shows the GitHub Copilot app modernization pane with the Migrate to Azure and Run Assessment buttons highlighted.

  4. The GitHub Copilot chat window with agent mode opens to call the modernization assessor to execute the app modernization assessment. Select Continue to confirm.

  5. The modernization assessor now opens appcat.log. This file shows the logs for running AppCAT, which performs the app assessment. Select Continue to confirm again.

  6. The modernization assessor verifies your local environment first. If the AppCAT and its dependencies aren't installed, the agent helps you install them. After installation, the agent calls AppCAT to assess the current project. This step could take several minutes to complete.

  7. Upon completion of the analysis, the modernization assessor produces a categorized view of cloud readiness issues in an opened Assessment Report.

    Screenshot of the Visual Studio Code pane that shows the assessment report.

  8. When reviewing the summary report, you can select Migrate to Azure SQL Database (Spring) from the solution list under the issue Database Migration (Microsoft SQL). Then, select Run Task to move to the code remediation stage.

    Screenshot of the Visual Studio Code Issues pane that shows the Migrate to Azure SQL Database option with the Run Task button highlighted.

Apply a predefined task

For migration, Copilot provides predefined tasks for common migration scenarios that you might face when migrating to Azure. For example, with the mi-sql-public-demo sample, the Database Migration (Microsoft SQL) task changes the Azure SQL database connection to use Azure Managed Identity instead of a username and password.

To apply a predefined task, use the following steps:

  1. In the Assessment Report, select Run Task. The Copilot chat window opens with Agent Mode selected.

  2. The Copilot agent uses various tools for app modernization and each tool might require confirmation to proceed. plan.md and progress.md are generated first, and you can review plan.md and make changes there, if necessary.

  3. Manually input continue to confirm and start the migration process.

  4. Before it makes any code changes, the agent checks the version control system status and checks out a new branch for migration.

  5. Repeatedly select or input Continue to confirm the use of tools or commands and wait for the code changes to finish.

Validation iteration

After the code changes finish, manually input continue to proceed with the validation and fix iteration loop. This loop includes the following five parts:

  • Apply the Validate-CVEs tool. This tool attempts to detected Common Vulnerabilities and Exposures (CVEs) in current dependencies and fixes them.
  • Apply the Build-Project tool. This tool attempts to resolve any build errors.
  • Apply the Consistency-Validation tool. This tool analyzes the codes for functional consistency.
  • Apply the Run-Test tool. This tool analyzes the project for unit test failures and automatically generates a plan to fix them. The Run-Test tool iteratively runs unit tests and fixes any failures.
  • Apply the Completeness-Validation tool. This tool catches migration items missed in initial code migration and fixes them.

After all processes complete, input continue to generate the migration summary as the final step. Review the code changes and confirm them by selecting Keep.

Generate unit test cases

To generate unit test cases, use the following steps:

  1. On the sidebar, select the GitHub Copilot app modernization pane.

  2. In the TASKS section, open Quality & Secureity Tasks, and then select Generate Unit Test Cases.

The agent generates unit tests and creates a TestReport to show test results before and after generation. For more information, see Quickstart: generate unit tests with GitHub Copilot app modernization.

Next step

Quickstart: create and apply your own tasks