Giter Club home page Giter Club logo

azure-spring-data-cosmos-java-sql-api-samples's Introduction

Azure Cosmos DB for NoSQL & Spring Data sample

Azure Cosmos DB for NoSQL & Spring Data sample code

Features

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.

Getting Started

Prerequisites

  • Java Development Kit 8 or JDK 11 if you run the azure-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.
  • (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.

GitHub Codespaces

Open in GitHub Codespaces

Quickstart

  1. In an empty directory, clone the repository: git clone https://github.com/Azure-Samples/azure-spring-data-cosmos-java-sql-api-samples.git .
  2. Update the src/main/resources/application.properties file with the uri, primary key, and *secondary key from your Azure Cosmos DB for NoSQL account.
  3. Run the application: mvn spring-boot:run

Resources

Please refer to Spring Data for Azure Cosmos DB for NoSQL source code for more information.

azure-spring-data-cosmos-java-sql-api-samples's People

Contributors

anfeldma-ms avatar kushagrathapar avatar microsoft-github-operations[bot] avatar microsoftopensource avatar seesharprun avatar theovankraay avatar trande4884 avatar

Stargazers

 avatar  avatar  avatar  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

azure-spring-data-cosmos-java-sql-api-samples's Issues

com.azure.cosmos.CosmosException: Message: {"Errors":["Resource Not Found. Learn more: https:\/\/aka.ms\/cosmosdb-tsg-not-found"]}

In SampleApplication.java
image

If I call function userRepository.getAllUsers(); , it will throw exception

error={"code":"NotFound","message":"Message: {\"Errors\":[\"Resource Not Found.   
Learn more: https:\\/\\/aka.ms\\/cosmosdb-\ tsg-not-found\"]}\r\nActivityId: e6e35cce-83ab-4e31-9674-566ac21e7312,  
Request URI: /apps/f56ce9b0-69fe-4151-840a-8e49704c36a4/services/e685e429-72e0-4744-9004-99dc6f2c3958/partitions/1c7e072b-9006-4e05-a884-297e20b1f334/replicas/132674189604669278s,   
RequestStats: \r\nRequestStartTime: 2021-06-07T07:45:34.3852316Z, RequestEndTime: 2021-06-07T07:45:34.3852316Z,    
Number of regions attempted:1\r\nResponseTime: 2021-06-07T07:45:34.3852316Z, StoreResult: StorePhysicalAddress:    
 rntbd://10.0.0.139:11300/apps/f56ce9b0-69fe-4151-840a-8e49704c36a4/services/e685e429-72e0-4744-9004-99dc6f2c3958/partitions/1c7e072b-9006-4e05-a884-297e20b1f334/replicas/132674189604669278s, LSN: 9,    
 GlobalCommittedLsn: 9, PartitionKeyRangeId: , IsValid: True, StatusCode: 404, SubStatusCode: 0, RequestCharge: 1, ItemLSN: -1, SessionToken: -1#9, UsingLocalLSN: False, TransportException: null, BELatencyMs: 0.347, ActivityId: e6e35cce-83ab-4e31-9674-566ac21e7312, ResourceType: Collection, OperationType: Read\r\nResponseTime: 2021-06-07T07:45:34.3852316Z,   
StoreResult:  StorePhysicalAddress: rntbd://10.0.0.25:11000/apps/f56ce9b0-69fe-4151-840a-8e49704c36a4/services/e685e429-72e0-4744-9004-99dc6f2c3958/partitions/1c7e072b-9006-4e05-a884-297e20b1f334/replicas/132674189604669279s, LSN: 9, GlobalCommittedLsn: 9, PartitionKeyRangeId: , IsValid: True, StatusCode: 404, SubStatusCode: 0, RequestCharge: 1, ItemLSN: -1, SessionToken: -1#9, UsingLocalLSN: False, TransportException: null, BELatencyMs: 0.345, ActivityId: e6e35cce-83ab-4e31-9674-566ac21e7312, ResourceType: Collection, OperationType: Read\r\n, SDK: Microsoft.Azure.Documents.Common/2.14.0, StatusCode: NotFound","additionalErrorInfo":null}, resourceAddress='null', requestUri='null', statusCode=404, message=Message: {"Errors":["Resource Not Found. Learn more: https:\/\/aka.ms\/cosmosdb-tsg-not-found"]}

This code cannot work with serverless plan!

Please provide us with the following information:

This issue is for a: (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

This code cannot run with serverless plan CosmosDB, because it doesn't support Provisioned Troughput

Any log messages given by the failure

"Setting offer throughput or autopilot on container is not supported for serverless accounts.\r\nActivityId: ****, Microsoft.Azure.Documents.Common/2.14.0, StatusCode: BadRequest"

Mention any other details that might be useful

It works fine if you modify User.java at line 8,
Original:
@container(containerName = "myContainer", ru = "400")
Modified:
@container(containerName = "myContainer")

This repository linked from QuickStart MS document and most user may use serverless plan for evaluation. So please correct it ASAP! (Write some guidance in README or update the code.)


Thanks! We'll be in touch soon.

Can you please check if the count query is working fine. for me they are not returning the result as the return type is not proper.SELECT  VALUE COUNT(1) FROM tableName c WHERE ( c.uploadDate BETWEEN @fromDate AND @toDate ) this is not working

Please provide us with the following information:

This issue is for a: (mark with an x)

- [ ] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

Any log messages given by the failure

Expected/desired behavior

OS and Version?

Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?)

Versions

Mention any other details that might be useful


Thanks! We'll be in touch soon.

Can you please check if the count query is working fine. for me they are not returning the result as the return type is not proper

Please provide us with the following information:

This issue is for a: (mark with an x)

- [ ] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

Any log messages given by the failure

Expected/desired behavior

OS and Version?

Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?)

Versions

Mention any other details that might be useful


Thanks! We'll be in touch soon.

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.