|
| 1 | +--- |
| 2 | +title: "Quickstart: Create and Apply Your Own Formula" |
| 3 | +titleSuffix: GitHub Copilot App Modernization for Java - Azure |
| 4 | +description: Shows you how to create and apply your own formula. |
| 5 | +author: KarlErickson |
| 6 | +ms.author: karler |
| 7 | +ms.reviewer: xiading |
| 8 | +ms.topic: quickstart |
| 9 | +ms.date: 05/19/2025 |
| 10 | +ms.custom: devx-track-java |
| 11 | +ms.service: azure-java |
| 12 | +--- |
| 13 | + |
| 14 | +# Quickstart: create and apply your own formulas for GitHub Copilot App Modernization for Java (preview) |
| 15 | + |
| 16 | +This quickstart shows you how to create and apply your own formulas when you use GitHub Copilot App Modernization for Java (preview). |
| 17 | + |
| 18 | +In code development, enterprises often have different processes and controls to adhere to their organizational policies and business needs. This area is where *custom formulas* come in. A custom formula is generated by analyzing code commits from already-migrated code. The formula then guides Copilot to remediate code, following the pattern established by the already-migrated code. |
| 19 | + |
| 20 | +The following video demonstrates using GitHub Copilot App Modernization for Java (preview) to create and apply your own custom formula to migrate a Java project to Azure: |
| 21 | + |
| 22 | +<br> |
| 23 | + |
| 24 | +> [!VIDEO https://www.youtube.com/embed/ZiO3eznAl5w] |
| 25 | +
|
| 26 | +## Prerequisites |
| 27 | + |
| 28 | +- A GitHub account with [GitHub Copilot](https://github.com/features/copilot) enabled. All plans are supported, including the Free plan. |
| 29 | +- The latest version of [Visual Studio Code](https://code.visualstudio.com/). |
| 30 | +- The latest version of the [GitHub Copilot extension in Visual Studio Code](https://code.visualstudio.com/docs/copilot/overview). |
| 31 | +- [GitHub Copilot App Modernization](https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-app-mod-pack) extension pack. For install instructions, see [Quickstart: assess and migrate a Java project using GitHub Copilot App Modernization for Java (preview)](migrate-github-copilot-app-modernization-for-java-quickstart-assess-migrate.md). |
| 32 | + |
| 33 | + This extension pack bundles the following two extensions: |
| 34 | + - [GitHub Copilot App Modernization for Java (preview)](migrate-github-copilot-app-modernization-for-java.md) |
| 35 | + - [GitHub Copilot App Modernization - upgrade for Java (preview)](/java/upgrade/overview) |
| 36 | + |
| 37 | + App Modernization doesn't require Java in your local environment. However, to build your project successfully, install the correct version of Java and Maven. We recommend the [Microsoft Build of OpenJDK](/java/openjdk/) and [Maven](https://maven.apache.org/download.cgi). |
| 38 | + |
| 39 | +- [AppCAT](/azure/migrate/appcat/java-preview#download-and-install). This tool is required for the app assessment feature. |
| 40 | + |
| 41 | +## Create a custom formula |
| 42 | + |
| 43 | +Use the following steps to create a custom formula: |
| 44 | + |
| 45 | +1. Clone the [Java migration copilot samples](https://github.com/Azure-Samples/java-migration-copilot-samples) repository. |
| 46 | + |
| 47 | +1. In Visual Studio Code, open the **rabbitmq-sender** project folder in the samples repository. Then, check out the project to the **source** branch. |
| 48 | + |
| 49 | +1. In the **Activity** sidebar, open the **App Modernization for Java** extension pane and then, in the **Formulas** section, select **Create formula from source control**. |
| 50 | + |
| 51 | + :::image type="content" source="./media/migrate-github-copilot-app-modernization-for-java/create-formula-from-source-control.png" lightbox="./media/migrate-github-copilot-app-modernization-for-java/create-formula-from-source-control.png" alt-text="Screenshot of Visual Studio Code that shows the button for Create formula from source control."::: |
| 52 | + |
| 53 | +1. Type **migrate rabbitmq to service bus** to search for the commit that migrates RabbitMQ. Select the corresponding commit and then select **OK**. |
| 54 | + |
| 55 | + :::image type="content" source="./media/migrate-github-copilot-app-modernization-for-java/commit-for-custom-formula.png" lightbox="./media/migrate-github-copilot-app-modernization-for-java/commit-for-custom-formula.png" alt-text="Screenshot of the Visual Studio Code dialog box with the heading Select commits you want to save."::: |
| 56 | + |
| 57 | +1. Select **Create New** to create a new custom formula. |
| 58 | + |
| 59 | +1. A default formula name is generated. Name it **custom formula migrate rabbitmq**, then press <kbd>Enter</kbd> to confirm. A formula description and search patterns are generated in order. Press <kbd>Enter</kbd> repeatedly to confirm. |
| 60 | + |
| 61 | +1. Now, the custom formula for migrating `rabbitmq` is generated and shows in the **Formulas** section of the **App Modernization for Java** pane. |
| 62 | + |
| 63 | + :::image type="content" source="./media/migrate-github-copilot-app-modernization-for-java/custom-formula-rabbitmq.png" lightbox="./media/migrate-github-copilot-app-modernization-for-java/custom-formula-rabbitmq.png" alt-text="Screenshot of Visual Studio Code that shows the Formulas section with the rabbitmq formula showing."::: |
| 64 | + |
| 65 | +## Apply the custom formula |
| 66 | + |
| 67 | +Use the following steps to apply the custom formula: |
| 68 | + |
| 69 | +1. Check out the project to the **main** branch. Find the custom formula in the **Formulas** section of **App Modernization for Java** pane. Run this formula by selecting **Run Formula**. |
| 70 | + |
| 71 | + :::image type="content" source="./media/migrate-github-copilot-app-modernization-for-java/run-formula.png" lightbox="./media/migrate-github-copilot-app-modernization-for-java/run-formula.png" alt-text="Screenshot of Visual Studio Code that shows the Formulas section with the Run formula button indicated by a tooltip."::: |
| 72 | + |
| 73 | + After you select the formula, the Copilot chat window with Agent Mode opens automatically. |
| 74 | + |
| 75 | +1. Select **Continue** repeatedly to confirm each tool action in the Copilot Chat window. The Copilot Agent uses various tools to facilitate application modernization. Each tool's usage requires confirmation by selecting **Continue**. |
| 76 | + |
| 77 | +1. After each step, manually input **continue** to confirm and proceed. |
| 78 | + |
| 79 | +1. Wait for the code changes to be generated. |
| 80 | + |
| 81 | +1. When you're prompted to run the **Java Application Build-Fix** tool, select **Continue** to build the project and fix errors. This tool attempts to resolve any build errors in up to 10 iterations. |
| 82 | + |
| 83 | +1. After the Build-Fix tool begins, select **Continue** to proceed and show progress. |
| 84 | + |
| 85 | +1. After the tool is finished, review the code changes and confirm them by selecting **Keep**. |
| 86 | + |
| 87 | +## See also |
| 88 | + |
| 89 | +[Predefined formulas for GitHub Copilot App Modernization for Java (preview)](migrate-github-copilot-app-modernization-for-java-predefined-formula.md) |
0 commit comments