Skip to main content
Azure Cosmos DB for MongoDB vCore makes it easy to create a database with full native MongoDB support. You can apply your MongoDB experience and continue to use your favorite MongoDB drivers, SDKs, and tools by pointing your application to the API for MongoDB vCore account’s connection string. Use vector search in Azure Cosmos DB for MongoDB vCore to seamlessly integrate your AI-based applications with your data that’s stored in Azure Cosmos DB.
Azure Cosmos DB for MongoDB vCore provides developers with a fully managed MongoDB-compatible database service for building modern applications with a familiar architecture. Learn how to leverage the vector search capabilities of Azure Cosmos DB for MongoDB vCore from this page. If you don’t have an Azure account, you can create a free account to get started.

Setup

You’ll first need to install the @langchain/azure-cosmosdb package:
npm
You’ll also need to have an Azure Cosmos DB for MongoDB vCore instance running. You can deploy a free version on Azure Portal without any cost, following this guide. Once you have your instance running, make sure you have the connection string and the admin key. You can find them in the Azure Portal, under the “Connection strings” section of your instance. Then you need to set the following environment variables:
.env vars

Example

Below is an example that indexes documents from a file in Azure Cosmos DB for MongoDB vCore, runs a vector search query, and finally uses a chain to answer a question in natural language based on the retrieved documents.

Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.