Skip to content

Commit ccf8ef2

Browse files
authored
update README files (#26)
1 parent 220aa0a commit ccf8ef2

File tree

4 files changed

+185
-176
lines changed

4 files changed

+185
-176
lines changed

asset-manager/README.md

Lines changed: 174 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,170 @@
1-
# Asset Manager
2-
Sample project for migration tool code remediation that manages assets in cloud storage.
1+
# Workshop: migrate this project to Azure
32

4-
## Current Infrastructure
5-
The project currently uses the following infrastructure, in [`main`](https://github.com/Azure-Samples/java-migration-copilot-samples/tree/main/asset-manager) branch:
3+
> [!IMPORTANT]
4+
> `GitHub Copilot App Modernization for Java` is in preview and is subject to change before becoming generally available.
5+
6+
GitHub Copilot App Modernization for Java (Preview), also referred to as `App Modernization for Java`, 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 GitHub Copilot App Modernization for Java (Preview) to assess and migrate a sample Java application `asset-manager` to Azure. This application consists of two sub-modules, **Web** and **Worker**. For more information about this sample application, see [Asset Manager](README.md).
9+
10+
## Prerequisites
11+
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+
- [AppCAT](https://aka.ms/appcat-install): Required for the app assessment feature.
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+
- [Maven 3.9.9](https://maven.apache.org/install.html): Required for the assessment and code remediation feature.
20+
- [Azure subscription](https://azure.microsoft.com/free/): Required to deploy the migrated application to Azure.
21+
- [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.
22+
- Fork the [GitHub repository](https://github.com/Azure-Samples/java-migration-copilot-samples) that contains the sample Java application. Please ensure to **uncheck** the default selection "Copy the `main` branch only". Clone it to your local machine. Open the `asset-manager` folder in VSCode and checkout the `main` branch.
23+
24+
## Install GitHub Copilot App Modernization for Java (Preview)
25+
26+
In VSCode, open the Extensions view from Activity Bar, search `GitHub Copilot App Modernization for Java` extension in marketplace. Select the Install button on the extension. After installation completes, you should see a notification in the bottom-right corner of VSCode confirming success.
27+
28+
In VSCode, configure runtime arguments to enable the proposed API:
29+
```json
30+
"enable-proposed-api": ["Microsoft.migrate-java-to-azure"],
31+
```
32+
1. Press **Ctrl+Shift+P** and select **Preferences: Configure Runtime Arguments**.
33+
2. Add the above JSON snippet into the editor and save.
34+
3. Restart VSCode.
35+
36+
37+
## Migrate the Sample Java Application
38+
39+
The following sections guide you through the process of migrating the sample Java application `asset-manager` to Azure using GitHub Copilot App Modernization for Java (Preview).
40+
41+
### Assess Your Java Application
42+
43+
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.
44+
45+
1. Open the VS code with all the prerequisites installed on the asset manager by changing the directory to the `asset-manager` directory and running `code .` in that directory.
46+
1. Open the extension `App Modernization for Java`.
47+
1. Hover the mouse over the **Assessment** section and click **Assess** button which looks like a triangle pointing right. Then, the Github Copilot Chat window will be opened and propose to run Modernization Assessor. Please confirm the tool usage by clicking **Continue**.
48+
![Trigger Assessment](doc-media/trigger-assessment.png)
49+
50+
> **NOTE**: If you are asked to allow the tool access the language models provided by GitHub Copilot Chat, select **Allow** to proceed.
51+
52+
1. After each step, please manually input "continue" to confirm and proceed.
53+
1. Wait for the assessment to be completed and the report to be generated.
54+
1. Review the **Summary** report. Select **Propose Solution** to view the proposed solutions for the issues identified in the summary report.
55+
1. For this workshop, deselect all solutions and select **Migrate to Azure Database for PostgreSQL (SDK on Public Cloud)** in the Solution report, then select **Confirm Solution**.
56+
![Confirm Solution](doc-media/confirm-postgresql-solution.png)
57+
1. In the Migrate report, click **Migrate**.
58+
59+
### Migrate to Azure Database for PostgreSQL Flexible Server using Predefined Formula
60+
61+
1. After clicking the Migrate button in the Solution Report, Copilot chat window will be opened with Agent Mode.
62+
1. In Copilot chat window, click **Continue** repeatedly to confirm each tool action. The Copilot Agent uses various tools to facilitate application modernization. Each tool's usage requires confirmation by clicking the `Continue` button.
63+
1. After each step, please manually input "Continue" to confirm and proceed.
64+
1. Click **Continue** to confirm to run **Java Application Build-Fix** tool. This tool will attempt to resolve any build errors, in up to 10 iterations.
65+
1. After the Build-Fix tool begins, click **Continue** to proceed and show progress and migration summary.
66+
1. Review the proposed code changes and click **Keep** to apply them.
67+
68+
### Migrate to Azure Blob Storage and Azure Service Bus using Custom Formula
69+
70+
The Application `asset-manager` used AWS S3 for image storage and Spring AMQP with RabbitMQ for message queuing. We have already migrated the code of **Web** module to use Azure Blob Storage and Azure Service Bus. These changes are recorded in two separate commits in the `main` branch.
71+
72+
The following steps demonstrate how to generate custom formulas based on those existing commits. Then, you can migrate **Worker** module to use Azure Blob Storage and Azure Service Bus as well, using the created custom formulas.
73+
74+
1. Open the sidebar of `App Modernization for Java`. Hover the mouse over the **Formulas** section. Select **Create formula from source control**. This icon looks like two circles with arrows pointing to the other circle.
75+
![Create Formula From Source Control](doc-media/create-formula-from-source-control.png)
76+
1. Type **migrate web** to search for the commits that migrated the **Web** module, and you should see two commits listed:
77+
* migrate web RabbitMQ to azure service bus
78+
* migrate web s3 to azure blob storage
79+
![Migration Commits](doc-media/migration-commits.png)
80+
1. You will create two custom formulas based on the two commits. First, create the formula for migrating RabbitMQ. Select the commit of **migrate web RabbitMQ to azure service bus**, click OK.
81+
1. Click **Create New** to create a new custom formula.
82+
1. Default formula name will be generated. Give it a new name: "custom formula migrate RabbitMQ". Press `Enter` to confirm. Then, formula description, and search patterns will be generated in order. Press `Enter` repeatedly to confirm.
83+
1. Now, the custom formula for migrating RabbitMQ is generated and shows in the section of formulas in of `App Modernization for Java` blade.
84+
![Custom Formula of Migrating Rabbitmq](doc-media/custom-formula-RabbitMQ.png)
85+
1. Create another custom formula for migrating S3. Follow the same steps you just did, select the commit **migrate web s3 to azure blob storage** to create a new custom formula with name: "custom formula migrate s3".
86+
1. Now, the two custom formulas are ready.
87+
![Custom Formulas](doc-media/custom-formulas.png)
88+
1. Select and run the two custom formulas one by one you created in the formulas section of `App Modernization for Java`, one at a time.
89+
![Run Formula](doc-media/run-formula.png)
90+
1. Follow the same steps as the predefined formula to review and apply the changes, and run the Java Application Build-Fix tool to apply build fixes.
91+
1. Review the proposed code changes and click **Keep** to apply them.
92+
93+
## Deploy to Azure
94+
95+
At this point, you have successfully migrated the sample Java application `asset-manager` to Migrate to Azure Database for PostgreSQL (SDK on Public Cloud), Azure Blob Storage, and Azure Service Bus. Now, you can deploy the migrated application to Azure using the Azure CLI after you identify a working location for your Azure resources.
96+
97+
For example, an Azure Database for PostgreSQL Flexible Server requires a location that supports the service. Follow the instructions below to find a suitable location.
98+
99+
1. Run the following command to list all available locations for the current subscription.
100+
101+
```bash
102+
az account list-locations -o table
103+
```
104+
105+
1. Select a location from column **Name** in the output.
106+
107+
1. Run the following command to list all available SKUs in the selected location for Azure Database for PostgreSQL Flexible Server:
108+
109+
```bash
110+
az postgres flexible-server list-skus --location <your location> -o table
111+
```
112+
113+
1. If you see the output contains the SKU `Standard_B1ms` and the **Tier** is `Burstable`, you can use the location for the deployment. Otherwise, try another location.
114+
115+
```text
116+
SKU Tier VCore Memory Max Disk IOPS
117+
----------------- --------------- ------- -------- ---------------
118+
Standard_B1ms Burstable 1 2 GiB 640e
119+
```
120+
121+
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.
122+
123+
Deploy using GitHub Codespaces:
124+
1. Commit and push the changes to your forked repository.
125+
1. Follow instructions in [Use GitHub Codespaces for Deployment](README.md#use-github-codespaces-for-deployment) to deploy the app to Azure.
126+
127+
Deploy using local environment by running the deployment script in the terminal:
128+
1. Run `az login` to sign in to Azure.
129+
1. Run the following commands to deploy the app to Azure:
130+
131+
Windows:
132+
```batch
133+
scripts\deploy-to-azure.cmd -ResourceGroupName <your resource group name> -Location <your resource group location, e.g., eastus2> -Prefix <your unique resource prefix>
134+
```
135+
136+
Linux:
137+
```bash
138+
scripts/deploy-to-azure.sh -ResourceGroupName <your resource group name> -Location <your resource group location, e.g., eastus2> -Prefix <your unique resource prefix>
139+
```
140+
141+
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.
142+
143+
## Clean up
144+
145+
When no longer needed, you can delete all related resources using the following scripts.
146+
147+
Windows:
148+
```batch
149+
scripts\cleanup-azure-resources.cmd -ResourceGroupName <your resource group name>
150+
```
151+
152+
Linux:
153+
```bash
154+
scripts/cleanup-azure-resources.sh -ResourceGroupName <your resource group name>
155+
```
156+
157+
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**.
158+
159+
## Project Information
160+
161+
### Current Infrastructure
162+
The project currently uses the following infrastructure, in [`source`](https://github.com/Azure-Samples/java-migration-copilot-samples/tree/source/asset-manager) branch:
6163
* AWS S3 for image storage, using password-based authentication (access key/secret key)
7164
* RabbitMQ for message queuing, using password-based authentication
8165
* PostgreSQL database for metadata storage, using password-based authentication
9166

10-
## Current Architecture
167+
### Current Architecture
11168
```mermaid
12169
flowchart TD
13170
@@ -76,13 +233,13 @@ class User user
76233
```
77234
Password-based authentication
78235

79-
## Migrated Infrastructure
236+
### Migrated Infrastructure
80237
After migration, the project will use the following Azure services, in [`expected`](https://github.com/Azure-Samples/java-migration-copilot-samples/tree/expected/asset-manager) branch:
81238
* Azure Blob Storage for image storage, using managed identity authentication
82239
* Azure Service Bus for message queuing, using managed identity authentication
83240
* Azure Database for PostgreSQL for metadata storage, using managed identity authentication
84241

85-
## Migrated Architecture
242+
### Migrated Architecture
86243
```mermaid
87244
flowchart TD
88245
@@ -151,14 +308,14 @@ class User user
151308
```
152309
Managed identity based authentication
153310

154-
## Run Locally
311+
### Run Locally
155312

156-
Check out the [`main`](https://github.com/Azure-Samples/java-migration-copilot-samples/tree/main/asset-manager) branch to run the current infrastructure locally:
313+
Check out the [`source`](https://github.com/Azure-Samples/java-migration-copilot-samples/tree/source/asset-manager) branch to run the current infrastructure locally:
157314

158315
```bash
159316
git clone https://github.com/Azure-Samples/java-migration-copilot-samples.git
160317
cd java-migration-copilot-samples/asset-manager
161-
git checkout main
318+
git checkout source
162319
```
163320

164321
**Prerequisites**: JDK, Docker
@@ -181,7 +338,7 @@ scripts/start.sh
181338

182339
To stop, run `stop.cmd` or `stop.sh` in the `scripts` directory.
183340

184-
## Run Migrated Code on Azure
341+
### Run Migrated Code on Azure
185342

186343
Check out the [`expected`](https://github.com/Azure-Samples/java-migration-copilot-samples/tree/expected/asset-manager) branch to run the migrated infrastructure on Azure:
187344

@@ -212,7 +369,7 @@ scripts/deploy-to-azure.sh -ResourceGroupName <your resource group name> -Locati
212369

213370
To clean up, run `scripts\cleanup-azure-resources.cmd -ResourceGroupName <your resource group name>` or `scripts/cleanup-azure-resources.sh -ResourceGroupName <your resource group name>` for Windows and Linux, respectively.
214371

215-
### Use GitHub Codespaces for Deployment
372+
#### Use GitHub Codespaces for Deployment
216373

217374
The deployment scripts can also be executed in GitHub Codespaces, which pre-installs the necessary dependencies. Follow the steps below to deploy the apps to Azure using GitHub Codespaces:
218375

@@ -229,24 +386,22 @@ The deployment scripts can also be executed in GitHub Codespaces, which pre-inst
229386

230387
1. To clean up, run `scripts\cleanup-azure-resources.cmd -ResourceGroupName <your resource group name>` or `scripts/cleanup-azure-resources.sh -ResourceGroupName <your resource group name>` for Windows and Linux, respectively.
231388

232-
## Java Migration Copilot Workshop
389+
### Java Migration Copilot Workshop
233390

234-
Check out the [`workshop`](https://github.com/Azure-Samples/java-migration-copilot-samples/tree/workshop/asset-manager) branch for Java Migration Copilot workshop:
391+
Check out the [`main`](https://github.com/Azure-Samples/java-migration-copilot-samples/tree/main/asset-manager) branch for Java Migration Copilot workshop:
235392

236393
```bash
237394
git clone https://github.com/Azure-Samples/java-migration-copilot-samples.git
238395
cd java-migration-copilot-samples/asset-manager
239-
git checkout workshop
396+
git checkout main
240397
```
241398

242-
Compared to the `main` branch, the `workshop` branch has additional commits that have already migrated the code for **Web Application** with custom code remediation, including:
399+
Compared to the `source` branch, the `main` branch has additional commits that have already migrated the code for **Web Application** with custom code remediation, including:
243400
* Azure Blob Storage for image storage, using managed identity authentication
244401
* Azure Service Bus for message queuing, using managed identity authentication
245402

246403
The remaining targets of the workshop are:
247404
* For both **Web Application** and **Worker Service**, migrate to Azure Database for PostgreSQL Flexible server for metadata storage with managed identity authentication, using predefined prompt.
248405
* For **Worker Service**, migrate to Azure Blob Storage and Azure Service Bus for image storage and message queuing, respectively, with managed identity authentication, using custom propmt created from existing commits that migrated the **Web Application**.
249406

250-
Once the workshop is successfully completed, you should be able to run the migrated code on Azure, similar to [Run Migrated Code on Azure](#run-migrated-code-on-azure) but using the `workshop` branch with the migrated code.
251-
252-
For more details, refer to the [workshop guide](https://github.com/Azure-Samples/java-migration-copilot-samples/blob/workshop/asset-manager/WORKSHOP.md).
407+
Once the workshop is successfully completed, you should be able to run the migrated code on Azure, similar to [Run Migrated Code on Azure](#run-migrated-code-on-azure) but using the `main` branch with the migrated code.

0 commit comments

Comments
 (0)