Skip to content

Latest commit

 

History

History

cosmos-quickstart-samples

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
page_type languages products name description
sample
java
azure-cosmos-db
Using Azure Cosmos DB By Spring Data in Spring Boot Application
This sample demonstrates how to use Azure Cosmos DB in Spring Boot application.

Using Azure Cosmos DB By Spring Data in Spring Boot Application

Features

Basic sample code for getting started with azure-spring-data-cosmos for Azure Cosmos DB SQL API.

Getting Started

Prerequisites

  • Java Development Kit 8 or higher.
  • An active Azure account. If you don't have one, you can sign up for a free account. Alternatively, you can use the Azure Cosmos DB Emulator for development and testing. As emulator https certificate is self-signed, you need to import its certificate to java trusted cert store, explained here
  • Maven.
  • (Optional) SLF4J is a logging facade.
  • (Optional) SLF4J binding is used to associate a specific logging framework with SLF4J. 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.

Quickstart

  1. git clone https://github.com/Azure-Samples/azure-spring-boot-samples.git
  2. cd cosmos/azure-spring-data-cosmos/cosmos-quickstart-samples
  3. Add environment variables ACCOUNT_HOST and ACCOUNT_KEY with Cosmos DB uri and primary key respectively (see resources/application.yaml).
  4. mvn spring-boot:run

Resources

Please refer to azure spring data cosmos for sql api azure-spring-data-cosmos source code for more information.

Deploy to Azure Spring Apps

Now that you have the Spring Boot application running locally, it's time to move it to production. Azure Spring Apps makes it easy to deploy Spring Boot applications to Azure without any code changes. The service manages the infrastructure of Spring applications so developers can focus on their code. Azure Spring Apps provides lifecycle management using comprehensive monitoring and diagnostics, configuration management, service discovery, CI/CD integration, blue-green deployments, and more. To deploy your application to Azure Spring Apps, see Deploy your first application to Azure Spring Apps.