Skip to content

Commit 401f5f5

Browse files
author
Cephas Lin
committed
acrolinx
1 parent 0ae677b commit 401f5f5

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

articles/app-service/toc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157
- name: Python with Postgres
158158
href: tutorial-python-postgresql-app.md
159159
- name: Tomcat with MySQL
160-
href: tutorial-java-quarkus-postgresql-app.md
160+
href: tutorial-java-tomcat-mysql-app.md
161161
- name: Spring Boot with MongoDB
162162
href: tutorial-java-spring-cosmosdb.md
163163
- name: Quarkus with Postgres

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

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ zone_pivot_groups: app-service-portal-azd
1212

1313
# Tutorial: Build a Tomcat web app with Azure App Service on Linux and MySQL
1414

15-
This tutorial shows how to build, configure, and deploy a secure Tomcat application in Azure App Service that's connected to a MySQL database (using [Azure Database for MySQL](../mysql/index.yml)). Azure App Service is a highly scalable, self-patching, web-hosting service that can easily deploy apps on Windows or Linux. When you're finished, you'll have a Tomcat app running on [Azure App Service on Linux](overview.md).
15+
This tutorial shows how to build, configure, and deploy a secure Tomcat application in Azure App Service that connects to a MySQL database (using [Azure Database for MySQL](../mysql/index.yml)). Azure App Service is a highly scalable, self-patching, web-hosting service that can easily deploy apps on Windows or Linux. When you're finished, you'll have a Tomcat app running on [Azure App Service on Linux](overview.md).
1616

1717
:::image type="content" source="./media/tutorial-java-tomcat-mysql-app/azure-portal-browse-app-2.png" alt-text="Screenshot of Tomcat application storing data in MySQL.":::
1818

@@ -163,7 +163,7 @@ App settings are one way to keep connection secrets out of your code repository.
163163
:::column span="2":::
164164
**Step 2:**
165165
1. In the **Application settings** tab of the **Configuration** page, find the app setting `AZURE_MYSQL_CONNECTIONSTRING`. The creation wizard created it for you.
166-
1. If you want, you can select the **Edit** button to the right of each setting and see or copy its value, or select Add to add a variable to inject into your Tomcat container. If you add an app setting that contains a valid Oracle, SQL Server, PostgreSQL, or MySQL connection string, App Service adds it as a JNDI data source in the Tomcat server's *context.xml* file.
166+
1. If you want, you can select the **Edit** button to the right of each setting and see or copy its value, or select Add to add a variable to inject into your Tomcat container. If you add an app setting that contains a valid Oracle, SQL Server, PostgreSQL, or MySQL connection string, App Service adds it as a Java Naming and Directory Interface (JNDI) data source in the Tomcat server's *context.xml* file.
167167
:::column-end:::
168168
:::column:::
169169
:::image type="content" source="./media/tutorial-java-tomcat-mysql-app/azure-portal-get-connection-string-2.png" alt-text="A screenshot showing how to see the autogenerated connection string." lightbox="./media/tutorial-java-tomcat-mysql-app/azure-portal-get-connection-string-2.png":::
@@ -189,7 +189,7 @@ In this step, you use the SSH connection to the app container to verify the JNDI
189189
:::row:::
190190
:::column span="2":::
191191
**Step 2:** In the SSH terminal:
192-
1. Run `cat /usr/local/tomcat/conf/context.xml`. You should see that a JNDI resource called `jdbc/AZURE_MYSQL_CONNECTIONSTRING_DS` was added. You will use this data source later.
192+
1. Run `cat /usr/local/tomcat/conf/context.xml`. You should see that a JNDI resource called `jdbc/AZURE_MYSQL_CONNECTIONSTRING_DS` was added. You'll use this data source later.
193193
:::column-end:::
194194
:::column:::
195195
:::image type="content" source="./media/tutorial-java-tomcat-mysql-app/azure-portal-check-config-in-ssh-2.png" alt-text="A screenshot showing the commands to run in the SSH shell and their output." lightbox="./media/tutorial-java-tomcat-mysql-app/azure-portal-check-config-in-ssh-2.png":::
@@ -307,7 +307,7 @@ Having issues? Check the [Troubleshooting section](#troubleshooting).
307307

308308
## 7. Stream diagnostic logs
309309

310-
Azure App Service captures all messages output to the console to help you diagnose issues with your application. The sample application includes standard Log4j logging statements to demonstrate this capability as shown below.
310+
Azure App Service captures all messages output to the console to help you diagnose issues with your application. The sample application includes standard Log4j logging statements to demonstrate this capability, as shown in the following snippet:
311311

312312
:::code language="java" source="~/msdocs-tomcat-mysql-sample-app/src/main/java/com/microsoft/azure/appservice/examples/tomcatmysql/ViewServlet.java" range="17-26" highlight="3,8":::
313313

@@ -375,7 +375,7 @@ When you're finished, you can delete all of the resources from your Azure subscr
375375

376376
In this step, you create the Azure resources and deploy a sample app to App Service on Linux. The steps used in this tutorial create a set of secure-by-default resources that include App Service and Azure Database for MySQL.
377377

378-
The dev container already has the [Azure Developer CLI](/azure/developer/azure-developer-cli/install-azd).
378+
The dev container already has the [Azure Developer CLI](/azure/developer/azure-developer-cli/install-azd) (AZD).
379379

380380
1. From the repository root, run `azd init`.
381381

@@ -389,23 +389,23 @@ The dev container already has the [Azure Developer CLI](/azure/developer/azure-d
389389
|---------|---------|
390390
|The current directory is not empty. Would you like to initialize a project here in '\<your-directory>'? | **Y** |
391391
|What would you like to do with these files? | **Keep my existing files unchanged** |
392-
|Enter a new environment name | Type a unique name. The azd template uses this name as part of the DNS name of your web app in Azure (`<app-name>.azurewebsites.net`). Alphanumeric characters and hyphens are allowed. |
392+
|Enter a new environment name | Type a unique name. The AZD template uses this name as part of the DNS name of your web app in Azure (`<app-name>.azurewebsites.net`). Alphanumeric characters and hyphens are allowed. |
393393

394-
1. Run the `azd auth login` command and follow the prompt to sign into Azure.
394+
1. Sign into Azure by running the `azd auth login` command and following the prompt:
395395

396396
```bash
397397
azd auth login
398398
```
399399

400-
1. Run the `azd up` command to create the necessary Azure resources and deploy the app code. Follow the prompt to select the desired subscription and location for the Azure resources.
400+
1. Create the necessary Azure resources and deploy the app code with the `azd up` command. Follow the prompt to select the desired subscription and location for the Azure resources.
401401

402402
```bash
403403
azd up
404404
```
405405

406406
The `azd up` command takes about 15 minutes to complete (the Redis cache take the most time). It also compiles and deploys your application code, but you'll modify your code later to work with App Service. While it's running, the command provides messages about the provisioning and deployment process, including a link to the deployment in Azure. When it finishes, the command also displays a link to the deploy application.
407407

408-
This azd template contains files (*azure.yaml* and the *infra* directory) that generate a secure-by-default architecture with the following Azure resources:
408+
This AZD template contains files (*azure.yaml* and the *infra* directory) that generate a secure-by-default architecture with the following Azure resources:
409409

410410
- **Resource group**: The container for all the created resources.
411411
- **App Service plan**: Defines the compute resources for App Service. A Linux plan in the *B1* tier is created.
@@ -415,13 +415,13 @@ The dev container already has the [Azure Developer CLI](/azure/developer/azure-d
415415
- **Azure Cache for Redis**: Accessible only from within the virtual network.
416416
- **Private DNS zones**: Enable DNS resolution of the database server and the Redis cache in the virtual network.
417417
- **Log Analytics workspace**: Acts as the target container for your app to ship its logs, where you can also query the logs.
418-
- **Key vault**: Used to keep your database password the same when you redeploy with azd.
418+
- **Key vault**: Used to keep your database password the same when you redeploy with AZD.
419419

420420
## 3. Verify connection strings
421421

422-
The azd template you use generated the connectivity variables for you already as [app settings](configure-common.md#configure-app-settings) and outputs the them to the terminal for your convenience. App settings are one way to keep connection secrets out of your code repository.
422+
The AZD template you use generated the connectivity variables for you already as [app settings](configure-common.md#configure-app-settings) and outputs the them to the terminal for your convenience. App settings are one way to keep connection secrets out of your code repository.
423423

424-
1. In the azd output, find the app setting `AZURE_MYSQL_CONNECTIONSTRING`. To keep secrets safe, only the setting names are displayed. They look like this in the azd output:
424+
1. In the AZD output, find the app setting `AZURE_MYSQL_CONNECTIONSTRING`. To keep secrets safe, only the setting names are displayed. They look like this in the AZD output:
425425

426426
<pre>
427427
App Service app has the following connection strings:
@@ -432,21 +432,21 @@ The azd template you use generated the connectivity variables for you already as
432432

433433
`AZURE_MYSQL_CONNECTIONSTRING` contains the connection string to the MySQL database in Azure. You need to use it in your code later.
434434

435-
1. For your convenience, the azd template shows you the direct link to the app's app settings page. Find the link and open it in a new browser tab.
435+
1. For your convenience, the AZD template shows you the direct link to the app's app settings page. Find the link and open it in a new browser tab.
436436
437-
If you add an app setting that contains a valid Oracle, SQL Server, PostgreSQL, or MySQL connection string, App Service adds it as a JNDI data source in the Tomcat server's *context.xml* file.
437+
If you add an app setting that contains a valid Oracle, SQL Server, PostgreSQL, or MySQL connection string, App Service adds it as a Java Naming and Directory Interface (JNDI) data source in the Tomcat server's *context.xml* file.
438438

439439
## 4. Confirm JNDI data source
440440

441441
In this step, you use the SSH connection to the app container to verify the JNDI data source in the Tomcat server. In the process, you learn how to access the SSH shell for the Tomcat container.
442442

443-
1. In the azd output, find the URL for the SSH session and navigate to it in the browser. It looks like this in the output:
443+
1. In the AZD output, find the URL for the SSH session and navigate to it in the browser. It looks like this in the output:
444444

445445
<pre>
446446
Open SSH session to App Service container at: https://&lt;app-name>.scm.azurewebsites.net/webssh/host
447447
</pre>
448448

449-
1. In the SSH terminal, run `cat /usr/local/tomcat/conf/context.xml`. You should see that a JNDI resource called `jdbc/AZURE_MYSQL_CONNECTIONSTRING_DS` was added. You will use this data source later.
449+
1. In the SSH terminal, run `cat /usr/local/tomcat/conf/context.xml`. You should see that a JNDI resource called `jdbc/AZURE_MYSQL_CONNECTIONSTRING_DS` was added. You'll use this data source later.
450450
451451
:::image type="content" source="./media/tutorial-java-tomcat-mysql-app/azure-portal-check-config-in-ssh-2.png" alt-text="A screenshot showing the commands to run in the SSH shell and their output.":::
452452
@@ -481,7 +481,7 @@ In this step, you use the SSH connection to the app container to verify the JNDI
481481
482482
## 6. Browse to the app
483483
484-
1. In the azd output, find the URL of your app and navigate to it in the browser. The URL looks like this in the AZD output:
484+
1. In the AZD output, find the URL of your app and navigate to it in the browser. The URL looks like this in the AZD output:
485485
486486
<pre>
487487
Deploying services (azd deploy)
@@ -498,13 +498,13 @@ In this step, you use the SSH connection to the app container to verify the JNDI
498498
499499
## 7. Stream diagnostic logs
500500
501-
Azure App Service can capture console logs to help you diagnose issues with your application. For convenience, the azd template already [enabled logging to the local file system](troubleshoot-diagnostic-logs.md#enable-application-logging-linuxcontainer) and is [shipping the logs to a Log Analytics workspace](troubleshoot-diagnostic-logs.md#send-logs-to-azure-monitor).
501+
Azure App Service can capture console logs to help you diagnose issues with your application. For convenience, the AZD template already [enabled logging to the local file system](troubleshoot-diagnostic-logs.md#enable-application-logging-linuxcontainer) and is [shipping the logs to a Log Analytics workspace](troubleshoot-diagnostic-logs.md#send-logs-to-azure-monitor).
502502
503-
The sample application includes standard Log4j logging statements to demonstrate this capability as shown below.
503+
The sample application includes standard Log4j logging statements to demonstrate this capability, as shown in the following snippet:
504504
505505
:::code language="java" source="~/msdocs-tomcat-mysql-sample-app/src/main/java/com/microsoft/azure/appservice/examples/tomcatmysql/ViewServlet.java" range="17-26" highlight="3,8":::
506506
507-
In the azd output, find the link to stream App Service logs and navigate to it in the browser. The link looks like this in the azd output:
507+
In the AZD output, find the link to stream App Service logs and navigate to it in the browser. The link looks like this in the AZD output:
508508
509509
<pre>
510510
Stream App Service logs at: https://portal.azure.com/#@/resource/subscriptions/&lt;subscription-guid>/resourceGroups/&lt;group-name>/providers/Microsoft.Web/sites/&lt;app-name>/logStream
@@ -535,19 +535,19 @@ You can ignore the warnings. The Maven Jetty plugin shows the warnings because t
535535
536536
#### The portal deployment view for Azure Database for MySQL Flexible Server shows a Conflict status
537537
538-
Depending on your subscription and the region you select, you may see the deployment status for Azure Database for MySQL Flexible Server to be `Conflict`, with the following message in Operation details:
538+
Depending on your subscription and the region you select, you might see the deployment status for Azure Database for MySQL Flexible Server to be `Conflict`, with the following message in Operation details:
539539
540540
`InternalServerError: An unexpected error occured while processing the request.`
541541
542-
This is most likely because there's a limit on your subscription for the region you select. Try choosing a different region for your deployment.
542+
This error is most likely caused by a limit on your subscription for the region you select. Try choosing a different region for your deployment.
543543
544544
#### The deployed sample app doesn't show the tasks list app
545545
546546
If you see a `Hey, Java developers!` page instead of the tasks list app, App Service is most likely still loading the updated container from your most recent code deployment. Wait a few minutes and refresh the page.
547547
548548
#### I see a 404 Page Not Found error in the deployed sample app
549549
550-
Make sure that you made the code changes to use the `java:comp/env/jdbc/AZURE_MYSQL_CONNECTIONSTRING_DS` data source. If you have made the changes and have redeployed your code, App Service is most likely still loading the updated container. Wait a few minutes and refresh the page.
550+
Make sure that you made the code changes to use the `java:comp/env/jdbc/AZURE_MYSQL_CONNECTIONSTRING_DS` data source. If you made the changes and redeployed your code, App Service is most likely still loading the updated container. Wait a few minutes and refresh the page.
551551
552552
## Frequently asked questions
553553
@@ -567,8 +567,8 @@ Pricing for the created resources is as follows:
567567
568568
#### How do I connect to the MySQL server behind the virtual network with other tools?
569569
570-
- The Tomcat container currently doesn't have the `mysql-client` terminal too. If you want, you must manually install it. Note that anything you install won't persist across app restart.
571-
- To connect from a desktop tool like MySQL Workbench, your machine must be within the virtual network. For example, it could be an Azure VM that's connected to one of the subnets, or a machine in an on-premises network that has a [site-to-site VPN](../vpn-gateway/vpn-gateway-about-vpngateways.md) connection with the Azure virtual network.
570+
- The Tomcat container currently doesn't have the `mysql-client` terminal too. If you want, you must manually install it. Note that anything you install doesn't persist across app restarts.
571+
- To connect from a desktop tool like MySQL Workbench, your machine must be within the virtual network. For example, it could be an Azure VM in one of the subnets, or a machine in an on-premises network that has a [site-to-site VPN](../vpn-gateway/vpn-gateway-about-vpngateways.md) connection with the Azure virtual network.
572572
- You can also [integrate Azure Cloud Shell](../cloud-shell/private-vnet.md) with the virtual network.
573573
574574
#### How does local app development work with GitHub Actions?

0 commit comments

Comments
 (0)