GithubHelp home page GithubHelp logo

azure-samples / azure-cosmos-db-mongodb-spring Goto Github PK

View Code? Open in Web Editor NEW
9.0 37.0 23.0 36 KB

This sample shows you how to use SpringBoot MongoDB application with Azure CosmosDB Mongo API.

License: MIT License

Java 100.00%

azure-cosmos-db-mongodb-spring's Introduction

page_type languages products description urlFragment
sample
java
azure
Azure Cosmos DB is a fully managed globally distributed, multi-model database service, transparently replicating your data across any number of Azure regions.
azure-cosmos-db-mongodb-spring

Developing a SpringBoot app using Azure Cosmos DB for MongoDB API

Azure Cosmos DB is a fully managed globally distributed, multi-model database service, transparently replicating your data across any number of Azure regions. You can elastically scale throughput and storage, and take advantage of fast, single-digit-millisecond data access using the API of your choice backed by 99.999 SLA. This sample shows you how to use the Azure Cosmos DB for MongoDB API to store and access data from a SpringBoot application.

Prerequisites

Before you can run this sample, you must have the following prerequisites:

  • 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 this tutorial.
  • An Azure Cosmos DB for MongoDB API account configured with at least two read regions.

Running this sample

  1. Clone this repository

  2. Substitute the spring.data.mongodb.uri in src\main\resources\application.properties with your Azure Cosmos DB account's connection string.

    spring.data.mongodb.uri=mongodb://<account-name>:<account-key>@<account-name>.mongo.cosmos.azure.com:10255/?ssl=true&replicaSet=globaldb&retrywrites=false&maxIdleTimeMS=120000&appName=@<account-name>@

    If the key string used in the MongoDB URI contains special characters, such as plus signs, use the URL-encoded value of that key. Otherwise, you may face issues trying to connect and see errors pertaining to SASL Authentication failure. This is especially true when working with Azure Cosmos DB Emulator over a local network.

  3. Create a new database in your Azure Cosmos DB account.

  4. Substitute the spring.data.mongodb.database in src\main\resources\application.properties with the name of the database in your Azure Cosmos DB account.

    spring.data.mongodb.database=<database-name>
  5. Run your application:

    mvn spring-boot:run

About the code

The code included in this sample is intended to illustrate using Azure Cosmos DB for MongoDB API from SpringBoot application. It is a port of the sample from SpringBoot Getting Started article. It also uses code from this tutorial to configure read preference for different repositories.

More information

azure-cosmos-db-mongodb-spring's People

Contributors

seesharprun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

azure-cosmos-db-mongodb-spring's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.