Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"ms-azuretools.vscode-cosmosdb",
"buildwithlayer.mongodb-integration-expert-qS6DB",
"mongodb.mongodb-vscode",
"ms-azuretools.vscode-documentdb"
"ms-azuretools.vscode-documentdb",
"ms-azuretools.vscode-bicep"
]
}
}
Expand Down
3 changes: 2 additions & 1 deletion .devcontainer/python/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"ms-azuretools.vscode-cosmosdb",
"buildwithlayer.mongodb-integration-expert-qS6DB",
"mongodb.mongodb-vscode",
"ms-azuretools.vscode-documentdb"
"ms-azuretools.vscode-documentdb",
"ms-azuretools.vscode-bicep"
]
}
}
Expand Down
3 changes: 2 additions & 1 deletion .devcontainer/typescript/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"ms-azuretools.vscode-cosmosdb",
"buildwithlayer.mongodb-integration-expert-qS6DB",
"mongodb.mongodb-vscode",
"ms-azuretools.vscode-documentdb"
"ms-azuretools.vscode-documentdb",
"ms-azuretools.vscode-bicep"
]
}
}
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -432,4 +432,5 @@ FodyWeavers.xsd
# TypeScript
dist/
build/
node_modules/
node_modules/
.tsbuildinfo*
44 changes: 44 additions & 0 deletions azure.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: DocumentDB AI samples

infra:
bicep:
path: ./infra/main.bicep
parameters:
principalId: ${AZURE_PRINCIPAL_ID}

hooks:

postprovision:
posix:
shell: sh
run: |
# Get environment values for the application
azd env get-values > .env
echo "" >> .env
echo "# Application default configuration" >> .env
cat ./mongo-vcore-agent-langchain/.env.default >> .env
echo "Environment configured with Azure and application defaults."
windows:
shell: pwsh
run: |
azd env get-values > .env
Add-Content -Path .env -Value ""
Add-Content -Path .env -Value "# Application default configuration"
Get-Content ./mongo-vcore-agent-langchain/.env.default | Add-Content -Path .env
Write-Host "Environment configured with Azure and application defaults."

postdown:
posix:
shell: sh
run: |
echo "Cleaning up environment file..."
rm -f .env
echo "Environment file removed."
windows:
shell: pwsh
run: |
Write-Host "Cleaning up environment file..."
Remove-Item -Path .env -ErrorAction SilentlyContinue
Write-Host "Environment file removed."

services:
24 changes: 24 additions & 0 deletions cosmos-db-vector-samples.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.2.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CosmosDbVectorSamples", "mongo-vcore-vector-search-dotnet\CosmosDbVectorSamples.csproj", "{5DFBA6DE-760C-46C5-1241-FF6858E38D2A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5DFBA6DE-760C-46C5-1241-FF6858E38D2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5DFBA6DE-760C-46C5-1241-FF6858E38D2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5DFBA6DE-760C-46C5-1241-FF6858E38D2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5DFBA6DE-760C-46C5-1241-FF6858E38D2A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7FA967F3-BD13-4E70-A069-41D47548F917}
EndGlobalSection
EndGlobal
118 changes: 118 additions & 0 deletions infra/documentdb.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
metadata description = 'Provisions resources for an Azure Cosmos DB for MongoDB vCore cluster.'

@description('The name of the Azure Cosmos DB for MongoDB vCore cluster.')
param name string

@description('Primary location for the resources.')
param location string

@description('Tags to be applied to the resource.')
param tags object

@description('Principal identifier of the identity that is deploying the template.')
param principalId string

@description('Principal identifier of the identity that is used for the web application.')
param managedIdentityPrincipalId string

@description('The password for the administrator login.')
param mongoAdmin string = 'app'

@secure()
@description('The password for the administrator login.')
param mongoPassword string = newGuid()

@description('Indicates if the deployment is being executed from a pipeline.')
param pipeline bool = false

resource mongoCluster 'Microsoft.DocumentDB/mongoClusters@2025-04-01-preview' = {
name: name
location: location
tags: tags
properties: {
administrator: {
userName: mongoAdmin
password: mongoPassword
}
compute: {
tier: 'M10'
}
sharding: {
shardCount: 1
}
storage: {
sizeGb: 32
}
highAvailability: {
targetMode: 'Disabled'
}
publicNetworkAccess: 'Enabled'
authConfig: {
allowedModes: [
'MicrosoftEntraID'
'NativeAuth'
]
}
}
}

resource mongoClusterUserManagedIdentity 'Microsoft.DocumentDB/mongoClusters/users@2025-04-01-preview' = {
parent: mongoCluster
name: managedIdentityPrincipalId
properties: {
identityProvider: {
type: 'MicrosoftEntraID'
properties: {
principalType: 'ServicePrincipal'
}
}
roles: [
{
db: 'admin'
role: 'dbOwner'
}
]
}
}

resource mongoClusterUserDeploymentIdentity 'Microsoft.DocumentDB/mongoClusters/users@2025-04-01-preview' = if (!pipeline && principalId != '' && principalId != managedIdentityPrincipalId) {
parent: mongoCluster
name: principalId
properties: {
identityProvider: {
type: 'MicrosoftEntraID'
properties: {
principalType: 'User'
}
}
roles: [
{
db: 'admin'
role: 'dbOwner'
}
]
}
}

resource mongoClusterFirewallAllowAzure 'Microsoft.DocumentDB/mongoClusters/firewallRules@2025-04-01-preview' = {
parent: mongoCluster
name: 'allow-azure-services'
properties: {
startIpAddress: '0.0.0.0'
endIpAddress: '0.0.0.0'
}
}

resource mongoClusterFirewallAllowAll 'Microsoft.DocumentDB/mongoClusters/firewallRules@2025-04-01-preview' = {
parent: mongoCluster
name: 'allow-all-ip-addresses'
properties: {
startIpAddress: '0.0.0.0'
endIpAddress: '255.255.255.255'
}
}

output name string = mongoCluster.name
output resourceId string = mongoCluster.id
output endpoint string = '${mongoCluster.name}.global.mongocluster.cosmos.azure.com'
output connectionString string = 'mongodb://${mongoAdmin}:${mongoPassword}@${mongoCluster.name}.global.mongocluster.cosmos.azure.com:10255/?ssl=true&replicaSet=globaldb&retrywrites=false&maxIdleTimeMS=120000&appName=@${mongoCluster.name}@'
Loading