Skip to content

Commit b4c837d

Browse files
author
Cephas Lin
committed
1 parent f2f9cf7 commit b4c837d

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

articles/app-service/tutorial-java-tomcat-mysql-app.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ This tutorial shows how to build, configure, and deploy a secure Tomcat applicat
3333

3434
::: zone-end
3535

36+
> [!TIP]
37+
> To try GitHub Copilot, you need a [GitHub Copilot account](https://docs.github.com/copilot/using-github-copilot/using-github-copilot-code-suggestions-in-your-editor). A 30-day free trial is available.
38+
3639
## Skip to the end
3740

3841
You can quickly deploy the sample app in this tutorial and see it running in Azure. Just run the following commands in the [Azure Cloud Shell](https://shell.azure.com), and follow the prompt:
@@ -84,6 +87,12 @@ First, you set up a sample data-driven app as a starting point. For your conveni
8487
:::column-end:::
8588
:::row-end:::
8689

90+
> [!TIP]
91+
> You can ask [GitHub Copilot](https://docs.github.com/copilot/using-github-copilot/using-github-copilot-code-suggestions-in-your-editor) about this repository. For example:
92+
>
93+
> * *@workspace What does this project do?*
94+
> * *@workspace What does the .devcontainer folder do?*
95+
8796
Having issues? Check the [Troubleshooting section](#troubleshooting).
8897

8998
::: zone pivot="azure-portal"
@@ -614,31 +623,23 @@ See [Set up GitHub Actions deployment from the Deployment Center](deploy-github-
614623
615624
#### Make code changes using GitHub Copilot
616625
617-
With a [GitHub Copilot account](https://docs.github.com/copilot/using-github-copilot/using-github-copilot-code-suggestions-in-your-editor) (30-day free trial available), you can make the code changes in this tutorial by using Copilot Chat in the codespace. For example:
618-
619-
1. In your [codespace](#1-run-the-sample), open *src/main/resources/META-INF/persistence.xml*.
620-
1. Start a new Copilot chat session in the **Chat** view. The GitHub Copilot chat extension was installed by the container definition (see *.devcontainer/devcontainer.json*).
621-
1. If you like, ask, "*What does this file do?*"
626+
With a [GitHub Copilot account](https://docs.github.com/copilot/using-github-copilot/using-github-copilot-code-suggestions-in-your-editor) (30-day free trial available), you can make the code changes in this tutorial by using Copilot Chat in the codespace. Since GitHub Copilot doesn't give you the same answer every time, the following is just an example:
622627
623-
Copilot should give you some explanation about the jdbc/MYSQLDS data source.
624-
1. Ask, "*I want to override this data source dynamically with a Tomcat shared data source.*"
628+
1. In your [codespace](#1-run-the-sample), start a new Copilot chat session in the **Chat** view. The GitHub Copilot chat extension was installed by the container definition (see *.devcontainer/devcontainer.json*).
625629
626-
Copilot should show you sample code similar to [the one in this tutorial](#5-deploy-sample-code).
627-
1. If the sample code is using the `javax.*` namespace, you can say "My application uses Jakarta instead."
630+
1. Ask, "*@workspace How does the app connect to the database?*"
628631
629-
Copilot should update the code suggestion to use the `jakarta.persistence.nonJtaDataSource` instead.
630-
1. Say, "*My Tomcat data source is called jdbc/AZURE_MYSQL_CONNECTIONSTRING_DS.*"
632+
Copilot might give you some explanation about the `jdbc/MYSQLDS` data source and how it's configured. For the `@workspace` agent, see [Use the @workspace agent](https://github.blog/2024-03-25-how-to-use-github-copilot-in-your-ide-tips-tricks-and-best-practices/#10-use-the-workspace-agent).
631633
632-
Copilot should update the JNDI name in the code suggestion.
634+
1. Ask, "*@workspace I want to replace the data source defined in persistence.xml with an existing JNDI data source in Tomcat but I want to do it dynamically.*"
633635
634-
1. Say, "*I want this code to run only if the environment AZURE_MYSQL_CONNECTIONSTRING is set.*"
635-
636-
Copilot should update the code suggestion with a check for the environment variable.
636+
Copilot might show you sample code similar to [the one in this tutorial](#5-deploy-sample-code) and even tell you to make the change in the [ContextListener](https://github.com/Azure-Samples/msdocs-tomcat-mysql-sample-app/blob/starter-no-infra/src/main/java/com/microsoft/azure/appservice/examples/tomcatmysql/ContextListener.java) class. However, it won't make the actual change for you. It's up to you to add the suggested code and test it.
637637
638-
The suggested code for `contextInitialized` is now very similar to the one shown in this tutorial. It may not be exactly the same. You can copy and paste this code into the `contextInitialized` method of *src/main/java/com/microsoft/azure/appservice/examples/tomcatmysql/ContextListener.java* and test it.
638+
Here are some other things you can say to fine-tune the answer you get.
639639
640-
> [!NOTE]
641-
> Copilot is not always correct in its code suggestions. It's still up to you to verify that the code works as expected in your application.
640+
* Please change this code to use the data source jdbc/AZURE_MYSQL_CONNECTIONSTRING_DS.
641+
* Some imports in this are using javax but I have a Jakarta app.
642+
* I want this code to run only if the environment variable AZURE_MYSQL_CONNECTIONSTRING is set.
642643
643644
## Next steps
644645

0 commit comments

Comments
 (0)