Skip to content

Commit 3ad1408

Browse files
authored
Merge pull request #8 from Azure-Samples/copilot/update-packages-branding
Standardize branding to "DocumentDB" across all vector search projects
2 parents 56ab0ae + 7441e53 commit 3ad1408

13 files changed

Lines changed: 55 additions & 54 deletions

File tree

ai/vector-search-dotnet/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static async Task Main(string[] args)
3838
string? command;
3939
while (true)
4040
{
41-
Console.WriteLine("\n=== Cosmos DB Vector Samples Menu ===\nPlease enter your choice (0-5):\n1. Create embeddings for data\n2. Show all database indexes\n3. Run IVF vector search\n4. Run HNSW vector search\n5. Run DiskANN vector search\n0. Exit\n");
41+
Console.WriteLine("\n=== DocumentDB Vector Samples Menu ===\nPlease enter your choice (0-5):\n1. Create embeddings for data\n2. Show all database indexes\n3. Run IVF vector search\n4. Run HNSW vector search\n5. Run DiskANN vector search\n0. Exit\n");
4242

4343
var input = Console.ReadLine();
4444
command = input switch

ai/vector-search-dotnet/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
# Azure Cosmos DB MongoDB vCore - Vector Search Sample
1+
# DocumentDB Vector Search Sample
22

3-
This .NET 8.0 sample application demonstrates vector similarity searches using Azure Cosmos DB for MongoDB vCore with different vector search algorithms (IVF, HNSW, and DiskANN). The application uses hotel data and text embeddings generated by Azure OpenAI.
3+
This .NET 8.0 sample application demonstrates vector similarity searches using Azure DocumentDB with different vector search algorithms (IVF, HNSW, and DiskANN). The application uses hotel data and text embeddings generated by Azure OpenAI.
44

55
## Features
66

77
- Generate vector embeddings for hotel descriptions using Azure OpenAI
88
- Compare performance across IVF, HNSW, and DiskANN vector search algorithms
9-
- Seamless integration with Azure Cosmos DB and Azure OpenAI services
9+
- Seamless integration with DocumentDB and Azure OpenAI services
1010
- Interactive menu-driven application
1111

1212
## Prerequisites
1313

1414
### Azure Services
1515

16-
- Azure Cosmos DB for MongoDB vCore account
16+
- Azure DocumentDB account
1717
- Azure OpenAI Service with text-embedding-ada-002 model deployed
1818

1919
### Development Environment
@@ -105,17 +105,17 @@ Update the following in `appsettings.json`:
105105

106106
- `AzureOpenAI.Endpoint`: Your Azure OpenAI service endpoint
107107
- `MongoDB.TenantId`: Your Azure tenant ID
108-
- `MongoDB.ClusterName`: Your Cosmos DB cluster name
108+
- `MongoDB.ClusterName`: Your DocumentDB cluster name
109109

110110
## Troubleshooting
111111

112112
- **Authentication errors**: Run `az login` to authenticate with Azure
113-
- **Connection issues**: Verify Cosmos DB cluster is running and accessible
113+
- **Connection issues**: Verify DocumentDB cluster is running and accessible
114114
- **Embedding errors**: Ensure Azure OpenAI service is deployed with text-embedding-ada-002 model
115115
- **Index failures**: Check vector dimensions match (1536) and sufficient storage is available
116116

117117
## Additional Resources
118118

119-
- [Azure Cosmos DB for MongoDB vCore Documentation](https://docs.microsoft.com/azure/cosmos-db/mongodb/vcore/)
119+
- [Azure DocumentDB Documentation](https://docs.microsoft.com/azure/documentdb/)
120120
- [Azure OpenAI Service Documentation](https://docs.microsoft.com/azure/cognitive-services/openai/)
121121
- [.NET MongoDB Driver Documentation](https://mongodb.github.io/mongo-csharp-driver/)

ai/vector-search-dotnet/Services/MongoDbService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace CosmosDbVectorSamples.Services;
1010

1111
/// <summary>
1212
/// Service for MongoDB operations including data insertion, index management, and vector index creation.
13-
/// Supports Azure Cosmos DB for MongoDB with passwordless authentication.
13+
/// Supports Azure DocumentDB with passwordless authentication.
1414
/// </summary>
1515
public class MongoDbService
1616
{
@@ -28,7 +28,7 @@ public MongoDbService(ILogger<MongoDbService> logger, IConfiguration configurati
2828
if (string.IsNullOrEmpty(_config.MongoDB.ClusterName))
2929
throw new InvalidOperationException("MongoDB connection not configured. Please provide ConnectionString or ClusterName.");
3030

31-
// Configure MongoDB connection for Azure Cosmos DB with OIDC authentication
31+
// Configure MongoDB connection for Azure DocumentDB with OIDC authentication
3232
var connectionString = $"mongodb+srv://{_config.MongoDB.ClusterName}.global.mongocluster.cosmos.azure.com/?tls=true&authMechanism=MONGODB-OIDC&retrywrites=false&maxIdleTimeMS=120000";
3333
var settings = MongoClientSettings.FromUrl(MongoUrl.Create(connectionString));
3434
settings.UseTls = true;
@@ -49,7 +49,7 @@ public IMongoCollection<T> GetCollection<T>(string databaseName, string collecti
4949
_client.GetDatabase(databaseName).GetCollection<T>(collectionName);
5050

5151
/// <summary>
52-
/// Creates a vector search index for Cosmos DB MongoDB, with support for IVF, HNSW, and DiskANN algorithms
52+
/// Creates a vector search index for DocumentDB, with support for IVF, HNSW, and DiskANN algorithms
5353
/// </summary>
5454
public async Task<BsonDocument> CreateVectorIndexAsync(string databaseName, string collectionName, string indexName, string embeddedField, BsonDocument cosmosSearchOptions)
5555
{

ai/vector-search-go/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ LOAD_SIZE_BATCH=100
137137
To use passwordless authentication with Microsoft Entra ID, follow these steps:
138138

139139
1. In your Azure DocumentDB resource, enable **Native DocumentDB** and **Microsoft Entra ID** authentication methods.
140-
2. Assign your Microsoft Entra ID user the following roles on the Cosmos DB resource:
141-
- **Cosmos DB Account Reader Role**
140+
2. Assign your Microsoft Entra ID user the following roles on the DocumentDB resource:
141+
- **DocumentDB Account Reader Role**
142142
- **DocumentDB Account Contributor**
143143

144144
## Usage
@@ -269,7 +269,7 @@ defer mongoClient.Disconnect(ctx)
269269

270270
1. Ensure you're logged in with `az login`
271271
2. Enable **Native DocumentDB and Microsoft Entra ID authentication** methods for your Azure DocumentDB resource.
272-
3. Grant your identity appropriate RBAC permissions on your Azure DocumentDB instance. You need **Cosmos DB Account Reader Role** and **DocumentDB Account Contributor** roles assigned to your user.
272+
3. Grant your identity appropriate RBAC permissions on your Azure DocumentDB instance. You need **DocumentDB Account Reader Role** and **DocumentDB Account Contributor** roles assigned to your user.
273273
4. Set `MONGO_CLUSTER_NAME` instead of `MONGO_CONNECTION_STRING` in `.env`
274274

275275
### Method 2: Connection String Authentication
@@ -333,7 +333,7 @@ mongo-vcore-vector-search-go/
333333
1. **Authentication Errors**
334334
- Verify Azure OpenAI endpoint and key
335335
- Check Azure DocumentDB connection string
336-
- Ensure proper RBAC permissions for passwordless authentication. You need **Cosmos DB Account Reader Role** and **DocumentDB Account Contributor** roles assigned to your user. Roles may take some time to propagate.
336+
- Ensure proper RBAC permissions for passwordless authentication. You need **DocumentDB Account Reader Role** and **DocumentDB Account Contributor** roles assigned to your user. Roles may take some time to propagate.
337337

338338
2. **Embedding Generation Fails**
339339
- Check Azure OpenAI model deployment name
@@ -377,7 +377,7 @@ DEBUG=true
377377

378378
- [Azure DocumentDB Documentation](https://learn.microsoft.com/azure/documentdb/)
379379
- [Azure OpenAI Service Documentation](https://learn.microsoft.com/azure/ai-services/openai/)
380-
- [Vector Search in Cosmos DB](https://learn.microsoft.com/azure/documentdb/vector-search)
380+
- [Vector Search in DocumentDB](https://learn.microsoft.com/azure/documentdb/vector-search)
381381
- [Go MongoDB Driver Documentation](https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo)
382382
- [Azure SDK for Go Documentation](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go)
383383

ai/vector-search-python/README.md

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# Cosmos DB Vector Samples (Python)
1+
# DocumentDB Vector Samples (Python)
22

3-
This project demonstrates vector search capabilities using Azure Cosmos DB for MongoDB (vCore) with Python. It includes implementations of three different vector index types: DiskANN, HNSW, and IVF, along with utilities for embedding generation and data management.
3+
This project demonstrates vector search capabilities using Azure DocumentDB with Python. It includes implementations of three different vector index types: DiskANN, HNSW, and IVF, along with utilities for embedding generation and data management.
44

55
## Overview
66

77
Vector search enables semantic similarity searching by converting text into high-dimensional vector representations (embeddings) and finding the most similar vectors in the database. This project shows how to:
88

99
- Generate embeddings using Azure OpenAI
10-
- Store vectors in Cosmos DB for MongoDB (vCore)
10+
- Store vectors in DocumentDB
1111
- Create and use different types of vector indexes
1212
- Perform similarity searches with various algorithms
1313

@@ -18,7 +18,7 @@ Before running this project, you need:
1818
### Azure Resources
1919
1. **Azure subscription** with appropriate permissions
2020
2. **Azure OpenAI resource** with embedding model deployment
21-
3. **Azure Cosmos DB for MongoDB (vCore) resource**
21+
3. **Azure DocumentDB resource**
2222
4. **Azure CLI** installed and configured
2323

2424
### Development Environment
@@ -75,9 +75,9 @@ az cognitiveservices account create \
7575
4. Choose **text-embedding-ada-002** model
7676
5. Note the deployment name for configuration
7777

78-
#### Create Cosmos DB for MongoDB (vCore)
78+
#### Create DocumentDB
7979

80-
Learn how to create a Cosmos DB for MongoDB (vCore) account in the [official documentation](https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/vcore/quickstart-portal).
80+
Learn how to create an Azure DocumentDB account in the [official documentation](https://learn.microsoft.com/azure/documentdb/).
8181

8282
### Step 3: Configure Environment Variables
8383

@@ -95,7 +95,7 @@ AZURE_OPENAI_EMBEDDING_ENDPOINT=https://your-openai-resource.openai.azure.com/
9595
AZURE_OPENAI_EMBEDDING_KEY=your-azure-openai-api-key
9696
AZURE_OPENAI_EMBEDDING_API_VERSION=2024-02-01
9797
98-
# MongoDB/Cosmos DB Configuration
98+
# MongoDB/DocumentDB Configuration
9999
MONGO_CONNECTION_STRING=mongodb+srv://username:password@your-cluster.mongocluster.cosmos.azure.com/?tls=true&authMechanism=SCRAM-SHA-256&retrywrites=false&maxIdleTimeMS=120000
100100
MONGO_CLUSTER_NAME=vectorSearch
101101
@@ -126,14 +126,15 @@ az cognitiveservices account keys list \
126126
--query "key1" --output tsv
127127
```
128128

129-
#### Cosmos DB Connection String
129+
#### DocumentDB Connection String
130130
```bash
131-
# Get Cosmos DB connection string
132-
az cosmosdb keys list \
133-
--name myCosmosAccount \
131+
# Get DocumentDB connection string
132+
az resource show \
134133
--resource-group myResourceGroup \
135-
--type connection-strings \
136-
--query "connectionStrings[0].connectionString" --output tsv
134+
--name myDocumentDBCluster \
135+
--resource-type "Microsoft.DocumentDB/mongoClusters" \
136+
--query "properties.connectionString" \
137+
--output tsv
137138
```
138139

139140
## Usage
@@ -206,7 +207,7 @@ This utility shows:
206207
## Important Notes
207208

208209
### Vector Index Limitations
209-
**One Index Per Field**: Cosmos DB for MongoDB (vCore) allows only one vector index per field. Each script automatically handles this by:
210+
**One Index Per Field**: DocumentDB allows only one vector index per field. Each script automatically handles this by:
210211

211212
1. **Dropping existing indexes**: Before creating a new vector index, the script removes any existing vector indexes on the same field
212213
2. **Safe switching**: You can run different vector index scripts in any order - each will clean up previous indexes first
@@ -234,7 +235,7 @@ Different vector index types require different cluster tiers:
234235
If you encounter "not enabled for this cluster tier" errors:
235236
1. Try a different index type (IVF is most widely supported)
236237
2. Consider upgrading your cluster tier
237-
3. Check the [Cosmos DB pricing page](https://azure.microsoft.com/pricing/details/cosmos-db/) for tier features
238+
3. Check the [DocumentDB pricing page](https://azure.microsoft.com/pricing/details/documentdb/) for tier features
238239

239240
## Authentication Options
240241

@@ -257,7 +258,7 @@ mongo_client, openai_client = get_clients_passwordless()
257258

258259
**Setup for passwordless authentication:**
259260
1. Ensure you're logged in with `az login`
260-
2. Grant your identity appropriate RBAC permissions on Cosmos DB
261+
2. Grant your identity appropriate RBAC permissions on DocumentDB
261262
3. Set `MONGO_CLUSTER_NAME` instead of `MONGO_CONNECTION_STRING` in `.env`
262263

263264
### Method 2: Connection String Authentication
@@ -314,7 +315,7 @@ cosmos-db-vector-samples/
314315

315316
1. **Authentication Errors**
316317
- Verify Azure OpenAI endpoint and key
317-
- Check Cosmos DB connection string
318+
- Check DocumentDB connection string
318319
- Ensure proper RBAC permissions for passwordless auth
319320

320321
2. **Embedding Generation Fails**
@@ -368,14 +369,14 @@ except Exception as e:
368369

369370
### Cost Optimization
370371
- Use appropriate Azure OpenAI pricing tier
371-
- Consider Cosmos DB serverless vs provisioned throughput
372+
- Consider DocumentDB serverless vs provisioned throughput
372373
- Monitor API usage and optimize batch processing
373374

374375
## Further Resources
375376

376-
- [Azure Cosmos DB for MongoDB (vCore) Documentation](https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/vcore/)
377+
- [Azure DocumentDB Documentation](https://learn.microsoft.com/azure/documentdb/)
377378
- [Azure OpenAI Service Documentation](https://learn.microsoft.com/en-us/azure/ai-services/openai/)
378-
- [Vector Search in Cosmos DB](https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/vcore/vector-search)
379+
- [Vector Search in DocumentDB](https://learn.microsoft.com/azure/documentdb/vector-search)
379380
- [Python MongoDB Driver Documentation](https://pymongo.readthedocs.io/)
380381

381382
## Support

ai/vector-search-python/src/diskann.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ def create_diskann_vector_index(collection, vector_field: str, dimensions: int)
1414
# Drop any existing vector indexes on this field first
1515
drop_vector_indexes(collection, vector_field)
1616

17-
# Use the native MongoDB command for Cosmos DB vector indexes
17+
# Use the native MongoDB command for DocumentDB vector indexes
1818
index_command = {
1919
"createIndexes": collection.name,
2020
"indexes": [
2121
{
2222
"name": f"diskann_index_{vector_field}",
2323
"key": {
24-
vector_field: "cosmosSearch" # Cosmos DB vector search index type
24+
vector_field: "cosmosSearch" # DocumentDB vector search index type
2525
},
2626
"cosmosSearchOptions": {
2727
# DiskANN algorithm configuration
@@ -57,7 +57,7 @@ def create_diskann_vector_index(collection, vector_field: str, dimensions: int)
5757
if "not enabled for this cluster tier" in str(e):
5858
print("\nDiskANN indexes require a higher cluster tier.")
5959
print("Try one of these alternatives:")
60-
print(" • Upgrade your Cosmos DB cluster to a higher tier")
60+
print(" • Upgrade your DocumentDB cluster to a higher tier")
6161
print(" • Use HNSW instead: python src/hnsw.py")
6262
print(" • Use IVF instead: python src/ivf.py")
6363
raise
@@ -82,11 +82,11 @@ def perform_diskann_vector_search(collection,
8282
query_embedding = embedding_response.data[0].embedding
8383

8484
# Construct the aggregation pipeline for vector search
85-
# Cosmos DB for MongoDB vCore uses $search with cosmosSearch
85+
# DocumentDB uses $search with cosmosSearch
8686
pipeline = [
8787
{
8888
"$search": {
89-
# Use cosmosSearch for vector operations in Cosmos DB
89+
# Use cosmosSearch for vector operations in DocumentDB
9090
"cosmosSearch": {
9191
# The query vector to search for
9292
"vector": query_embedding,

ai/vector-search-python/src/hnsw.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ def create_hnsw_vector_index(collection, vector_field: str, dimensions: int) ->
1414
# Drop any existing vector indexes on this field first
1515
drop_vector_indexes(collection, vector_field)
1616

17-
# Use the native MongoDB command for Cosmos DB vector indexes
17+
# Use the native MongoDB command for DocumentDB vector indexes
1818
index_command = {
1919
"createIndexes": collection.name,
2020
"indexes": [
2121
{
2222
"name": f"hnsw_index_{vector_field}",
2323
"key": {
24-
vector_field: "cosmosSearch" # Cosmos DB vector search index type
24+
vector_field: "cosmosSearch" # DocumentDB vector search index type
2525
},
2626
"cosmosSearchOptions": {
2727
# HNSW algorithm configuration
@@ -78,7 +78,7 @@ def perform_hnsw_vector_search(collection,
7878
pipeline = [
7979
{
8080
"$search": {
81-
# Use cosmosSearch for vector operations in Cosmos DB
81+
# Use cosmosSearch for vector operations in DocumentDB
8282
"cosmosSearch": {
8383
# Query vector to find similar documents for
8484
"vector": query_embedding,

ai/vector-search-python/src/ivf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ def create_ivf_vector_index(collection, vector_field: str, dimensions: int) -> N
1414
# Drop any existing vector indexes on this field first
1515
drop_vector_indexes(collection, vector_field)
1616

17-
# Use the native MongoDB command for Cosmos DB vector indexes
17+
# Use the native MongoDB command for DocumentDB vector indexes
1818
index_command = {
1919
"createIndexes": collection.name,
2020
"indexes": [
2121
{
2222
"name": f"ivf_index_{vector_field}",
2323
"key": {
24-
vector_field: "cosmosSearch" # Cosmos DB vector search index type
24+
vector_field: "cosmosSearch" # DocumentDB vector search index type
2525
},
2626
"cosmosSearchOptions": {
2727
# IVF algorithm configuration
@@ -75,7 +75,7 @@ def perform_ivf_vector_search(collection,
7575
pipeline = [
7676
{
7777
"$search": {
78-
# Use cosmosSearch for vector operations in Cosmos DB
78+
# Use cosmosSearch for vector operations in DocumentDB
7979
"cosmosSearch": {
8080
# Query vector to find similar documents
8181
"vector": query_embedding,

ai/vector-search-python/src/show_indexes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Display vector indexes for Cosmos DB collections.
2+
Display vector indexes for DocumentDB collections.
33
44
This utility script shows all vector indexes in a collection, including
55
their configuration details, status, and performance characteristics.

ai/vector-search-python/src/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ def fetch(self, context: OIDCCallbackContext) -> OIDCCallbackResult:
2424

2525
def get_clients() -> Tuple[MongoClient, AzureOpenAI]:
2626

27-
# Get MongoDB connection string - required for Cosmos DB access
27+
# Get MongoDB connection string - required for DocumentDB access
2828
mongo_connection_string = os.getenv("MONGO_CONNECTION_STRING")
2929
if not mongo_connection_string:
3030
raise ValueError("MONGO_CONNECTION_STRING environment variable is required")
3131

32-
# Create MongoDB client with optimized settings for Cosmos DB
32+
# Create MongoDB client with optimized settings for DocumentDB
3333
mongo_client = MongoClient(
3434
mongo_connection_string,
3535
maxPoolSize=50, # Allow up to 50 connections for better performance
@@ -95,7 +95,7 @@ def get_clients_passwordless() -> Tuple[MongoClient, AzureOpenAI]:
9595

9696
def azure_identity_token_callback(credential: DefaultAzureCredential) -> str:
9797

98-
# Cosmos DB for MongoDB requires this specific scope
98+
# DocumentDB requires this specific scope
9999
token_scope = "https://cosmos.azure.com/.default"
100100

101101
# Get token from Azure AD

0 commit comments

Comments
 (0)