Questions tagged [azure-cosmosdb-sqlapi]
1222 questions
8
votes
3 answers
How to start CosmosDB emulator with docker-compose?
I've got a docker-compose project in Visual Studio which starts 3 services. One of them use cosmosdb.
I've followed the instructions on https://hub.docker.com/r/microsoft/azure-cosmosdb-emulator/ to start the emulator in a docker container and it…

Amila
- 3,711
- 3
- 26
- 42
7
votes
4 answers
Configure EF Core with Cosmos DB to store ICollection of string
Entity framework has some nice documentation about Embedding entities but I cannot figure out how to embed a simple string array IEnumerable.
Sample class
public class Post {
public string Id {get;set;}
public string Content {get;set;}
…

Stephan
- 2,356
- 16
- 38
7
votes
1 answer
How to structure many-to-many relationships in cosmos db
I'm working on a new project and it was recommended to me that I have a look at Cosmos DB to use for my data store for it because it's going to be a global SaaS application servicing potentially hundreds of thousands of users.
As this is my first…

bnm12
- 83
- 1
- 5
7
votes
2 answers
How to get more than 100 query results with SQL on portal.azure.com Cosmos DB Data Explorer
On https://portal.azure.com/ - Cosmos DB Data Explorer, I can execute SQL queries. The result output is 100:
SELECT c.email FROM Clients c
To reduce the number of network round trips required to retrieve all applicable results, you can increase…

chelder
- 3,819
- 6
- 56
- 90
7
votes
0 answers
Azure Cosmos DB SQL API QueryDefinition multiple parameters for WHERE IN
I'm trying to use SQL query parameters with a WHERE ... IN statement in an Azure Cosmos DB SQL API query:
var componentDesignGuids = new List();
// ...
var queryDefinition = new QueryDefinition(
"SELECT componentDesign.guid,…

Scotty H
- 6,432
- 6
- 41
- 94
7
votes
1 answer
Cosmos DB SQL API - How to query a field name that uses a reserved word
I'm trying to query a collection for some documents where one of the fields happens to be named 'top'. However, I can't directly reference this column in a select statement because the name conflicts with the TOP keyword. For example:
SELECT C.code,…

Adam Greenall
- 189
- 2
- 10
6
votes
3 answers
Parameterized Where IN clause does not work with CosmosClient QueryDefinition Object
I am trying to write a parameterized query that has IN clause.
For Ex :
Working code
Input string : "'guid1','guid2','guid3'"
public List GetEmployeeIds(string ids){
QueryDefinition query =new QueryDefinition(@"Select * from Employee where…

Rahul C
- 61
- 1
- 5
6
votes
2 answers
Bug in DateTime handling of Cosmos DB DocumentClient
This question relates to DocumentClient from Microsoft.Azure.DocumentDB.Core v2.11.2. (Update: the bug also exists in Microsoft.Azure.Cosmos.)
There seems to be a bug in the LINQ Provider for Cosmos DB when the query contains DateTime values with…

Mo B.
- 5,307
- 3
- 25
- 42
6
votes
1 answer
Cosmos SQL upsert not working as expected
If I try to upsert a document with an id and partition key that already exists, it works as expected IF there are no Unique constraints set on the container.
However, when I set any value in the table as Unique, then the upsert doesn't work and I…

Artanis
- 561
- 1
- 7
- 26
6
votes
1 answer
Why am I seeing different index behaviour between 2 seemingly identical CosmosDb Collections
I'm trying to debug a very strange discrepency between 2 seperate cosmos db collection that on face value are configured the same.
We recently modified some code that executed the following query.
OLD QUERY
SELECT * FROM c
WHERE c.ProductId =…

Eoin Campbell
- 43,500
- 17
- 101
- 157
6
votes
2 answers
Selecting values from objects in document nested array in CosmosDB
Imagine we have a such collection (example taken from https://www.documentdb.com/sql/demo)
{
"_id" : "19015",
"description" : "Snacks, granola bars, hard, plain",
"servings" : [
{
"amount" : 1,
…

jas
- 103
- 1
- 6
5
votes
1 answer
C# Cosmos DB Patch - insert element into child collection
Trying to add a new item into a parent object's child collection. For example, in the code below, how would one go about adding a new Item to the Items collection?
{
"id": "SalesOrder2",
"ponumber": "PO15428132599",
"OrderDate":…

Pietv
- 215
- 2
- 8
5
votes
3 answers
ReadItemAsync Cosmos DB
I have a cosmos db container with below fields (id,Category,Type).
The partition key is Category. While using the Below query I need to pass Partition key also.
But I have only ID value. How do I perform the operation using ReadItemAsync?. I am…

DealZaap India
- 79
- 1
- 7
5
votes
2 answers
Cosmos DB read a single document without partition key
A container has a function called ReadItemAsync. The problem is I do not have the partition key, but only the id of the document. What is the best approach to get just a single item then?
Do I have to get it from a collection? Like:
var…

Thomas Segato
- 4,567
- 11
- 55
- 104
5
votes
3 answers
How to query from two containers in Cosmos DB (SQL API)
I am new to cosmos db. I chose cosmos db (core sql), created a database having two containers say EmployeeContainer and DepartmentContainer. Now I want to query these two container and want to fetch employee details with associated department…

Rahul Jha
- 874
- 1
- 11
- 28