Skip to content

Commit 0c7f5f7

Browse files
Merge pull request #218003 from KarlErickson/karler-maud
edits for "Update Spring Apps + Cosmos DB, MySQL, Redis"
2 parents 2b0c260 + a82e24a commit 0c7f5f7

File tree

3 files changed

+168
-75
lines changed

3 files changed

+168
-75
lines changed

articles/spring-apps/how-to-bind-cosmos.md

Lines changed: 87 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Learn how to bind Azure Cosmos DB to your application in Azure Spri
44
author: karlerickson
55
ms.service: spring-apps
66
ms.topic: how-to
7-
ms.date: 10/06/2019
7+
ms.date: 11/09/2022
88
ms.author: karler
99
ms.custom: devx-track-java, event-tier1-build-2022, ignite-2022
1010
---
@@ -32,49 +32,95 @@ If you don't have a deployed Azure Spring Apps instance, follow the steps in the
3232

3333
1. Add one of the following dependencies to your application's pom.xml pom.xml file. Choose the dependency that is appropriate for your API type.
3434

35-
* API type: NoSQL
35+
* API type: NoSQL
3636

37-
```xml
38-
<dependency>
39-
<groupId>com.azure.spring</groupId>
40-
<artifactId>spring-cloud-azure-starter-data-cosmos</artifactId>
41-
<version>4.3.0</version>
42-
</dependency>
43-
```
37+
```xml
38+
<dependency>
39+
<groupId>com.azure.spring</groupId>
40+
<artifactId>spring-cloud-azure-starter-data-cosmos</artifactId>
41+
<version>4.3.0</version>
42+
</dependency>
43+
```
4444

45-
* API type: MongoDB
45+
* API type: MongoDB
4646

47-
```xml
48-
<dependency>
49-
<groupId>org.springframework.boot</groupId>
50-
<artifactId>spring-boot-starter-data-mongodb</artifactId>
51-
</dependency>
52-
```
47+
```xml
48+
<dependency>
49+
<groupId>org.springframework.boot</groupId>
50+
<artifactId>spring-boot-starter-data-mongodb</artifactId>
51+
</dependency>
52+
```
5353

54-
* API type: Cassandra
54+
* API type: Cassandra
5555

56-
```xml
57-
<dependency>
58-
<groupId>org.springframework.boot</groupId>
59-
<artifactId>spring-boot-starter-data-cassandra</artifactId>
60-
</dependency>
61-
```
56+
```xml
57+
<dependency>
58+
<groupId>org.springframework.boot</groupId>
59+
<artifactId>spring-boot-starter-data-cassandra</artifactId>
60+
</dependency>
61+
```
6262

63-
* API type: Azure Table
63+
* API type: Azure Table
6464

65-
```xml
66-
<dependency>
67-
<groupId>com.azure.spring</groupId>
68-
<artifactId>spring-cloud-azure-starter-storage-blob</artifactId>
69-
<version>4.3.0</version>
70-
</dependency>
71-
```
65+
```xml
66+
<dependency>
67+
<groupId>com.azure.spring</groupId>
68+
<artifactId>spring-cloud-azure-starter-storage-blob</artifactId>
69+
<version>4.3.0</version>
70+
</dependency>
71+
```
7272

7373
1. Update the current app by running `az spring app deploy`, or create a new deployment for this change by running `az spring app deployment create`.
7474

7575
## Bind your app to the Azure Cosmos DB
7676

77-
#### [Service Binding](#tab/Service-Binding)
77+
### [Service Connector](#tab/Service-Connector)
78+
79+
1. Use the Azure CLI to configure your Spring app to connect to a Cosmos SQL Database with a system-assigned managed identity by using the `az spring connection create` command, as shown in the following example.
80+
81+
> [!NOTE]
82+
> Updating Azure Cosmos DB database settings can take a few minutes to complete.
83+
84+
```azurecli
85+
az spring connection create cosmos-sql \
86+
--resource-group $AZURE_SPRING_APPS_RESOURCE_GROUP \
87+
--service $AZURE_SPRING_APPS_SERVICE_INSTANCE_NAME \
88+
--app $APP_NAME \
89+
--deployment $DEPLOYMENT_NAME \
90+
--target-resource-group $COSMOSDB_RESOURCE_GROUP \
91+
--account $COSMOSDB_ACCOUNT_NAME \
92+
--database $DATABASE_NAME \
93+
--system-assigned-identity
94+
```
95+
96+
> [!NOTE]
97+
> If you're using [Service Connector](../service-connector/overview.md) for the first time, start by running the command `az provider register --namespace Microsoft.ServiceLinker` to register the Service Connector resource provider.
98+
>
99+
> If you're using Cosmos Cassandra, use a `--key_space` instead of `--database`.
100+
101+
> [!TIP]
102+
> Run the command `az spring connection list-support-types --output table` to get a list of supported target services and authentication methods for Azure Spring Apps. If the `az spring` command isn't recognized by the system, check that you have installed the required extension by running `az extension add --name spring`.
103+
104+
1. Alternately, you can use the Azure portal to configure this connection by completing the following steps. The Azure portal provides the same capabilities as the Azure CLI and provides an interactive experience.
105+
106+
1. Select your Azure Spring Apps instance in the Azure portal and select **Apps** from the navigation menu. Choose the app you want to connect and select **Service Connector** on the navigation menu.
107+
108+
1. Select **Create**.
109+
110+
1. On the **Basics** tab, for service type, select Cosmos DB, then choose a subscription. For API type, select Core (SQL), choose a Cosmos DB account, and a database. For client type, select Java, then select **Next: Authentication**. If you haven't created your database yet, see [Quickstart: Create an Azure Cosmos DB account, database, container, and items from the Azure portal](../cosmos-db/nosql/quickstart-portal.md).
111+
112+
1. On the **Authentication** tab, choose **Connection string**. Service Connector automatically retrieves the access key from your Cosmos DB account. Select **Next: Networking**.
113+
114+
1. On the **Networking** tab, select **Configure firewall rules to enable access to target service**, then select **Next: Review + Create**.
115+
116+
1. On the **Review + Create** tab, wait for the validation to pass and then select **Create**. The creation can take a few minutes to complete.
117+
118+
1. Once the connection between your Spring apps and your Cosmos DB database has been generated, you can see it in the Service Connector page and select the unfold button to view the configured connection variables.
119+
120+
### [Service Binding](#tab/Service-Binding)
121+
122+
> [!NOTE]
123+
> We recommend using Service Connector instead of Service Binding to connect your app to your database. Service Binding is going to be deprecated in favor of Service Connector. For instructions, see the Service Connector tab.
78124
79125
Azure Cosmos DB has five different API types that support binding. The following procedure shows how to use them:
80126

@@ -85,25 +131,26 @@ Azure Cosmos DB has five different API types that support binding. The following
85131
1. Go to your Azure Spring Apps service page in the Azure portal. Go to **Application Dashboard** and select the application to bind to Azure Cosmos DB. This application is the same one you updated or deployed in the previous step.
86132

87133
1. Select **Service binding**, and select **Create service binding**. To fill out the form, select:
134+
88135
* The **Binding type** value **Azure Cosmos DB**.
89136
* The API type.
90137
* Your database name.
91138
* The Azure Cosmos DB account.
92139

93-
> [!NOTE]
94-
> If you are using Cassandra, use a key space for the database name.
140+
> [!NOTE]
141+
> If you are using Cassandra, use a key space for the database name.
95142
96143
1. Restart the application by selecting **Restart** on the application page.
97144

98145
1. To ensure the service is bound correctly, select the binding name and verify its details. The `property` field should be similar to this example:
99146

100-
```properties
101-
spring.cloud.azure.cosmos.endpoint=https://<some account>.documents.azure.com:443
102-
spring.cloud.azure.cosmos.key=abc******
103-
spring.cloud.azure.cosmos.database=testdb
104-
```
147+
```properties
148+
spring.cloud.azure.cosmos.endpoint=https://<some account>.documents.azure.com:443
149+
spring.cloud.azure.cosmos.key=abc******
150+
spring.cloud.azure.cosmos.database=testdb
151+
```
105152

106-
#### [Terraform](#tab/Terraform)
153+
### [Terraform](#tab/Terraform)
107154

108155
The following Terraform script shows how to set up an Azure Spring Apps app with an Azure Cosmos DB account.
109156

articles/spring-apps/how-to-bind-mysql.md

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Learn how to bind an Azure Database for MySQL instance to your appl
44
author: karlerickson
55
ms.service: spring-apps
66
ms.topic: how-to
7-
ms.date: 09/26/2022
7+
ms.date: 11/09/2022
88
ms.author: karler
99
ms.custom: devx-track-java, event-tier1-build-2022, passwordless-java
1010
---
@@ -47,7 +47,26 @@ With Azure Spring Apps, you can bind select Azure services to your applications
4747

4848
## Bind your app to the Azure Database for MySQL instance
4949

50-
#### [Service Binding](#tab/Service-Binding)
50+
### [Service Connector](#tab/Service-Connector)
51+
52+
To configure your Spring app to connect to an Azure Database for MySQL Flexible Server with a system-assigned managed identity, use the `az spring connection create` command, as shown in the following example.
53+
54+
```azurecli
55+
az spring connection create mysql-flexible \
56+
--resource-group $AZURE_SPRING_APPS_RESOURCE_GROUP \
57+
--service $AZURE_SPRING_APPS_SERVICE_INSTANCE_NAME \
58+
--app $APP_NAME \
59+
--deployment $DEPLOYMENT_NAME \
60+
--target-resource-group $MYSQL_RESOURCE_GROUP \
61+
--server $MYSQL_SERVER_NAME \
62+
--database $DATABASE_NAME \
63+
--system-assigned-identity
64+
```
65+
66+
### [Service Binding](#tab/Service-Binding)
67+
68+
> [!NOTE]
69+
> We recommend using Service Connector instead of Service Binding to connect your app to your database. Service Binding is going to be deprecated in favor of Service Connector. For instructions, see the Service Connector tab.
5170
5271
1. Note the admin username and password of your Azure Database for MySQL account.
5372

@@ -70,23 +89,7 @@ With Azure Spring Apps, you can bind select Azure services to your applications
7089
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
7190
```
7291

73-
#### [Passwordless connection using a managed identity](#tab/Passwordless)
74-
75-
Configure your Spring app to connect to a MySQL Database Flexible Server with a system-assigned managed identity by using the `az spring connection create` command, as shown in the following example.
76-
77-
```azurecli
78-
az spring connection create mysql-flexible \
79-
--resource-group $AZURE_SPRING_APPS_RESOURCE_GROUP \
80-
--service $AZURE_SPRING_APPS_SERVICE_INSTANCE_NAME \
81-
--app $APP_NAME \
82-
--deployment $DEPLOYMENT_NAME \
83-
--target-resource-group $MYSQL_RESOURCE_GROUP \
84-
--server $MYSQL_SERVER_NAME \
85-
--database $DATABASE_NAME \
86-
--system-assigned-identity
87-
```
88-
89-
#### [Terraform](#tab/Terraform)
92+
### [Terraform](#tab/Terraform)
9093

9194
The following Terraform script shows how to set up an Azure Spring Apps app with Azure Database for MySQL.
9295

articles/spring-apps/how-to-bind-redis.md

Lines changed: 59 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,65 @@ If you don't have a deployed Azure Spring Apps instance, follow the steps in the
3030

3131
## Prepare your Java project
3232

33-
1. Add the following dependency to your project's pom.xml file:
33+
1. Add the following dependency to your project's *pom.xml* file:
3434

35-
```xml
36-
<dependency>
37-
<groupId>org.springframework.boot</groupId>
38-
<artifactId>spring-boot-starter-data-redis-reactive</artifactId>
39-
</dependency>
40-
```
35+
```xml
36+
<dependency>
37+
<groupId>org.springframework.boot</groupId>
38+
<artifactId>spring-boot-starter-data-redis-reactive</artifactId>
39+
</dependency>
40+
```
4141

42-
1. Remove any `spring.redis.*` properties from the `application.properties` file
42+
1. Remove any `spring.redis.*` properties from the *application.properties* file
4343

4444
1. Update the current deployment using `az spring app update` or create a new deployment using `az spring app deployment create`.
4545

4646
## Bind your app to the Azure Cache for Redis
4747

48-
#### [Service Binding](#tab/Service-Binding)
48+
### [Service Connector](#tab/Service-Connector)
49+
50+
1. Use the Azure CLI to configure your Spring app to connect to a Redis database with an access key using the `az spring connection create` command, as shown in the following example.
51+
52+
```azurecli
53+
az spring connection create redis \
54+
--resource-group $AZURE_SPRING_APPS_RESOURCE_GROUP \
55+
--service $AZURE_SPRING_APPS_SERVICE_INSTANCE_NAME \
56+
--app $APP_NAME \
57+
--deployment $DEPLOYMENT_NAME \
58+
--target-resource-group $REDIS_RESOURCE_GROUP \
59+
--server $REDIS_SERVER_NAME\
60+
--database $REDIS_DATABASE_NAME \
61+
--secret
62+
```
63+
64+
> [!NOTE]
65+
> If you're using [Service Connector](../service-connector/overview.md) for the first time, start by running the command `az provider register --namespace Microsoft.ServiceLinker` to register the Service Connector resource provider.
66+
>
67+
> If you're using Redis Enterprise, use the `az spring connection create redis-enterprise` command instead.
68+
69+
> [!TIP]
70+
> Run the command `az spring connection list-support-types --output table` to get a list of supported target services and authentication methods for Azure Spring Apps. If the `az spring` command isn't recognized by the system, check that you have installed the required extension by running `az extension add --name spring`.
71+
72+
1. Alternately, you can use the Azure portal to configure this connection by completing the following steps. The Azure portal provides the same capabilities as the Azure CLI and provides an interactive experience.
73+
74+
1. Select your Azure Spring Apps instance in the Azure portal and then select **Apps** from the navigation menu. Choose the app you want to connect and then select **Service Connector** on the navigation menu.
75+
76+
1. Select **Create**.
77+
78+
1. On the **Basics** tab, for service type, select Cache for Redis. Choose a subscription and a Redis cache server. Fill in the Redis database name ("0" in this example) and under client type, select Java. Select **Next: Authentication**.
79+
80+
1. On the **Authentication** tab, choose **Connection string**. Service Connector will automatically retrieve the access key from your Redis database account. Select **Next: Networking**.
81+
82+
1. On the **Networking** tab, select **Configure firewall rules to enable access to target service**, then select **Review + Create**.
83+
84+
1. On the **Review + Create** tab, wait for the validation to pass and then select **Create**. The creation can take a few minutes to complete.
85+
86+
1. Once the connection between your Spring app your Redis database has been generated, you can see it in the Service Connector page and select the unfold button to view the configured connection variables.
87+
88+
### [Service Binding](#tab/Service-Binding)
89+
90+
> [!NOTE]
91+
> We recommend using Service Connector instead of Service Binding to connect your app to your database. Service Binding is going to be deprecated in favor of Service Connector. For instructions, see the Service Connector tab.
4992
5093
1. Go to your Azure Spring Apps service page in the Azure portal. Go to **Application Dashboard** and select the application to bind to Azure Cache for Redis. This application is the same one you updated or deployed in the previous step.
5194

@@ -55,14 +98,14 @@ If you don't have a deployed Azure Spring Apps instance, follow the steps in the
5598

5699
1. To ensure the service binding is correct, select the binding name and verify its details. The `property` field should look like this:
57100

58-
```properties
59-
spring.redis.host=some-redis.redis.cache.windows.net
60-
spring.redis.port=6380
61-
spring.redis.password=abc******
62-
spring.redis.ssl=true
63-
```
101+
```properties
102+
spring.redis.host=some-redis.redis.cache.windows.net
103+
spring.redis.port=6380
104+
spring.redis.password=abc******
105+
spring.redis.ssl=true
106+
```
64107

65-
#### [Terraform](#tab/Terraform)
108+
### [Terraform](#tab/Terraform)
66109

67110
The following Terraform script shows how to set up an Azure Spring Apps app with Azure Cache for Redis.
68111

0 commit comments

Comments
 (0)