Skip to content

Commit 7f4c44f

Browse files
authored
Merge pull request #210601 from SteveSaunders1952/v-ssaunders-moarychan
how-to-bind-cosmos editorial pass
2 parents b052dd9 + 522a966 commit 7f4c44f

File tree

3 files changed

+38
-24
lines changed

3 files changed

+38
-24
lines changed

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

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@ ms.custom: devx-track-java, event-tier1-build-2022
2020

2121
Instead of manually configuring your Spring Boot applications, you can automatically bind select Azure services to your applications by using Azure Spring Apps. This article demonstrates how to bind your application to an Azure Cosmos DB database.
2222

23-
Prerequisites:
23+
## Prerequisites
2424

25-
* A deployed Azure Spring Apps instance. Follow our [quickstart on deploying via the Azure CLI](./quickstart.md) to get started.
26-
* An Azure Cosmos DB account with a minimum permission level of Contributor.
25+
* A deployed Azure Spring Apps instance.
26+
* An Azure Cache for Redis service instance.
27+
* The Azure Spring Apps extension for the Azure CLI.
28+
29+
If you don't have a deployed Azure Spring Apps instance, follow the steps in the [Quickstart: Deploy your first application to Azure Spring Apps](./quickstart.md).
2730

2831
## Prepare your Java project
2932

@@ -34,8 +37,8 @@ Prerequisites:
3437
```xml
3538
<dependency>
3639
<groupId>com.azure.spring</groupId>
37-
<artifactId>azure-spring-boot-starter-cosmos</artifactId>
38-
<version>3.6.0</version>
40+
<artifactId>spring-cloud-azure-starter-data-cosmos</artifactId>
41+
<version>4.3.0</version>
3942
</dependency>
4043
```
4144

@@ -61,9 +64,9 @@ Prerequisites:
6164

6265
```xml
6366
<dependency>
64-
<groupId>com.microsoft.azure</groupId>
65-
<artifactId>azure-storage-spring-boot-starter</artifactId>
66-
<version>2.0.5</version>
67+
<groupId>com.azure.spring</groupId>
68+
<artifactId>spring-cloud-azure-starter-storage-blob</artifactId>
69+
<version>4.3.0</version>
6770
</dependency>
6871
```
6972

@@ -72,6 +75,7 @@ Prerequisites:
7275
## Bind your app to the Azure Cosmos DB
7376

7477
#### [Service Binding](#tab/Service-Binding)
78+
7579
Azure Cosmos DB has five different API types that support binding. The following procedure shows how to use them:
7680

7781
1. Create an Azure Cosmos DB database. Refer to the quickstart on [creating a database](../cosmos-db/create-cosmosdb-resources-portal.md) for help.
@@ -94,13 +98,14 @@ Azure Cosmos DB has five different API types that support binding. The following
9498
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:
9599

96100
```properties
97-
azure.cosmosdb.uri=https://<some account>.documents.azure.com:443
98-
azure.cosmosdb.key=abc******
99-
azure.cosmosdb.database=testdb
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
100104
```
101105

102106
#### [Terraform](#tab/Terraform)
103-
The following Terraform script shows how to set up an Azure Spring Apps app with Azure Cosmos DB MongoDB API.
107+
108+
The following Terraform script shows how to set up an Azure Spring Apps app with an Azure Cosmos DB account.
104109

105110
```terraform
106111
provider "azurerm" {
@@ -123,7 +128,7 @@ resource "azurerm_cosmosdb_account" "cosmosdb" {
123128
resource_group_name = azurerm_resource_group.example.name
124129
location = azurerm_resource_group.example.location
125130
offer_type = "Standard"
126-
kind = "MongoDB"
131+
kind = "GlobalDocumentDB"
127132

128133
consistency_policy {
129134
consistency_level = "Session"
@@ -135,7 +140,7 @@ resource "azurerm_cosmosdb_account" "cosmosdb" {
135140
}
136141
}
137142

138-
resource "azurerm_cosmosdb_mongo_database" "cosmosdb" {
143+
resource "azurerm_cosmosdb_sql_database" "cosmosdb" {
139144
name = "cosmos-${var.application_name}-001"
140145
resource_group_name = azurerm_cosmosdb_account.cosmosdb.resource_group_name
141146
account_name = azurerm_cosmosdb_account.cosmosdb.name
@@ -158,15 +163,18 @@ resource "azurerm_spring_cloud_app" "example" {
158163
resource "azurerm_spring_cloud_java_deployment" "example" {
159164
name = "default"
160165
spring_cloud_app_id = azurerm_spring_cloud_app.example.id
161-
cpu = 2
162-
memory_in_gb = 4
166+
quota {
167+
cpu = "2"
168+
memory = "4Gi"
169+
}
163170
instance_count = 2
164171
jvm_options = "-XX:+PrintGC"
165172
runtime_version = "Java_11"
166173

167174
environment_variables = {
168-
"azure.cosmosdb.uri" : azurerm_cosmosdb_account.cosmosdb.connection_strings[0]
169-
"azure.cosmosdb.database" : azurerm_cosmosdb_mongo_database.cosmosdb.name
175+
"spring.cloud.azure.cosmos.endpoint" : azurerm_cosmosdb_account.cosmosdb.endpoint
176+
"spring.cloud.azure.cosmos.key" : azurerm_cosmosdb_account.cosmosdb.primary_key
177+
"spring.cloud.azure.cosmos.database" : azurerm_cosmosdb_sql_database.cosmosdb.name
170178
}
171179
}
172180

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ With Azure Spring Apps, you can bind select Azure services to your applications
2626
* An Azure Database for MySQL account
2727
* Azure CLI
2828

29-
If you don't have a deployed Azure Spring Apps instance, follow the instructions in [Quickstart: Launch an application in Azure Spring Apps by using the Azure portal](./quickstart.md) to deploy your first Spring app.
29+
If you don't have a deployed Azure Spring Apps instance, follow the instructions in [Quickstart: Deploy your first application to Azure Spring Apps](./quickstart.md) to deploy your first Spring app.
3030

3131
## Prepare your Java project
3232

@@ -46,6 +46,7 @@ If you don't have a deployed Azure Spring Apps instance, follow the instructions
4646
## Bind your app to the Azure Database for MySQL instance
4747

4848
#### [Service Binding](#tab/Service-Binding)
49+
4950
1. Note the admin username and password of your Azure Database for MySQL account.
5051

5152
1. Connect to the server, create a database named **testdb** from a MySQL client, and then create a new non-admin account.
@@ -153,8 +154,10 @@ resource "azurerm_spring_cloud_app" "example" {
153154
resource "azurerm_spring_cloud_java_deployment" "example" {
154155
name = "default"
155156
spring_cloud_app_id = azurerm_spring_cloud_app.example.id
156-
cpu = 2
157-
memory_in_gb = 4
157+
quota {
158+
cpu = "2"
159+
memory = "4Gi"
160+
}
158161
instance_count = 2
159162
jvm_options = "-XX:+PrintGC"
160163
runtime_version = "Java_11"

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Instead of manually configuring your Spring Boot applications, you can automatic
2626
* An Azure Cache for Redis service instance
2727
* The Azure Spring Apps extension for the Azure CLI
2828

29-
If you don't have a deployed Azure Spring Apps instance, follow the steps in the [quickstart on deploying an Azure Spring Apps app](./quickstart.md).
29+
If you don't have a deployed Azure Spring Apps instance, follow the steps in the [Quickstart: Deploy your first application to Azure Spring Apps](./quickstart.md).
3030

3131
## Prepare your Java project
3232

@@ -46,6 +46,7 @@ If you don't have a deployed Azure Spring Apps instance, follow the steps in the
4646
## Bind your app to the Azure Cache for Redis
4747

4848
#### [Service Binding](#tab/Service-Binding)
49+
4950
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.
5051

5152
1. Select **Service binding** and select **Create service binding**. Fill out the form, being sure to select the **Binding type** value **Azure Cache for Redis**, your Azure Cache for Redis server, and the **Primary** key option.
@@ -109,8 +110,10 @@ resource "azurerm_spring_cloud_app" "example" {
109110
resource "azurerm_spring_cloud_java_deployment" "example" {
110111
name = "default"
111112
spring_cloud_app_id = azurerm_spring_cloud_app.example.id
112-
cpu = 2
113-
memory_in_gb = 4
113+
quota {
114+
cpu = "2"
115+
memory = "4Gi"
116+
}
114117
instance_count = 2
115118
jvm_options = "-XX:+PrintGC"
116119
runtime_version = "Java_11"

0 commit comments

Comments
 (0)