Skip to content

Commit 7441e53

Browse files
Copilotdiberry
andcommitted
Correct branding from Cosmos DB to DocumentDB across all projects
Co-authored-by: diberry <41597107+diberry@users.noreply.github.com>
1 parent 1b7f077 commit 7441e53

20 files changed

Lines changed: 95 additions & 94 deletions

File tree

ai/vector-search-dotnet/.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "Cosmos DB Vector Search - .NET 8",
2+
"name": "Azure DocumentDB Vector Search - .NET 8",
33
"image": "mcr.microsoft.com/devcontainers/dotnet:1-8.0-bookworm",
44

55
"features": {

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: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
# Cosmos DB Vector Search Sample
1+
# DocumentDB Vector Search Sample
22

3-
This .NET 8.0 sample application demonstrates vector similarity searches using Cosmos DB 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 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-
- Cosmos DB account
16+
- Azure DocumentDB account
1717
- Azure OpenAI Service with text-embedding-ada-002 model deployed
1818

1919
### Development Environment
2020

2121
- .NET 8.0 SDK
2222
- Visual Studio Code or Visual Studio 2022
2323
- Azure CLI
24-
- [Cosmos DB for VS Code](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-documentdb)
24+
- [Azure DocumentDB for VS Code](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-documentdb)
2525

2626
## Setup
2727

@@ -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-
- [Cosmos DB 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/.env.example

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ EMBEDDING_DIMENSIONS=1536
4545
# Number of records to load per batch during data insertion
4646
LOAD_SIZE_BATCH=100
4747

48-
# Cosmos DB Configuration
48+
# DocumentDB Configuration
4949

50-
# Cosmos DB connection string
50+
# DocumentDB connection string
5151
MONGO_CONNECTION_STRING=mongodb+srv://username:password@cluster.mongocluster.cosmos.azure.com/?tls=true&authMechanism=SCRAM-SHA-256&retrywrites=false&maxIdleTimeMS=120000
5252

53-
# Name of the Cosmos DB cluster
53+
# Name of the DocumentDB cluster
5454
MONGO_CLUSTER_NAME=vectorSearch
5555

5656
# Example connection string format:

ai/vector-search-go/README.md

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

3-
This project demonstrates vector search capabilities using Cosmos DB with Go. 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 Go. 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
10+
- Store vectors in Azure DocumentDB
1111
- Create and use different types of vector indexes
1212
- Perform similarity searches with various algorithms
1313
- Handle authentication using Azure Active Directory (passwordless) or connection strings
@@ -19,7 +19,7 @@ Before running this project, you need:
1919
### Azure Resources
2020
1. **Azure subscription** with appropriate permissions
2121
2. **Azure OpenAI resource** with embedding model deployment
22-
3. **Cosmos DB resource**
22+
3. **Azure DocumentDB resource**
2323
4. **Azure CLI** installed and configured
2424

2525
### Development Environment
@@ -70,9 +70,9 @@ az cognitiveservices account create \
7070
4. Choose **text-embedding-ada-002** model
7171
5. Note the deployment name for configuration
7272

73-
#### Create Cosmos DB Resource
73+
#### Create Azure DocumentDB Resource
7474

75-
Create a Cosmos DB cluster by using the [Azure portal](https://learn.microsoft.com/azure/documentdb/quickstart-portal), [Bicep](https://learn.microsoft.com/azure/documentdb/quickstart-bicep), or [Terraform](https://learn.microsoft.com/azure/documentdb/quickstart-terraform).
75+
Create a Azure DocumentDB cluster by using the [Azure portal](https://learn.microsoft.com/azure/documentdb/quickstart-portal), [Bicep](https://learn.microsoft.com/azure/documentdb/quickstart-bicep), or [Terraform](https://learn.microsoft.com/azure/documentdb/quickstart-terraform).
7676

7777
### Step 3: Get Your Connection Information
7878

@@ -91,9 +91,9 @@ az cognitiveservices account keys list \
9191
--query "key1" --output tsv
9292
```
9393

94-
#### Cosmos DB Connection String
94+
#### DocumentDB Connection String
9595
```bash
96-
# Get Cosmos DB connection string
96+
# Get DocumentDB connection string
9797
az resource show \
9898
--resource-group "<resource-group>" \
9999
--name "<cluster-name>" \
@@ -119,7 +119,7 @@ AZURE_OPENAI_EMBEDDING_ENDPOINT=https://your-openai-resource.openai.azure.com/
119119
AZURE_OPENAI_EMBEDDING_KEY=your-azure-openai-api-key
120120
AZURE_OPENAI_EMBEDDING_API_VERSION=2024-02-01
121121
122-
# Cosmos DB Configuration
122+
# DocumentDB Configuration
123123
MONGO_CONNECTION_STRING=mongodb+srv://username:password@your-cluster.mongocluster.cosmos.azure.com/?tls=true&authMechanism=SCRAM-SHA-256&retrywrites=false&maxIdleTimeMS=120000
124124
MONGO_CLUSTER_NAME=vectorSearch
125125
@@ -136,10 +136,10 @@ LOAD_SIZE_BATCH=100
136136
### Step 5: Configure passwordless authentication (optional)
137137
To use passwordless authentication with Microsoft Entra ID, follow these steps:
138138

139-
1. In your Cosmos DB resource, enable **Native Cosmos DB** 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**
142-
- **Cosmos DB Account Contributor**
139+
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 DocumentDB resource:
141+
- **DocumentDB Account Reader Role**
142+
- **DocumentDB Account Contributor**
143143

144144
## Usage
145145

@@ -211,7 +211,7 @@ This utility shows:
211211
## Important Notes
212212

213213
### Vector Index Limitations
214-
**One Index Per Field**: Cosmos DB allows only one vector index per field. Each script automatically handles this by:
214+
**One Index Per Field**: Azure DocumentDB allows only one vector index per field. Each script automatically handles this by:
215215

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

244244
## Authentication Options
245245

@@ -268,8 +268,8 @@ defer mongoClient.Disconnect(ctx)
268268
**Setup for passwordless authentication:**
269269

270270
1. Ensure you're logged in with `az login`
271-
2. Enable **Native Cosmos DB and Microsoft Entra ID authentication** methods for your Cosmos DB resource.
272-
3. Grant your identity appropriate RBAC permissions on your Cosmos DB instance. You need **Cosmos DB Account Reader Role** and **Cosmos DB Account Contributor** roles assigned to your user.
271+
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 **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
@@ -332,8 +332,8 @@ mongo-vcore-vector-search-go/
332332

333333
1. **Authentication Errors**
334334
- Verify Azure OpenAI endpoint and key
335-
- Check Cosmos DB connection string
336-
- Ensure proper RBAC permissions for passwordless authentication. You need **Cosmos DB Account Reader Role** and **Cosmos DB Account Contributor** roles assigned to your user. Roles may take some time to propagate.
335+
- Check Azure DocumentDB connection string
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
@@ -375,9 +375,9 @@ DEBUG=true
375375

376376
## Further Resources
377377

378-
- [Cosmos DB Documentation](https://learn.microsoft.com/azure/documentdb/)
378+
- [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-go/src/diskann.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ func CreateDiskANNVectorIndex(ctx context.Context, collection *mongo.Collection,
2323
fmt.Printf("Warning: Could not drop existing indexes: %v\n", err)
2424
}
2525

26-
// Use the native MongoDB command for Cosmos DB vector indexes
26+
// Use the native MongoDB command for DocumentDB vector indexes
2727
// Note: Must use bson.D for commands to preserve order and avoid "multi-key map" errors
2828
indexCommand := bson.D{
2929
{"createIndexes", collection.Name()},
3030
{"indexes", []bson.D{
3131
{
3232
{"name", fmt.Sprintf("diskann_index_%s", vectorField)},
3333
{"key", bson.D{
34-
{vectorField, "cosmosSearch"}, // Cosmos DB vector search index type
34+
{vectorField, "cosmosSearch"}, // DocumentDB vector search index type
3535
}},
3636
{"cosmosSearchOptions", bson.D{
3737
// DiskANN algorithm configuration
@@ -63,7 +63,7 @@ func CreateDiskANNVectorIndex(ctx context.Context, collection *mongo.Collection,
6363
if strings.Contains(err.Error(), "not enabled for this cluster tier") {
6464
fmt.Println("\nDiskANN indexes require a higher cluster tier.")
6565
fmt.Println("Try one of these alternatives:")
66-
fmt.Println(" • Upgrade your Cosmos DB cluster to a higher tier")
66+
fmt.Println(" • Upgrade your DocumentDB cluster to a higher tier")
6767
fmt.Println(" • Use HNSW instead: go run src/hnsw.go")
6868
fmt.Println(" • Use IVF instead: go run src/ivf.go")
6969
}
@@ -85,11 +85,11 @@ func PerformDiskANNVectorSearch(ctx context.Context, collection *mongo.Collectio
8585
}
8686

8787
// Construct the aggregation pipeline for vector search
88-
// Cosmos DB uses $search with cosmosSearch
88+
// DocumentDB uses $search with cosmosSearch
8989
pipeline := []bson.M{
9090
{
9191
"$search": bson.M{
92-
// Use cosmosSearch for vector operations in Cosmos DB
92+
// Use cosmosSearch for vector operations in DocumentDB
9393
"cosmosSearch": bson.M{
9494
// The query vector to search for
9595
"vector": queryEmbedding,

ai/vector-search-go/src/hnsw.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ func CreateHNSWVectorIndex(ctx context.Context, collection *mongo.Collection, ve
2222
fmt.Printf("Warning: Could not drop existing indexes: %v\n", err)
2323
}
2424

25-
// Use the native MongoDB command for Cosmos DB vector indexes
25+
// Use the native MongoDB command for DocumentDB vector indexes
2626
// Note: Must use bson.D for commands to preserve order and avoid "multi-key map" errors
2727
indexCommand := bson.D{
2828
{"createIndexes", collection.Name()},
2929
{"indexes", []bson.D{
3030
{
3131
{"name", fmt.Sprintf("hnsw_index_%s", vectorField)},
3232
{"key", bson.D{
33-
{vectorField, "cosmosSearch"}, // Cosmos DB vector search index type
33+
{vectorField, "cosmosSearch"}, // DocumentDB vector search index type
3434
}},
3535
{"cosmosSearchOptions", bson.D{
3636
// HNSW algorithm configuration
@@ -62,7 +62,7 @@ func CreateHNSWVectorIndex(ctx context.Context, collection *mongo.Collection, ve
6262
if strings.Contains(err.Error(), "not enabled for this cluster tier") {
6363
fmt.Println("\nHNSW indexes require a higher cluster tier.")
6464
fmt.Println("Try one of these alternatives:")
65-
fmt.Println(" • Upgrade your Cosmos DB cluster to a higher tier")
65+
fmt.Println(" • Upgrade your DocumentDB cluster to a higher tier")
6666
fmt.Println(" • Use IVF instead: go run src/ivf.go")
6767
fmt.Println(" • Use DiskANN instead: go run src/diskann.go")
6868
}
@@ -84,11 +84,11 @@ func PerformHNSWVectorSearch(ctx context.Context, collection *mongo.Collection,
8484
}
8585

8686
// Build aggregation pipeline for HNSW vector search
87-
// Cosmos DB uses $search with cosmosSearch
87+
// DocumentDB uses $search with cosmosSearch
8888
pipeline := []bson.M{
8989
{
9090
"$search": bson.M{
91-
// Use cosmosSearch for vector operations in Cosmos DB
91+
// Use cosmosSearch for vector operations in DocumentDB
9292
"cosmosSearch": bson.M{
9393
// Query vector to find similar documents for
9494
"vector": queryEmbedding,

ai/vector-search-go/src/ivf.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ func CreateIVFVectorIndex(ctx context.Context, collection *mongo.Collection, vec
2222
fmt.Printf("Warning: Could not drop existing indexes: %v\n", err)
2323
}
2424

25-
// Use the native MongoDB command for Cosmos DB vector indexes
25+
// Use the native MongoDB command for DocumentDB vector indexes
2626
// Note: Must use bson.D for commands to preserve order and avoid "multi-key map" errors
2727
indexCommand := bson.D{
2828
{"createIndexes", collection.Name()},
2929
{"indexes", []bson.D{
3030
{
3131
{"name", fmt.Sprintf("ivf_index_%s", vectorField)},
3232
{"key", bson.D{
33-
{vectorField, "cosmosSearch"}, // Cosmos DB vector search index type
33+
{vectorField, "cosmosSearch"}, // DocumentDB vector search index type
3434
}},
3535
{"cosmosSearchOptions", bson.D{
3636
// IVF algorithm configuration
@@ -59,7 +59,7 @@ func CreateIVFVectorIndex(ctx context.Context, collection *mongo.Collection, vec
5959
if strings.Contains(err.Error(), "not enabled for this cluster tier") {
6060
fmt.Println("\nIVF indexes require a higher cluster tier.")
6161
fmt.Println("Try one of these alternatives:")
62-
fmt.Println(" • Upgrade your Cosmos DB cluster to a higher tier")
62+
fmt.Println(" • Upgrade your DocumentDB cluster to a higher tier")
6363
fmt.Println(" • Use HNSW instead: go run src/hnsw.go")
6464
fmt.Println(" • Use DiskANN instead: go run src/diskann.go")
6565
}
@@ -81,11 +81,11 @@ func PerformIVFVectorSearch(ctx context.Context, collection *mongo.Collection, o
8181
}
8282

8383
// Construct aggregation pipeline for IVF vector search
84-
// Cosmos DB uses $search with cosmosSearch
84+
// DocumentDB uses $search with cosmosSearch
8585
pipeline := []bson.M{
8686
{
8787
"$search": bson.M{
88-
// Use cosmosSearch for vector operations in Cosmos DB
88+
// Use cosmosSearch for vector operations in DocumentDB
8989
"cosmosSearch": bson.M{
9090
// Query vector to find similar documents
9191
"vector": queryEmbedding,

ai/vector-search-go/src/show_indexes.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ func formatIndexInfo(indexInfo IndexInfo) string {
3232
}
3333
lines = append(lines, fmt.Sprintf("Index Name: %s", name))
3434

35-
// Check if this is a vector index by looking for Cosmos DB vector search configuration
35+
// Check if this is a vector index by looking for DocumentDB vector search configuration
3636
if indexInfo.CosmosSearchOptions != nil && len(indexInfo.CosmosSearchOptions) > 0 {
37-
lines = append(lines, "Type: Cosmos DB Vector Search Index")
37+
lines = append(lines, "Type: DocumentDB Vector Search Index")
3838

3939
// Vector search specific details
4040
if similarity, ok := indexInfo.CosmosSearchOptions["similarity"]; ok {

0 commit comments

Comments
 (0)