Skip to content

Commit e1ff885

Browse files
committed
improve
1 parent 0ee7990 commit e1ff885

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

articles/cosmos-db/nosql/quickstart-java-spring-data.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ You may read more about databases, containers and items [here.](../account-datab
5656

5757
The provisioned throughput is measured in Request Units (*RUs*) which have a monetary price and are a substantial determining factor in the operating cost of the account. Provisioned throughput can be selected at per-container granularity or per-database granularity, however container-level throughput specification is typically preferred. You may read more about throughput provisioning [here.](../set-throughput.md)
5858

59-
As items are inserted into an Azure Cosmos DB container, the database grows horizontally by adding more storage and compute to handle requests. Storage and compute capacity are added in discrete units known as *partitions*, and you must choose one field in your documents to be the partition key which maps each document to a partition. The way partitions are managed is that each partition is assigned a roughly equal slice out of the range of partition key values; therefore you're advised to choose a partition key which is relatively random or evenly distributed. Otherwise, some partitions will see substantially more requests (*hot partition*) while other partitions see substantially fewer requests (*cold partition*), and this is to be avoided. You may learn more about partitioning [here](../partitioning-overview.md).
59+
As items are inserted into an Azure Cosmos DB container, the database grows horizontally by adding more storage and compute to handle requests. Storage and compute capacity are added in discrete units known as *partitions*, and you must choose one field in your documents to be the partition key, which maps each document to a partition. The way partitions are managed is that each partition is assigned a roughly equal slice out of the range of partition key values; therefore you're advised to choose a partition key, which is relatively random or evenly distributed. Otherwise, some partitions see substantially more requests (*hot partition*) while other partitions see substantially fewer requests (*cold partition*), and this is to be avoided. You may learn more about partitioning [here](../partitioning-overview.md).
6060

6161
## Create a database account
6262

@@ -79,7 +79,7 @@ Before you can create a document database, you need to create an API for NoSQL a
7979

8080
## Clone the sample application
8181

82-
Now let's switch to working with code. Let's clone an API for NoSQL app from GitHub, set the connection string, and run it. You'll see how easy it is to work with data programmatically.
82+
Now let's switch to working with code. Let's clone an API for NoSQL app from GitHub, set the connection string, and run it. You see how easy it is to work with data programmatically.
8383

8484
Run the following command to clone the sample repository. This command creates a copy of the sample app on your computer.
8585

@@ -91,16 +91,20 @@ git clone https://github.com/Azure-Samples/azure-spring-boot-samples.git
9191

9292
This step is optional. If you're interested in learning how the database resources are created in the code, you can review the following snippets. Otherwise, you can skip ahead to [Run the app](#run-the-app).
9393

94-
## [Passwordless (Recommended)](#tab/passwordless)
94+
### [Passwordless (Recommended)](#tab/passwordless)
9595

96-
In this section, neither the configurations nor the code have any authentication operations. However, connecting to Azure service requires authentication. To complete the authentication, you need to use Azure Identity. Spring Cloud Azure uses `DefaultAzureCredential`, which is provided by Azure Identity to help you get credentials without any code changes.
96+
In this section, neither the configurations nor the code has any authentication operations. However, connecting to Azure service requires authentication. To complete the authentication, you need to use Azure Identity. Spring Cloud Azure uses `DefaultAzureCredential`, which is provided by Azure Identity to help you get credentials without any code changes.
9797

9898
`DefaultAzureCredential` supports multiple authentication methods and determines which method should be used at runtime. This approach enables your app to use different authentication methods in different environments (local vs. production) without implementing environment-specific code. For more information, see the [Default Azure credential](/azure/developer/java/sdk/identity-azure-hosted-auth#default-azure-credential) section of [Authenticate Azure-hosted Java applications](/azure/developer/java/sdk/identity-azure-hosted-auth).
9999

100-
To use Azure CLI, Visual Studio Code, PowerShell or other methods to complete the authentication in local development environments, see [Azure authentication in Java development environments](/azure/developer/java/sdk/identity-dev-env-auth). To complete the authentication in Azure hosting environments, we recommend using managed identity. For more information, see [What are managed identities for Azure resources?](/azure/active-directory/managed-identities-azure-resources/overview)
101-
102100
[!INCLUDE [cosmos-nosql-create-assign-roles](../../../includes/passwordless/cosmos-nosql/cosmos-nosql-create-assign-roles.md)]
103101

102+
### Authenticate using DefaultAzureCredential
103+
104+
[!INCLUDE [default-azure-credential-sign-in](../../../includes/passwordless/default-azure-credential-sign-in.md)]
105+
106+
You can authenticate to Cosmos DB for NoSQL using `DefaultAzureCredential` by adding the `azure-identity` [dependency](https://mvnrepository.com/artifact/com.azure/azure-identity) to your application. `DefaultAzureCredential` will automatically discover and use the account you signed-in with in the previous step.
107+
104108
### Application configuration file
105109

106110
Configure the Azure Database for MySQL credentials in the `application.yml` configuration file in the `cosmos/spring-cloud-azure-starter-data-cosmos/spring-cloud-azure-data-cosmos-sample` directory. Replace the values of `${AZURE_COSMOS_ENDPOINT}` and `${COSMOS_DATABASE}`.
@@ -118,7 +122,7 @@ After creating the Azure Cosmos DB account, database and container, Spring Boot/
118122

119123
### Java source
120124

121-
The Spring Data value-add also comes from its simple, clean, standardized and platform-independent interface for operating on datastores. Building on the Spring Data GitHub sample linked above, below are CRUD and query samples for manipulating Azure Cosmos DB documents with Spring Datan Azure Cosmos DB.
125+
The Spring Data value-add also comes from its simple, clean, standardized and platform-independent interface for operating on datastores. Building on the Spring Data GitHub sample linked above, below are CRUD and query samples for manipulating Azure Cosmos DB documents with Spring Data Azure Cosmos DB.
122126

123127
* Item creation and updates by using the `save` method.
124128

@@ -144,13 +148,13 @@ The Spring Data value-add also comes from its simple, clean, standardized and pl
144148
LOGGER.info("Deleted all data in container.");
145149
```
146150

147-
* Derived query based on repository method name. Spring Data implements the `repository` `findByFirstName` method as a Java SDK SQL query on the `firstName` field (this query could not be implemented as a point-read):
151+
* Derived query based on repository method name. Spring Data implements the `repository` `findByFirstName` method as a Java SDK SQL query on the `firstName` field (this query couldn't be implemented as a point-read):
148152

149153
```java
150154
final Flux<User> firstNameUserFlux = repository.findByFirstName("testFirstName");
151155
```
152156

153-
## [Password](#tab/password)
157+
### [Password](#tab/password)
154158

155159
### Application configuration file
156160

@@ -196,7 +200,7 @@ The Spring Data value-add also comes from its simple, clean, standardized and pl
196200
LOGGER.info("Deleted all data in container.");
197201
```
198202

199-
* Derived query based on repository method name. Spring Data implements the `repository` `findByFirstName` method as a Java SDK SQL query on the `firstName` field (this query could not be implemented as a point-read):
203+
* Derived query based on repository method name. Spring Data implements the `repository` `findByFirstName` method as a Java SDK SQL query on the `firstName` field (this query couldn't be implemented as a point-read):
200204

201205
```java
202206
final Flux<User> firstNameUserFlux = repository.findByFirstName("testFirstName");
@@ -227,8 +231,8 @@ Now go back to the Azure portal to get your connection string information and la
227231
```
228232

229233
1. The app loads **application.yml** and connects the resources in your Azure Cosmos DB account.
230-
1. The app will perform point CRUD operations described above.
231-
1. The app will perform a derived query.
234+
1. The app performs point CRUD operations described above.
235+
1. The app performs a derived query.
232236
1. The app doesn't delete your resources. Switch back to the portal to [clean up the resources](#clean-up-resources) from your account if you want to avoid incurring charges.
233237

234238
## Review SLAs in the Azure portal

0 commit comments

Comments
 (0)