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
Copy file name to clipboardExpand all lines: articles/cosmos-db/nosql/quickstart-java-spring-data.md
+16-12Lines changed: 16 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -56,7 +56,7 @@ You may read more about databases, containers and items [here.](../account-datab
56
56
57
57
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)
58
58
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).
60
60
61
61
## Create a database account
62
62
@@ -79,7 +79,7 @@ Before you can create a document database, you need to create an API for NoSQL a
79
79
80
80
## Clone the sample application
81
81
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.
83
83
84
84
Run the following command to clone the sample repository. This command creates a copy of the sample app on your computer.
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).
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.
97
97
98
98
`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).
99
99
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)
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
+
104
108
### Application configuration file
105
109
106
110
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/
118
122
119
123
### Java source
120
124
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.
122
126
123
127
* Item creation and updates by using the `save` method.
124
128
@@ -144,13 +148,13 @@ The Spring Data value-add also comes from its simple, clean, standardized and pl
144
148
LOGGER.info("Deleted all data in container.");
145
149
```
146
150
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):
148
152
149
153
```java
150
154
final Flux<User> firstNameUserFlux = repository.findByFirstName("testFirstName");
151
155
```
152
156
153
-
## [Password](#tab/password)
157
+
### [Password](#tab/password)
154
158
155
159
### Application configuration file
156
160
@@ -196,7 +200,7 @@ The Spring Data value-add also comes from its simple, clean, standardized and pl
196
200
LOGGER.info("Deleted all data in container.");
197
201
```
198
202
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):
200
204
201
205
```java
202
206
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
227
231
```
228
232
229
233
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.
232
236
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.
0 commit comments