Skip to content

Commit f2f9cf7

Browse files
author
Cephas Lin
committed
add try copilot
1 parent 6d18b17 commit f2f9cf7

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ In this step, you configure GitHub deployment using GitHub Actions. It's just on
207207

208208
Like the Tomcat convention, if you want to deploy to the root context of Tomcat, name your built artifact *ROOT.war*.
209209

210+
> [!TIP]
211+
> In **Step 4**, try [letting GitHub Copilot show you the code changes to make](#make-code-changes-using-github-copilot).
212+
210213
:::row:::
211214
:::column span="2":::
212215
**Step 1:** Back in the App Service page, in the left menu, select **Deployment Center**.
@@ -482,6 +485,9 @@ Having issues? Check the [Troubleshooting section](#troubleshooting).
482485
483486
This code checks to see if the `AZURE_MYSQL_CONNECTIONSTRING` app setting exists, and changes the data source to `java:comp/env/jdbc/AZURE_MYSQL_CONNECTIONSTRING_DS`, which is the data source you found earlier in *context.xml* in the SSH shell.
484487
488+
> [!TIP]
489+
> Try [letting GitHub Copilot show you the code changes to make](#make-code-changes-using-github-copilot).
490+
485491
1. Back in the codespace terminal, run `azd deploy`.
486492
487493
```bash
@@ -606,6 +612,34 @@ git push origin main
606612
607613
See [Set up GitHub Actions deployment from the Deployment Center](deploy-github-actions.md#set-up-github-actions-deployment-from-the-deployment-center).
608614
615+
#### Make code changes using GitHub Copilot
616+
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?*"
622+
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.*"
625+
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."
628+
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.*"
631+
632+
Copilot should update the JNDI name in the code suggestion.
633+
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.
637+
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.
639+
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.
642+
609643
## Next steps
610644
611645
- [Azure for Java Developers](/java/azure/)

0 commit comments

Comments
 (0)