You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pet Clinic, as deployed in the default configuration [Quickstart: Build and deploy apps to Azure Spring Apps](quickstart-deploy-apps.md), uses an in-memory database (HSQLDB) that is populated with data at startup. This quickstart explains how to provision and prepare an Azure Database for MySQL instance and then configure Pet Clinic on Azure Spring Apps to use it as a persistent database with only one command.
19
+
Pet Clinic, as deployed in the default configuration [Quickstart: Build and deploy apps to Azure Spring Apps](./quickstart-deploy-apps.md), uses an in-memory database (HSQLDB) that is populated with data at startup. This quickstart explains how to provision and prepare an Azure Database for MySQL instance and then configure Pet Clinic on Azure Spring Apps to use it as a persistent database.
20
20
21
21
## Prerequisites
22
22
23
23
An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free).
24
24
25
-
## Prepare an Azure Database for MySQL instance
25
+
## Create an Azure Database for MySQL instance
26
26
27
-
1.Create an Azure Database for MySQL flexible server using the [az mysql flexible-server create](/cli/azure/mysql/flexible-server#az-mysql-flexible-server-create) command. Replace the placeholders `<database-name>`, `<resource-group-name>`, `<MySQL-flexible-server-name>`, `<admin-username>`, and `<admin-password>` with a name for your new database, the name of your resource group, a name for your new server, and an admin username and password. Use single quotes around the value for `admin-password`.
27
+
Create an Azure Database for MySQL flexible server using the [az mysql flexible-server create](/cli/azure/mysql/flexible-server#az-mysql-flexible-server-create) command. Replace the placeholders `<database-name>`, `<resource-group-name>`, `<MySQL-flexible-server-name>`, `<admin-username>`, and `<admin-password>` with a name for your new database, the name of your resource group, a name for your new server, and an admin username and password. Use single quotes around the value for `admin-password`.
28
28
29
-
```azurecli-interactive
30
-
az mysql flexible-server create \
31
-
--resource-group <resource-group-name> \
32
-
--name <MySQL-flexible-server-name> \
33
-
--database-name <database-name> \
34
-
--public-access 0.0.0.0 \
35
-
--admin-user <admin-username> \
36
-
--admin-password '<admin-password>'
37
-
```
29
+
```azurecli-interactive
30
+
az mysql flexible-server create \
31
+
--resource-group <resource-group-name> \
32
+
--name <MySQL-flexible-server-name> \
33
+
--database-name <database-name> \
34
+
--public-access 0.0.0.0 \
35
+
--admin-user <admin-username> \
36
+
--admin-password '<admin-password>'
37
+
```
38
38
39
-
> [!NOTE]
40
-
> The `Standard_B1ms` SKU is used by default. For pricing details, see [Azure Database for MySQL pricing](https://azure.microsoft.com/pricing/details/mysql/flexible-server/).
39
+
> [!NOTE]
40
+
> The `Standard_B1ms` SKU is used by default. For pricing details, see [Azure Database for MySQL pricing](https://azure.microsoft.com/pricing/details/mysql/flexible-server/).
41
41
42
-
> [!TIP]
43
-
> The password should be at least eight characters long and contain at least one English uppercase letter, one English lowercase letter, one number, and one non-alphanumeric character (!, $, #, %, and so on.).
42
+
> [!TIP]
43
+
> The password should be at least eight characters long and contain at least one English uppercase letter, one English lowercase letter, one number, and one non-alphanumeric character (!, $, #, %, and so on.).
44
44
45
45
## Connect your application to the MySQL database
46
46
@@ -57,7 +57,7 @@ Use [Service Connector](../service-connector/overview.md) to connect the app hos
57
57
az provider register --namespace Microsoft.ServiceLinker
58
58
```
59
59
60
-
1. Run the `az spring connection create` command to create a service connection between Azure Spring Apps and the Azure MySQL database. Replace the placeholders below with your own information. Use single quotes around the value for MySQL server `secret`.
60
+
1. Run the `az spring connection create` command to create a service connection between the `customers-service` app and the Azure MySQL database. Replace the placeholders for the following settings with your own information. Use single quotes around the value for MySQL server `secret`.
@@ -85,10 +85,10 @@ Use [Service Connector](../service-connector/overview.md) to connect the app hos
85
85
> [!TIP]
86
86
> If the `az spring` command isn't recognized by the system, check that you have installed the Azure Spring Apps extension by running `az extension add --name spring`.
87
87
88
-
### [Portal](#tab/azure-portal)
88
+
### [Azure portal](#tab/azure-portal)
89
89
90
90
1. In the Azure portal, type the name of your Azure Spring Apps instance in the search box at the top of the screen and select your instance.
91
-
1. Under **Settings**, select **Apps** and select the application from the list.
91
+
1. Under **Settings**, select **Apps**, and then select the`customers-service` application from the list.
92
92
1. Select **Service Connector** from the left table of contents and select **Create**.
93
93
94
94
:::image type="content" source="./media\quickstart-integrate-azure-database-mysql\create-service-connection.png" alt-text="Screenshot of the Azure portal, in the Azure Spring Apps instance, create a connection with Service Connector.":::
@@ -114,17 +114,19 @@ Use [Service Connector](../service-connector/overview.md) to connect the app hos
114
114
115
115
---
116
116
117
+
Repeat these steps to create connections for the `customers-service`, `vets-service`, and `visits-service` applications.
118
+
117
119
## Check connection to MySQL database
118
120
119
121
### [Azure CLI](#tab/azure-cli)
120
122
121
-
Run the `az spring connection validate` command to show the status of the connection between Azure Spring Apps and the Azure MySQL database. Replace the placeholders below with your own information.
123
+
Run the `az spring connection validate` command to show the status of the connection between the `customers-service` app and the Azure MySQL database. Replace the placeholders with your own information.
Use the following steps to set an environment variable to activate the `mysql` profile for the `customers-service` app:
176
+
177
+
1. Go to the Azure Spring Apps instance overview page, select **Apps** from the navigation menu, and then select the **customers-service** application from the list.
178
+
179
+
1. On the **customers-service Overview** page, select **Configuration** from the navigation menu.
180
+
181
+
1. On the **Configuration** page, select **Environment variables**. Enter `SPRING_PROFILES_ACTIVE` for **Key**, enter `mysql` for **Value**, and then select **Save**.
182
+
183
+
:::image type="content" source="media/quickstart-integrate-azure-database-mysql/customers-service-app-configuration.png" alt-text="Screenshot of the Azure portal showing the configuration settings for the customers-service app." lightbox="media/quickstart-integrate-azure-database-mysql/customers-service-app-configuration.png":::
184
+
185
+
---
186
+
187
+
Repeat these instructions to update app configuration for the `customers-service`, `vets-service`, and `visits-service` applications.
188
+
189
+
## Validate the apps
190
+
191
+
To validate the Pet Clinic service and to query records from the MySQL database to confirm the database connection, follow the instructions in the [Verify the services](./quickstart-deploy-apps.md?pivots=programming-language-java#verify-the-services) section of [Quickstart: Build and deploy apps to Azure Spring Apps](quickstart-deploy-apps.md).
192
+
153
193
## Clean up resources
154
194
155
195
If you plan to continue working with subsequent quickstarts and tutorials, you might want to leave these resources in place. When no longer needed, delete the resource group by using the [az group delete](/cli/azure/group#az-group-delete) command, which deletes the resources in the resource group. Replace `<resource-group>` with the name of your resource group.
@@ -160,5 +200,5 @@ az group delete --name <resource-group>
160
200
161
201
## Next steps
162
202
163
-
*[Bind an Azure Database for MySQL instance to your application in Azure Spring Apps](how-to-bind-mysql.md)
203
+
*[Bind an Azure Database for MySQL instance to your application in Azure Spring Apps](./how-to-bind-mysql.md)
164
204
*[Use a managed identity to connect Azure SQL Database to an app in Azure Spring Apps](./connect-managed-identity-to-azure-sql.md)
0 commit comments