Skip to main content
Azure DocumentDB 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 connection string. Use vector search in Azure DocumentDB to seamlessly integrate your AI-based applications with your data that’s stored in Azure DocumentDB.
Azure DocumentDB 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 DocumentDB 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 DocumentDB 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 DocumentDB, runs a vector search query, and finally uses a chain to answer a question in natural language based on the retrieved documents.