The samples in this repo have moved here. This repo is no longer maintained.
Azure Cosmos DB for NoSQL & Spring Data sample code
This repo provides basic sample code for getting started with Azure Cosmos DB for NoSQL SQL API using the azure-spring-data-cosmos
library for Java.
Java Development Kit 8
orJDK 11
if you run theazure-spring-data-cosmos-java-11-getting-started
.- An active Azure Cosmos DB for NoSQL account. If you don't have an Azure subscription, you can sign up for a free subscription for Azure.
- Alternatively, you can use Try Azure Cosmos DB free for development and testing.
- As another alternative, you can use the Azure Cosmos DB emulator.
- (Optional) SLF4J is a logging facade.
- (Optional) SLF4J binding is used to associate a specific logging framework with SLF4J.
- (Optional) Maven.
SLF4J is only needed if you plan to use logging, please also download an SLF4J binding which will link the SLF4J API with the logging implementation of your choice. See the SLF4J user manual for more information.
- In an empty directory, clone the repository:
git clone https://github.com/Azure-Samples/azure-spring-data-cosmos-java-sql-api-samples.git .
- Update the src/main/resources/application.properties file with the uri, primary key, and *secondary key from your Azure Cosmos DB for NoSQL account.
- Run the application:
mvn spring-boot:run
Please refer to Spring Data for Azure Cosmos DB for NoSQL source code for more information.