Skip to content

Commit 183f672

Browse files
authored
Merge pull request #6 from diberry/move-docdb-langs
Move other lang samples
2 parents bceb681 + a093741 commit 183f672

33 files changed

Lines changed: 102285 additions & 0 deletions
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"name": "Azure DocumentDB Vector Search - .NET 8",
3+
"image": "mcr.microsoft.com/devcontainers/dotnet:1-8.0-bookworm",
4+
5+
"features": {
6+
"ghcr.io/devcontainers/features/azure-cli:1": {},
7+
"ghcr.io/devcontainers/features/github-cli:1": {},
8+
"ghcr.io/devcontainers/features/common-utils:2": {
9+
"installZsh": true,
10+
"configureZshAsDefaultShell": true,
11+
"installOhMyZsh": true
12+
}
13+
},
14+
15+
"customizations": {
16+
"vscode": {
17+
"extensions": [
18+
"ms-dotnettools.csdevkit",
19+
"ms-dotnettools.vscodeintellicode-csharp",
20+
"ms-azuretools.vscode-azureresourcegroups",
21+
"ms-azuretools.vscode-cosmosdb",
22+
"mongodb.mongodb-vscode"
23+
],
24+
"settings": {
25+
"dotnet.completion.showCompletionItemsFromUnimportedNamespaces": true,
26+
"files.exclude": {
27+
"**/bin": true,
28+
"**/obj": true
29+
}
30+
}
31+
}
32+
},
33+
34+
"postCreateCommand": "dotnet restore && dotnet build",
35+
"remoteUser": "vscode",
36+
37+
"containerEnv": {
38+
"DOTNET_CLI_TELEMETRY_OPTOUT": "1",
39+
"DOTNET_NOLOGO": "1"
40+
},
41+
42+
"mounts": [
43+
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.azure,target=/home/vscode/.azure,type=bind,consistency=cached"
44+
],
45+
46+
"capAdd": ["SYS_PTRACE"],
47+
"securityOpt": ["seccomp:unconfined"]
48+
}

ai/vector-search-dotnet/.gitignore

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# .NET Core
2+
bin/
3+
obj/
4+
out/
5+
6+
# .NET Framework
7+
*.exe
8+
*.dll
9+
*.pdb
10+
*.cache
11+
*.so
12+
*.dylib
13+
14+
# User-specific files
15+
*.rsuser
16+
*.suo
17+
*.user
18+
*.userosscache
19+
*.sln.docstates
20+
21+
# User-specific files (MonoDevelop/Xamarin Studio)
22+
*.userprefs
23+
24+
# Build results
25+
[Dd]ebug/
26+
[Dd]ebugPublic/
27+
[Rr]elease/
28+
[Rr]eleases/
29+
x64/
30+
x86/
31+
build/
32+
bld/
33+
[Bb]in/
34+
[Oo]bj/
35+
36+
# Visual Studio 2015/2017 cache/options directory
37+
.vs/
38+
39+
# Visual Studio Code
40+
.vscode/
41+
!.vscode/settings.json
42+
!.vscode/tasks.json
43+
!.vscode/launch.json
44+
!.vscode/extensions.json
45+
46+
# JetBrains Rider
47+
.idea/
48+
*.sln.iml
49+
50+
# CodeRush personal settings
51+
.cr/personal
52+
53+
# Python Tools for Visual Studio (PTVS)
54+
__pycache__/
55+
*.pyc
56+
57+
# Cake - Uncomment if you are using it
58+
# tools/**
59+
# !tools/packages.config
60+
61+
# Tabs Studio
62+
*.tss
63+
64+
# Telerik's JustMock configuration file
65+
*.jmconfig
66+
67+
# BizTalk build output
68+
*.btp.cs
69+
*.btm.cs
70+
*.odx.cs
71+
*.xsd.cs
72+
73+
# OpenCover UI analysis results
74+
OpenCover/
75+
76+
# Azure Stream Analytics local run output
77+
ASALocalRun/
78+
79+
# MSBuild Binary and Structured Log
80+
*.binlog
81+
82+
# NVidia Nsight GPU debugger configuration file
83+
*.nvuser
84+
85+
# MFractors (Xamarin productivity tool) working folder
86+
.mfractor/
87+
88+
# Local History for Visual Studio
89+
.localhistory/
90+
91+
# BeatPulse healthcheck temp database
92+
healthchecksdb
93+
94+
# Sensitive configuration files
95+
appsettings.local.json
96+
appsettings.development.json
97+
.env
98+
.env.local
99+
100+
# Azure Functions
101+
local.settings.json
102+
103+
# Azure CLI
104+
.azure/
105+
106+
# Node.js (if any frontend tools are used)
107+
node_modules/
108+
npm-debug.log*
109+
yarn-debug.log*
110+
yarn-error.log*
111+
112+
# Logs
113+
*.log
114+
115+
# OS generated files
116+
.DS_Store
117+
.DS_Store?
118+
._*
119+
.Spotlight-V100
120+
.Trashes
121+
ehthumbs.db
122+
Thumbs.db
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<Nullable>enable</Nullable>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Azure.AI.OpenAI" Version="2.1.0" />
12+
<PackageReference Include="Azure.Identity" Version="1.13.1" />
13+
<PackageReference Include="MongoDB.Driver" Version="3.0.0" />
14+
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
15+
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.2" />
16+
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
17+
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" />
18+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
19+
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.1" />
20+
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.1" />
21+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
22+
</ItemGroup>
23+
24+
<ItemGroup>
25+
<Content Include="appsettings.json">
26+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
27+
</Content>
28+
<Content Include="data\**\*">
29+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
30+
</Content>
31+
</ItemGroup>
32+
33+
</Project>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
namespace CosmosDbVectorSamples.Models;
2+
3+
public class AppConfiguration
4+
{
5+
public AzureOpenAIConfiguration AzureOpenAI { get; set; } = new();
6+
public DataFilesConfiguration DataFiles { get; set; } = new();
7+
public EmbeddingConfiguration Embedding { get; set; } = new();
8+
public MongoDBConfiguration MongoDB { get; set; } = new();
9+
public VectorSearchConfiguration VectorSearch { get; set; } = new();
10+
}
11+
12+
public class AzureOpenAIConfiguration
13+
{
14+
public string EmbeddingModel { get; set; } = string.Empty;
15+
public string ApiVersion { get; set; } = string.Empty;
16+
public string Endpoint { get; set; } = string.Empty;
17+
// Note: API Key removed - using Microsoft Entra ID authentication via DefaultAzureCredential
18+
}
19+
20+
public class DataFilesConfiguration
21+
{
22+
public string WithoutVectors { get; set; } = string.Empty;
23+
public string WithVectors { get; set; } = string.Empty;
24+
}
25+
26+
public class EmbeddingConfiguration
27+
{
28+
public string FieldToEmbed { get; set; } = string.Empty;
29+
public string EmbeddedField { get; set; } = string.Empty;
30+
public int Dimensions { get; set; }
31+
public int BatchSize { get; set; }
32+
}
33+
34+
public class MongoDBConfiguration
35+
{
36+
public string ConnectionString { get; set; } = string.Empty;
37+
public string ClusterName { get; set; } = string.Empty;
38+
public int LoadBatchSize { get; set; }
39+
public string TenantId { get; set; } = string.Empty;
40+
}
41+
42+
public class VectorSearchConfiguration
43+
{
44+
public string Query { get; set; } = string.Empty;
45+
public string DatabaseName { get; set; } = string.Empty;
46+
public int TopK { get; set; }
47+
}
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
using MongoDB.Bson;
2+
using MongoDB.Bson.Serialization.Attributes;
3+
using Newtonsoft.Json;
4+
5+
namespace CosmosDbVectorSamples.Models;
6+
7+
public class HotelData
8+
{
9+
[BsonId]
10+
[JsonProperty("_id")]
11+
public ObjectId Id { get; set; }
12+
13+
[JsonProperty("HotelId")]
14+
public string? HotelId { get; set; }
15+
16+
[JsonProperty("HotelName")]
17+
public string? HotelName { get; set; }
18+
19+
[JsonProperty("Description")]
20+
public string? Description { get; set; }
21+
22+
[JsonProperty("Description_fr")]
23+
public string? DescriptionFr { get; set; }
24+
25+
[JsonProperty("Category")]
26+
public string? Category { get; set; }
27+
28+
[JsonProperty("Tags")]
29+
public List<string>? Tags { get; set; }
30+
31+
[JsonProperty("ParkingIncluded")]
32+
public bool? ParkingIncluded { get; set; }
33+
34+
[JsonProperty("SmokingAllowed")]
35+
public bool? SmokingAllowed { get; set; }
36+
37+
[JsonProperty("LastRenovationDate")]
38+
public DateTime? LastRenovationDate { get; set; }
39+
40+
[JsonProperty("Rating")]
41+
public double? Rating { get; set; }
42+
43+
[JsonProperty("Location")]
44+
public LocationData? Location { get; set; }
45+
46+
[JsonProperty("Address")]
47+
public AddressData? Address { get; set; }
48+
49+
[JsonProperty("Rooms")]
50+
public List<RoomData>? Rooms { get; set; }
51+
52+
// Embedding fields - will be added dynamically based on configuration
53+
[BsonExtraElements]
54+
[JsonExtensionData]
55+
public Dictionary<string, object>? ExtraElements { get; set; }
56+
}
57+
58+
public class LocationData
59+
{
60+
[JsonProperty("type")]
61+
public string? Type { get; set; }
62+
63+
[JsonProperty("coordinates")]
64+
public List<double>? Coordinates { get; set; }
65+
}
66+
67+
public class AddressData
68+
{
69+
[JsonProperty("StreetAddress")]
70+
public string? StreetAddress { get; set; }
71+
72+
[JsonProperty("City")]
73+
public string? City { get; set; }
74+
75+
[JsonProperty("StateProvince")]
76+
public string? StateProvince { get; set; }
77+
78+
[JsonProperty("PostalCode")]
79+
public string? PostalCode { get; set; }
80+
81+
[JsonProperty("Country")]
82+
public string? Country { get; set; }
83+
}
84+
85+
public class RoomData
86+
{
87+
[JsonProperty("Description")]
88+
public string? Description { get; set; }
89+
90+
[JsonProperty("Description_fr")]
91+
public string? DescriptionFr { get; set; }
92+
93+
[JsonProperty("Type")]
94+
public string? Type { get; set; }
95+
96+
[JsonProperty("BaseRate")]
97+
public double? BaseRate { get; set; }
98+
99+
[JsonProperty("BedOptions")]
100+
public string? BedOptions { get; set; }
101+
102+
[JsonProperty("SleepsCount")]
103+
public int? SleepsCount { get; set; }
104+
105+
[JsonProperty("SmokingAllowed")]
106+
public bool? SmokingAllowed { get; set; }
107+
108+
[JsonProperty("Tags")]
109+
public List<string>? Tags { get; set; }
110+
}
111+
112+
public class SearchResult
113+
{
114+
public HotelData? Document { get; set; }
115+
public double Score { get; set; }
116+
}
117+
118+
public class InsertSummary
119+
{
120+
public int Total { get; set; }
121+
public int Inserted { get; set; }
122+
public int Updated { get; set; }
123+
public int Skipped { get; set; }
124+
public int Failed { get; set; }
125+
}

0 commit comments

Comments
 (0)