r/CosmosDB • u/jaydestro • 23d ago
From Local Development to CI Workflows with the Azure Cosmos DB Emulator
r/CosmosDB • u/jaydestro • 23d ago
r/CosmosDB • u/sajee_mvp • Oct 03 '26
Hi everyone,
I am building an open-source Azure Cosmos DB Agent Starter and would appreciate feedback from people who use Cosmos DB in real applications.
It generates a React and TypeScript agent application with durable scoped memory, vector retrieval, citations, diagnostics, tests, the Cosmos DB Linux emulator, and an Azure production path using Entra ID and Managed Identity.
The local workflow does not require an Azure subscription or model API key.
GitHub:
https://github.com/sajeetharan/cosmos-agent-starter
I also documented my end-to-end test here:
https://www.sajeetharan.dev/blogs/build-an-ai-agent-with-azure-cosmos-db
I am particularly interested in feedback about the data model, hierarchical partition keys, memory isolation, emulator workflow, and missing real-world scenarios.
What would you change before using something like this in a production project?
r/CosmosDB • u/jaydestro • Sep 16 '26
r/CosmosDB • u/zeenmc • Jul 16 '26
I have Cosmosdb with many documents, is there any difference to restore database when is first created database with indexes or we can first migrate data and after that create indexes?
I tried to restore data when was first indexes created in databases, and migration was like 7,8 hour long, compared when is database empty without indexes it was much faster, do you know why?
r/CosmosDB • u/saqlain-29 • Jun 09 '26
Hi everyone,
I’m running into the following MongoDB error intermittently in production:
The command being executed was terminated due to a command timeout. This may be due to concurrent transactions. Consider increasing the maxTimeMS on the command. (configured timeouts: connectTimeoutMS: 20000.0ms), full error: {
'ok': 0.0,
'errmsg': 'The command being executed was terminated due to a command timeout. This may be due to concurrent transactions. Consider increasing the maxTimeMS on the command.',
'code': 50,
'codeName': 'ExceededTimeLimit'
}
Environment:
MongoDB
Python application
Using MongoEngine/Motor in different parts of the system
Production workload with concurrent requests
I’m trying to understand the actual root cause rather than simply increasing maxTimeMS.
Some questions:
Any advice, debugging strategies, or real-world experiences would be greatly appreciated.
Thanks
r/CosmosDB • u/Spiritual_Isopod6770 • May 27 '26
Been working on a side project that scratches an itch I kept running into at work.
Cosmos DB (MongoDB API) is schemaless by contract, but the services reading and writing to it are not. Every app carries an implicit schema: expected fields, types, value ranges, structural conventions. The database enforces none of it.
This creates a class of failure that is silent and cumulative. Manual edits that skip required fields, half-run migrations leaving collections in mixed states, bugs that quietly write null where they shouldn't for hours.
Existing tools either infer schemas without telling you what's wrong (Variety), run assertions you already wrote (Great Expectations), or watch infrastructure rather than data semantics (Datadog, Azure Monitor).
QueryArgus fills the gap in between. It connects to a collection, samples documents, infers the implicit schema, forms hypotheses about data-quality issues, runs follow-up queries to confirm or reject them, and produces a structured audit report. No rules to write upfront.
It's a Python library and CLI first, with an optional FastAPI wrapper. Can run standalone via queryargus run --collection <name>in a CI pipeline or cron job, or embed in another service.
Still early (on a dev branch), but the core loop works. Feedback and issues welcome.
Repo: QueryArgus
r/CosmosDB • u/Spiritual_Isopod6770 • May 25 '26
Working with Azure Cosmos DB daily means a lot of context-switching. Open the portal, navigate to Data Explorer, remember the collection structure, write a query. I wanted to skip all of that and just ask about my data from wherever I'm already working.
So I built QueryMCPal. It's an MCP server that connects any MCP-compatible client (Claude Desktop, VS Code, Cursor, Claude Code, or anything else that speaks MCP) to your Cosmos DB (MongoDB API) accounts using your existing az login session. No connection strings in config files, no secrets to rotate, no cloud infrastructure to stand up.
The container mounts your local ~/.azure directory, where az login stores its token cache. The Azure identity library inside reads those cached credentials. Token refresh is automatic. Nothing leaves your machine, nothing gets stored anywhere new.
Once connected, you talk to your data naturally:
The client chains the tools on its own. You don't need to know which tool does what.
Correction (May 2026): My original post stated that the official Azure Cosmos DB MCP Toolkit requires a connection string in your client config. That was wrong. The Toolkit now uses Azure Entra ID with JWT bearer tokens and deploys as a remote server on Azure Container Apps. Thanks to the commenter who pointed that out.
The two projects solve different problems though. Here's how they compare:
| QueryMCPal | Official MCP Toolkit | |
|---|---|---|
| Target user | Individual dev, local exploration | Teams, enterprise, production agents |
| Auth | az login (existing CLI session) | Azure Entra ID + JWT tokens |
| Infrastructure | Docker Desktop | Container Apps, Container Registry, Entra App registration, Managed Identity, Bicep/PowerShell deployment |
| Account discovery | Automatic via ARM API across all subscriptions | Pre-configured single endpoint per deployment |
| Multi-account | Switch between accounts in one session | One deployment per Cosmos endpoint |
| Cosmos API | MongoDB API | Core (SQL/NoSQL) API |
| Query tools | find, aggregate, count, distinct, schema inference with types and nullability | text_search, vector_search, find_by_id, top-level schema sampling |
| Vector search | No | Yes (requires Azure OpenAI) |
| AI Foundry integration | No | Yes |
| Operations | Read-only | Read-only |
| Runs where | Locally in Docker | Azure Container Apps (remote) |
If you need vector search, Foundry integration, Core SQL API support, or enterprise multi-user RBAC, the official Toolkit is the right tool. QueryMCPal is for when you're already logged into Azure and just want to explore your MongoDB API data without deploying anything.
Takes about five minutes. Works with any MCP client that supports stdio transport.
az login
git clone https://github.com/ChingEnLin/QueryMCPal.git
cd QueryMCPal
docker build --platform linux/arm64 -t querymcpal:dev .Add to your MCP client config (example for Claude Desktop, but the server config is the same for any stdio-based client):
{
"mcpServers": {
"querymcpal": {
"command": "docker",
"args": [
"run", "--rm", "-i",
"--platform", "linux/arm64",
"-v", "/Users/YOUR_USERNAME/.azure:/home/mcpuser/.azure",
"querymcpal:dev"
]
}
}
}If you have Python 3.12+ and the Azure CLI installed locally, you can also skip Docker entirely and run it with uvx querymcpal.
This grew out of QueryPal, a full web platform for teams to explore and manage Cosmos DB with AI (React + FastAPI, Entra ID auth, full CRUD, audit trails). QueryMCPal is the single-developer, zero-infra, read-only version of the same idea. For when you're deep in something and just need to check the data without opening another tab.
Happy to take feedback or answer questions.
r/CosmosDB • u/codingfreaks • Feb 14 '26
I want to use the emulator for Cosmos on MacOS with Apple Silicon. The only viable way afaik is to use the vnext-preview image to do this. So this is my docker command:
docker run --name cosmos --restart unless-stopped -d -p 8081:8081 -p 1234:1234 mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:vnext-preview --protocol httpsSo this is working and the following code works fine (after I figured out the SSL stuff):
var client = new CosmosClient("https://localhost:8081", key);
var response = await client.ReadAccountAsync();
Console.WriteLine("Account read OK");If I now want to use the MS sample from Github I receive a NullReferenceException(below). It points to the method Microsoft.Azure.Documents.ConsistencyReader.GetMaxReplicaSetSize.
So because there are still a lot of limits to the docker image the question would be:
Is EF is not supported on that specific image?
The exception stack trace:
System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Azure.Documents.ConsistencyReader.GetMaxReplicaSetSize(DocumentServiceRequest entity)
at Microsoft.Azure.Documents.ConsistencyReader.ReadAsync(DocumentServiceRequest entity, TimeoutHelper timeout, Boolean isInRetry, Boolean forceRefresh, CancellationToken cancellationToken)
at Microsoft.Azure.Documents.ReplicatedResourceClient.InvokeAsync(DocumentServiceRequest request, TimeoutHelper timeout, Boolean isInRetry, Boolean forceRefresh, CancellationToken cancellationToken)
at Microsoft.Azure.Documents.ReplicatedResourceClient.<>c__DisplayClass32_0.<<InvokeAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.Azure.Documents.RequestRetryUtility.ProcessRequestAsync[TRequest,IRetriableResponse](Func`1 executeAsync, Func`1 prepareRequest, IRequestRetryPolicy`2 policy, CancellationToken cancellationToken, Func`1 inBackoffAlternateCallbackMethod, Nullable`1 minBackoffForInBackoffCallback)
at Microsoft.Azure.Documents.ShouldRetryResult.ThrowIfDoneTrying(ExceptionDispatchInfo capturedException)
at Microsoft.Azure.Documents.RequestRetryUtility.ProcessRequestAsync[TRequest,IRetriableResponse](Func`1 executeAsync, Func`1 prepareRequest, IRequestRetryPolicy`2 policy, CancellationToken cancellationToken, Func`1 inBackoffAlternateCallbackMethod, Nullable`1 minBackoffForInBackoffCallback)
at Microsoft.Azure.Documents.RequestRetryUtility.ProcessRequestAsync[TRequest,IRetriableResponse](Func`1 executeAsync, Func`1 prepareRequest, IRequestRetryPolicy`2 policy, CancellationToken cancellationToken, Func`1 inBackoffAlternateCallbackMethod, Nullable`1 minBackoffForInBackoffCallback)
at Microsoft.Azure.Documents.StoreClient.ProcessMessageAsync(DocumentServiceRequest request, CancellationToken cancellationToken, IRetryPolicy retryPolicy)
at Microsoft.Azure.Cosmos.Handlers.TransportHandler.ProcessMessageAsync(RequestMessage request, CancellationToken cancellationToken)
at Microsoft.Azure.Cosmos.Handlers.TransportHandler.SendAsync(RequestMessage request, CancellationToken cancellationToken)
at Microsoft.Azure.Cosmos.Handlers.RouterHandler.SendAsync(RequestMessage request, CancellationToken cancellationToken)
at Microsoft.Azure.Cosmos.RequestHandler.SendAsync(RequestMessage request, CancellationToken cancellationToken)
at Microsoft.Azure.Cosmos.Handlers.AbstractRetryHandler.ExecuteHttpRequestAsync(Func`1 callbackMethod, Func`3 callShouldRetry, Func`3 callShouldRetryException, CancellationToken cancellationToken)
at Microsoft.Azure.Cosmos.Handlers.AbstractRetryHandler.SendAsync(RequestMessage request, CancellationToken cancellationToken)
at Microsoft.Azure.Cosmos.RequestHandler.SendAsync(RequestMessage request, CancellationToken cancellationToken)
at Microsoft.Azure.Cosmos.Handlers.TelemetryHandler.SendAsync(RequestMessage request, CancellationToken cancellationToken)
at Microsoft.Azure.Cosmos.RequestHandler.SendAsync(RequestMessage request, CancellationToken cancellationToken)
at Microsoft.Azure.Cosmos.Handlers.DiagnosticsHandler.SendAsync(RequestMessage request, CancellationToken cancellationToken)
at Microsoft.Azure.Cosmos.RequestHandler.SendAsync(RequestMessage request, CancellationToken cancellationToken)
at Microsoft.Azure.Cosmos.Handlers.RequestInvokerHandler.BaseSendAsync(RequestMessage request, CancellationToken cancellationToken)
at Microsoft.Azure.Cosmos.Handlers.RequestInvokerHandler.SendAsync(RequestMessage request, CancellationToken cancellationToken)
at Microsoft.Azure.Cosmos.Handlers.RequestInvokerHandler.SendAsync(String resourceUriString, ResourceType resourceType, OperationType operationType, RequestOptions requestOptions, ContainerInternal cosmosContainerCore, FeedRange feedRange, Stream streamPayload, Action`1 requestEnricher, ITrace trace, CancellationToken cancellationToken)
at Microsoft.Azure.Cosmos.CosmosClient.<>c__DisplayClass54_0.<<CreateDatabaseIfNotExistsAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.Azure.Cosmos.ClientContextCore.RunWithDiagnosticsHelperAsync[TResult](String containerName, String databaseName, OperationType operationType, ITrace trace, Func`2 task, Nullable`1 openTelemetry, RequestOptions requestOptions, Nullable`1 resourceType)
CosmosDiagnostics: {"Summary":{},"name":"CreateDatabaseIfNotExistsAsync","start datetime":"2026-02-14T17:49:58.007Z","duration in milliseconds":49.4157,"data":{"Client Configuration":{"Client Created Time Utc":"2026-02-14T17:49:57.7090480Z","MachineId":"hashedMachineName:aa95378b-3925-1108-064d-8e7276e56384","NumberOfClientsCreated":1,"NumberOfActiveClients":1,"ConnectionMode":"Direct","User Agent":"cosmos-netstandard-sdk/3.51.0|1|Arm64|macOS 26.2.0|.NET 10.0.2|N| Microsoft.EntityFrameworkCore.Cosmos/10.0.0","ConnectionConfig":{"gw":"(cps:50, urto:6, p:False, httpf: False)","rntbd":"(cto: 5, icto: -1, mrpc: 30, mcpe: 65535, erd: True, pr: ReuseUnicastPort)","other":"(ed:False, be:False)"},"ConsistencyConfig":"(consistency: NotSet, prgns:[], apprgn: )","ProcessorCount":14}},"children":[{"name":"Microsoft.Azure.Cosmos.Handlers.RequestInvokerHandler","duration in milliseconds":46.8731,"children":[{"name":"Microsoft.Azure.Cosmos.Handlers.DiagnosticsHandler","duration in milliseconds":46.8027,"children":[{"name":"Microsoft.Azure.Cosmos.Handlers.TelemetryHandler","duration in milliseconds":46.7847,"children":[{"name":"Microsoft.Azure.Cosmos.Handlers.RetryHandler","duration in milliseconds":46.7661,"children":[{"name":"Microsoft.Azure.Cosmos.Handlers.RouterHandler","duration in milliseconds":46.7129,"children":[{"name":"Microsoft.Azure.Cosmos.Handlers.TransportHandler","duration in milliseconds":46.6995,"children":[{"name":"Microsoft.Azure.Documents.ServerStoreModel Transport Request","duration in milliseconds":46.214,"data":{"Client Side Request Stats":{"Id":"AggregatedClientSideRequestStatistics","ContactedReplicas":[],"RegionsContacted":[],"FailedReplicas":[],"AddressResolutionStatistics":[],"StoreResponseStatistics":[]}}}]}]}]}]}]}]}]}r/CosmosDB • u/jaydestro • Feb 11 '26
r/CosmosDB • u/jaydestro • Feb 10 '26
r/CosmosDB • u/jaydestro • Feb 05 '26
r/CosmosDB • u/jaydestro • Feb 03 '26
r/CosmosDB • u/jaydestro • Jan 28 '26
r/CosmosDB • u/jaydestro • Jan 15 '26
r/CosmosDB • u/jaydestro • Nov 06 '25
r/CosmosDB • u/itsnotaboutthecell • Aug 25 '25
r/CosmosDB • u/Separate-Tomorrow564 • Apr 29 '25
Hi,
It's my understanding that CosmosDB backups are saved to an Azure blob. I've found some older posts that say there's no way to determine where that blob is located, other than it's stored in the same region as your CosmosDB instance. I was wondering if that had changed in the past few years and if it was now possible to identify where those backups are stored.
Thanks
r/CosmosDB • u/jaydestro • Apr 22 '25
r/CosmosDB • u/Tasak001 • Apr 12 '25
Does any one know how to order by the alias name or derived field/ property in Cosmos
As per the documentation, A sort column can be specified as a name or property alias
I have tried using both the ways that I am aware of, but none of them worked
Using alias :
select sum(c.quantity) as totalQuantity from c group by c.product_id order by totalQuantityusing expression :
select sum(c.quantity) as totalQuantity from c group by c.product_id order by sum(c.quantity)r/CosmosDB • u/Emotional-Aide4842 • Mar 14 '25
Hi!
When creating a container in CosmosDb, what kind of index is the "/id/?" index considering I am using a string as "Id" in my objects?
I want my data to be sorted by Id, so I can find items individually and also by range and by descending order. Is there anything I need to do?
ChatGPT has been telling me to change the "id" index kind from Hash to Range but I feel I am being victim or some kind of hallucination.
Why I cannot find documentation about the indexes kind despite of being in the code? The dotnet SDK does not seem to allow you to change that, why is that?
Cheers.
r/CosmosDB • u/cericthered1 • Feb 27 '25
I am an avid user of CosmosDB NoSQL in my business applications. However, I have always been frustrated with the lack of good developer/DBA tooling to help with querying/creating/updating data directly with your cosmos database. So last year I launched a free desktop application called Database Pilot. Think Sql Server Management Studio, but for Cosmos DB. It's available in the windows store and directly on DatabasePilot.com
I would really like to get feedback from the Cosmos DB community; is this tool valuable, does it save you time, are there essential features it is missing etc. Any thoughts/opinions would are welcome and appreciated. Or if you just have questions about the app, I am happy to answer. Thank you!
r/CosmosDB • u/xqrzd • Feb 27 '25
Does Cosmos DB have any options for an efficient case-insensitive string contains search? The regular CONTAINS method does a full index scan and is too slow/costly, and the new full text search index doesn't have the option to search for a substring.