Skip to content

Commit 78877ee

Browse files
committed
Acrolinx fixes
1 parent 505b3eb commit 78877ee

File tree

1 file changed

+20
-54
lines changed

1 file changed

+20
-54
lines changed

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

Lines changed: 20 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,23 @@ Azure Cosmos DB is a multi-model database service that lets you quickly create a
4646

4747
* An Azure account with an active subscription.
4848
* No Azure subscription? You can [try Azure Cosmos DB free](../try-free.md) with no credit card required.
49-
* [Java Development Kit (JDK) 8](https://www.azul.com/downloads/azure-only/zulu/?&version=java-8-lts&architecture=x86-64-bit&package=jdk). Point your `JAVA_HOME` environment variable to the folder where the JDK is installed.
49+
* [Java Development Kit (JDK) 8](https://www.azul.com/downloads/azure-only/zulu/?&version=java-8-lts&architecture=x86-64-bit&package=jdk). Set the `JAVA_HOME` environment variable to the JDK install folder.
5050
* A [Maven binary archive](https://maven.apache.org/download.cgi). On Ubuntu, run `apt-get install maven` to install Maven.
5151
* [Git](https://www.git-scm.com/downloads). On Ubuntu, run `sudo apt-get install git` to install Git.
5252

5353
## Introductory notes
5454

55-
*The structure of an Azure Cosmos DB account.* Irrespective of API or programming language, an Azure Cosmos DB *account* contains zero or more *databases*, a *database* (DB) contains zero or more *containers*, and a *container* contains zero or more items, as shown in the diagram below:
55+
*The structure of an Azure Cosmos DB account.* Irrespective of API or programming language, an Azure Cosmos DB *account* contains zero or more *databases*, a *database* (DB) contains zero or more *containers*, and a *container* contains zero or more items, as shown in the following diagram:
5656

5757
:::image type="content" source="../media/account-databases-containers-items/cosmos-entities.png" alt-text="Azure Cosmos DB account entities" border="false":::
5858

5959
For more information about databases, containers, and items, see [Azure Cosmos DB resource model](../account-databases-containers-items.md). A few important properties are defined at the level of the container, among them *provisioned throughput* and *partition key*.
6060

61-
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)
61+
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. You can select provisioned throughput at per-container granularity or per-database granularity. However, you should prefer container-level throughput specification. For more information, see [Introduction to provisioned throughput in Azure Cosmos DB](../set-throughput.md).
6262

6363
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*. You must choose one field in your documents to be the partition key, which maps each document to a partition.
6464

65-
The way partitions are managed is that each partition is assigned a roughly equal slice out of the range of partition key values. For this reason, you should choose a partition key that's relatively random or evenly distributed. Otherwise, some partitions (called *hot partitions*) will see substantially more requests, while other partitions (called *cold partitions*) will see substantially fewer requests, and this is to be avoided. For more information, see [Partitioning and horizontal scaling in Azure Cosmos DB](../partitioning-overview.md).
65+
The way partitions are managed is that each partition is assigned a roughly equal slice out of the range of partition key values. For this reason, you should choose a partition key that's relatively random or evenly distributed. Otherwise, you get *hot partitions* and *cold partitions*, which see substantially more or fewer requests. For information on avoiding this condition, see [Partitioning and horizontal scaling in Azure Cosmos DB](../partitioning-overview.md).
6666

6767
## Create a database account
6868

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

8686
## Clone the sample application
8787

88-
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.
88+
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.
8989

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

@@ -99,17 +99,17 @@ This step is optional. If you're interested in learning how the database resourc
9999

100100
### [Passwordless (Recommended)](#tab/passwordless)
101101

102-
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.
102+
In this section, the configurations and the code don't 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 Azure Identity provides to help you get credentials without any code changes.
103103

104-
`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).
104+
`DefaultAzureCredential` supports multiple authentication methods and determines which method to use 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).
105105

106106
[!INCLUDE [cosmos-nosql-create-assign-roles](../../../includes/passwordless/cosmos-nosql/cosmos-nosql-create-assign-roles.md)]
107107

108108
### Authenticate using DefaultAzureCredential
109109

110110
[!INCLUDE [default-azure-credential-sign-in](../../../includes/passwordless/default-azure-credential-sign-in.md)]
111111

112-
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.
112+
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` automatically discovers and uses the account you signed in with in the previous step.
113113

114114
### Application configuration file
115115

@@ -124,41 +124,7 @@ spring:
124124
database: ${COSMOS_DATABASE}
125125
```
126126
127-
After creating the Azure Cosmos DB account, database and container, Spring Boot/Spring Data will connect to the database and container for `delete`, `add`, and `find` operations.
128-
129-
### Java source
130-
131-
Spring Data provides a simple, clean, standardized, and platform-independent interface for operating on datastores, as shown in the following examples. These CRUD and query examples enable you to manipulate Azure Cosmos DB documents by using Spring Data Azure Cosmos DB. These examples build on the Spring Data GitHub sample linked to earlier in this article.
132-
133-
* Item creation and updates by using the `save` method.
134-
135-
```java
136-
// Save the User class to Azure Cosmos DB database.
137-
final Mono<User> saveUserMono = repository.save(testUser);
138-
```
139-
140-
* Point-reads using the derived query method defined in the repository. The `findById` performs point-reads for `repository`. The fields mentioned in the method name cause Spring Data to execute a point-read defined by the `id` field:
141-
142-
```java
143-
// Nothing happens until we subscribe to these Monos.
144-
// findById will not return the user as user is not present.
145-
final Mono<User> findByIdMono = repository.findById(testUser.getId());
146-
final User findByIdUser = findByIdMono.block();
147-
Assert.isNull(findByIdUser, "User must be null");
148-
```
149-
150-
* Item deletes using `deleteAll`:
151-
152-
```java
153-
repository.deleteAll().block();
154-
LOGGER.info("Deleted all data in container.");
155-
```
156-
157-
* 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.
158-
159-
```java
160-
final Flux<User> firstNameUserFlux = repository.findByFirstName("testFirstName");
161-
```
127+
After Spring Boot and Spring Data create the Azure Cosmos DB account, database, and container, they connect to the database and container for `delete`, `add`, and `find` operations.
162128

163129
### [Password](#tab/password)
164130

@@ -176,11 +142,13 @@ spring:
176142
database: ${COSMOS_DATABASE}
177143
```
178144

179-
Once you create an Azure Cosmos DB account, database, and container, just fill-in-the-blanks in the config file and Spring Boot/Spring Data will automatically do the following: (1) create an underlying Java SDK `CosmosClient` instance with the URI and key, and (2) connect to the database and container. You're all set - no more resource management code!
145+
Once you create an Azure Cosmos DB account, database, and container, just fill-in-the-blanks in the config file and Spring Boot/Spring Data does the following: (1) creates an underlying Java SDK `CosmosClient` instance with the URI and key, and (2) connects to the database and container. You're all set - no more resource management code!
146+
147+
---
180148

181149
### Java source
182150

183-
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.
151+
Spring Data provides a simple, clean, standardized, and platform-independent interface for operating on datastores, as shown in the following examples. These CRUD and query examples enable you to manipulate Azure Cosmos DB documents by using Spring Data Azure Cosmos DB. These examples build on the Spring Data GitHub sample linked to earlier in this article.
184152

185153
* Item creation and updates by using the `save` method.
186154

@@ -206,38 +174,36 @@ The Spring Data value-add also comes from its simple, clean, standardized and pl
206174
LOGGER.info("Deleted all data in container.");
207175
```
208176

209-
* 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.
177+
* Derived query based on repository method name. Spring Data implements the `repository` `findByFirstName` method as a Java SDK SQL query on the `firstName` field. You can't implement this query as a point-read.
210178

211179
```java
212180
final Flux<User> firstNameUserFlux = repository.findByFirstName("testFirstName");
213181
```
214182

215-
---
216-
217183
## Run the app
218184

219-
Now go back to the Azure portal to get your connection string information and launch the app with your endpoint information. This enables your app to communicate with your hosted database.
185+
Now go back to the Azure portal to get your connection string information. Then, use the following steps to launch the app with your endpoint information so your app can communicate with your hosted database.
220186

221-
1. In the git terminal window, `cd` to the sample code folder.
187+
1. In the Git terminal window, `cd` to the sample code folder.
222188

223189
```bash
224190
cd azure-spring-boot-samples/cosmos/spring-cloud-azure-starter-data-cosmos/spring-cloud-azure-data-cosmos-sample
225191
```
226192

227-
1. In the git terminal window, use the following command to install the required Spring Data Azure Cosmos DB packages.
193+
1. In the Git terminal window, use the following command to install the required Spring Data Azure Cosmos DB packages.
228194

229195
```bash
230196
mvn clean package
231197
```
232198

233-
1. In the git terminal window, use the following command to start the Spring Data Azure Cosmos DB application:
199+
1. In the Git terminal window, use the following command to start the Spring Data Azure Cosmos DB application:
234200

235201
```bash
236202
mvn spring-boot:run
237203
```
238204

239205
1. The app loads *application.yml* and connects the resources in your Azure Cosmos DB account.
240-
1. The app performs point CRUD operations described above.
206+
1. The app performs point CRUD operations described previously.
241207
1. The app performs a derived query.
242208
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.
243209

@@ -251,7 +217,7 @@ Now go back to the Azure portal to get your connection string information and la
251217

252218
## Next steps
253219

254-
In this quickstart, you've learned how to create an Azure Cosmos DB for NoSQL account, create a document database and container using the Data Explorer, and run a Spring Data app to do the same thing programmatically. You can now import more data into your Azure Cosmos DB account.
220+
In this quickstart, you learned how to create an Azure Cosmos DB for NoSQL account and create a document database and container using the Data Explorer. You then ran a Spring Data app to do the same thing programmatically. You can now import more data into your Azure Cosmos DB account.
255221

256222
Trying to do capacity planning for a migration to Azure Cosmos DB? You can use information about your existing database cluster for capacity planning.
257223

0 commit comments

Comments
 (0)