|
1 | 1 | # Java Migration Copilot Workshop |
2 | 2 |
|
| 3 | +> [!IMPORTANT] |
| 4 | +> The Java Migration Copilot Tool is in preview and is subject to change before becoming generally available. |
| 5 | +
|
| 6 | +The Java Migration Copilot Tool assists with app assessment, planning and code remediation. It automates repetitive tasks, boosting developer confidence and speeding up the Azure migration and ongoing optimization. |
| 7 | + |
| 8 | +In this workshop, you learn how to use the Java Migration Copilot Tool to assess and migrate a sample Java application `asset-manager` to Azure. For more information about the sample application, see [Asset Manager](README.md). |
| 9 | + |
3 | 10 | ## Prerequisites |
4 | 11 |
|
5 | | -## Install Java Migration Copilot Tool (Private Preview) |
| 12 | +To successfully complete this workshop, you need the following: |
| 13 | + |
| 14 | +- [VSCode](https://code.visualstudio.com/): The latest version is recommended. |
| 15 | +- [A Github account with Github Copilot enabled](https://github.com/features/copilot): All plans are supported, including the Free plan. |
| 16 | +- [GitHub Copilot extension in VSCode](https://code.visualstudio.com/docs/copilot/overview): The latest version is recommended. |
| 17 | +- [Docker Desktop](https://www.docker.com/products/docker-desktop/): Required for the Assessment feature and running the initial application locally. |
| 18 | +- [JDK 21](https://learn.microsoft.com/en-us/java/openjdk/download#openjdk-21): Required for the code remediation feature and running the initial application locally. |
| 19 | +- [Azure subscription](https://azure.microsoft.com/free/): Required to deploy the migrated application to Azure. |
| 20 | +- [Azure CLI](https://docs.microsoft.com/cli/azure/install-azure-cli): Required if you deploy the migrated application to Azure locally. The latest version is recommended. |
| 21 | +- Fork the [GitHub repository](https://github.com/Azure-Samples/java-migration-copilot-samples) that contains the sample Java application, and clone it to your local machine. Open the `asset-manager` folder in VSCode and checkout the `workshop` branch. |
| 22 | + |
| 23 | +## Install Java Migration Copilot Tool |
| 24 | + |
| 25 | +Reference the doc **Installation Guide.docx** to install the Java Migration Copilot Tool. |
| 26 | + |
| 27 | +## Migrate the Sample Java Application |
| 28 | + |
| 29 | +Reference the doc **Getting Started.docx** for how to use the Java Migration Copilot Tool. The following sections guide you through the process of migrating the sample Java application `asset-manager` to Azure using the Java Migration Copilot Tool. |
| 30 | + |
| 31 | +### Assess Your Java Application |
| 32 | + |
| 33 | +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. |
| 34 | + |
| 35 | +1. Open Java Migration Copilot tool in VSCode. It consists of Assessment and Prompts features currently. |
| 36 | +1. Select **Assess**, wait for the assessment to complete, and review the assessment report. |
| 37 | +1. Select **Propose Solution** to view the proposed solutions for the issues identified in the assessment report, for example, **Migrate from AWS S3 to Azure Blob Storage**, **Migrate from Spring AMQP RabbitMQ to Azure Service Bus** and **Use Azure Database for PostgreSQL**. |
| 38 | +1. For this workshop, deselect all solutions and select **Use Azure Database for PostgreSQL**, then select **Confirm the Solution**. |
| 39 | +1. Review the solution details and select **Migrate** to initiate the migration process. |
| 40 | + |
| 41 | +### Migrate to Azure Database for PostgreSQL Flexible Server using Predefined Prompt |
| 42 | + |
| 43 | +You should see the matched predefined prompts for the selected solution are listed. Follow instructions to start the migration process. |
6 | 44 |
|
7 | | -### View Predefined Prompts |
| 45 | +1. Select the predefined prompt that best matches the solution, and confirm the prompt to run. |
| 46 | +1. Review the migration plan with files proposed to be modified. Disregard files you believe are not necessary to modify. For files you want to modify, do the following for each file: |
| 47 | + - Select the file. It starts to generate the code changes. Wait until the code changes are generated. |
| 48 | + - Review the proposed changes carefully. |
| 49 | + - Select **Accept** to apply the changes if you agree with them. |
8 | 50 |
|
9 | | -## Assess Your Java Applications |
| 51 | +Once you complete this step, suggest opening **Source Control** view to revisit the changes, and stage changes if you are satisfied with them. |
10 | 52 |
|
11 | | -## Migrate to Azure Database for PostgreSQL Flexible Server using Predefined Prompt |
| 53 | +### Migrate to Azure Blob Storage and Azure Service Bus using Custom Prompt |
12 | 54 |
|
13 | | -## Migrate to Azure Blob Storage and Azure Service Bus using Custom Prompt |
| 55 | +Recall that the sample Java application `asset-manager` uses AWS S3 for image storage and Spring AMQP RabbitMQ for message queuing. The `workshop` branch has additional commits that have already migrated the code for **Web Application** with custom code remediation to use Azure Blob Storage and Azure Service Bus, respectively. |
14 | 56 |
|
15 | | -## Build and Fix |
| 57 | +Now, you migrate the **Worker Service** to use Azure Blob Storage and Azure Service Bus as well, by using custom propmt created from existing commits that migrated the **Web Application**. |
| 58 | + |
| 59 | +1. Select **Create prompt from source control**, type **migrate web** to search for the commits that migrated the **Web Application**, and you should see two commits listed: |
| 60 | + * migrate web rabbitmq to azure service bus |
| 61 | + * migrate web s3 to azure blob storage |
| 62 | +1. Select these two commits to create a custom prompt, with all defaults populated including the name and description. |
| 63 | +1. Select and run the custom prompt you just created, and follow the same steps as the predefined prompt to review and apply the changes. |
| 64 | + |
| 65 | +Once you complete this step, suggest opening **Source Control** view to revisit the changes, and stage changes if you are satisfied with them. |
| 66 | + |
| 67 | +### Build and Fix |
| 68 | + |
| 69 | +Once you have completed the code changes, you can ask the tool to automatically build the application and fix any issues that may arise. |
| 70 | + |
| 71 | +1. Select **Fix build** to build and fix the application. |
| 72 | +1. Wait for the process to complete. If no build erros found, you can proceed to the next step. Otherwise, review the build errors and fix them manually. |
16 | 73 |
|
17 | 74 | ## Deploy to Azure |
18 | 75 |
|
19 | | -## Troubleshooting |
| 76 | +At this point, you have successfully migrated the sample Java application `asset-manager` to use Azure Database for PostgreSQL, Azure Blob Storage, and Azure Service Bus. Now, you deploy the migrated application to Azure using the Azure CLI. You can either run the deployment script locally or use the GitHub Codespaces. The recommended approach is to run the deployment script in the GitHub Codespaces, as it provides a ready-to-use environment with all the necessary dependencies. |
| 77 | + |
| 78 | +Deploy using GitHub Codespaces: |
| 79 | +1. Commit and push the changes to your forked repository. |
| 80 | +1. Follow instructions in [Use GitHub Codespaces for Deployment](README.md#use-github-codespaces-for-deployment) to deploy the app to Azure. |
| 81 | + |
| 82 | +Deploy using local environment by running the deployment script in the terminal: |
| 83 | +1. Run `az login` to sign in to Azure. |
| 84 | +1. Run the following commands to deploy the app to Azure: |
| 85 | + |
| 86 | + Winndows: |
| 87 | + ```batch |
| 88 | + scripts\deploy-to-azure.cmd -ResourceGroupName <your resource group name> -Location <your resource group location, e.g., eastus2> -Prefix <your unique resource prefix> |
| 89 | + ``` |
| 90 | + |
| 91 | + Linux: |
| 92 | + ```bash |
| 93 | + scripts/deploy-to-azure.sh -ResourceGroupName <your resource group name> -Location <your resource group location, e.g., eastus2> -Prefix <your unique resource prefix> |
| 94 | + ``` |
| 95 | + |
| 96 | +Once the deployment script completes successfully, it outputs the URL of the Web application. Open the URL in a browser to verify if the application is running as expected. |
20 | 97 |
|
21 | 98 | ## Clean up |
| 99 | + |
| 100 | +When you are done with the workshop, clean up the Azure resources to avoid incurring costs. |
| 101 | + |
| 102 | +Winndows: |
| 103 | +```batch |
| 104 | +scripts\cleanup-azure-resources.cmd -ResourceGroupName <your resource group name> |
| 105 | +``` |
| 106 | + |
| 107 | +Linux: |
| 108 | +```bash |
| 109 | +scripts/cleanup-azure-resources.sh -ResourceGroupName <your resource group name> |
| 110 | +``` |
| 111 | + |
| 112 | +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**. |
0 commit comments