Skip to content

Use string keys for Azure AI Search in the aichatweb template - #7789

Open
Laurianti wants to merge 1 commit into
dotnet:mainfrom
Laurianti:fix-aichatweb-key-type
Open

Laurianti wants to merge 1 commit into
dotnet:mainfrom
Laurianti:fix-aichatweb-key-type

Conversation

@Laurianti

@Laurianti Laurianti commented Sep 27, 2026 •

Copy link
Copy Markdown

Why

Since #7804, SemanticSearch takes a VectorStoreCollection<Guid, IngestedChunk> for every vector store. With Azure AI Search, Program.cs registers the collection with AddAzureAISearchCollection<IngestedChunk>, which only registers string keys. A project created with dotnet new aichatweb --vector-store azureaisearch then stops at startup:

System.InvalidOperationException: Unable to resolve service for type 'Microsoft.Extensions.VectorData.VectorStoreCollection`2[System.Guid,ChatApp.Services.IngestedChunk]' while attempting to activate 'ChatApp.Services.SemanticSearch'.

Change

With Azure AI Search, IngestedChunk.Key and the collection that SemanticSearch takes are now string, as the registration. The local vector store and Qdrant keep Guid keys.

--vector-store azureaisearch Before Now
IngestedChunk.Key Guid string
SemanticSearch VectorStoreCollection<Guid, IngestedChunk> VectorStoreCollection<string, IngestedChunk>
App startup fails with the error above starts

VectorStoreWriter still writes Guid keys. Azure AI Search stores keys as strings, so the chunks it writes are read through the string-keyed collection.

The snapshots of the two Azure AI Search configurations are updated.

I generated dotnet new aichatweb --provider openai --vector-store azureaisearch --managed-identity false from the template package built from main and from this branch. On main the app stops at startup with the error above; with this change it starts. The snapshot tests pass (5/5).

Microsoft Reviewers: Open in CodeFlow

@Laurianti
Laurianti requested a review from a team as a code owner September 27, 2026 18:58
@github-actions github-actions Bot added the area-ai-templates Microsoft.Extensions.AI.Templates label Sep 27, 2026
@dotnet-comment-bot

Copy link
Copy Markdown
Collaborator

‼️ Found issues ‼️

Project Coverage Type Expected Actual
Microsoft.Extensions.Diagnostics.Testing Line 99 98.65 🔻
Microsoft.Extensions.Telemetry Line 93 92.64 🔻
Microsoft.Extensions.AI.OpenAI Line 75 68.32 🔻
Microsoft.Extensions.AI.OpenAI Branch 75 57.59 🔻
Microsoft.Extensions.DataIngestion.MarkItDown Line 75 4.46 🔻
Microsoft.Extensions.DataIngestion.MarkItDown Branch 75 0 🔻
Microsoft.Extensions.Diagnostics.ResourceMonitoring Line 99 96.03 🔻
Microsoft.Extensions.Diagnostics.ResourceMonitoring Branch 99 92.76 🔻
Microsoft.Extensions.Diagnostics.ResourceMonitoring.Kubernetes Line 99 97.73 🔻
Microsoft.Extensions.ServiceDiscovery.Dns Line 75 69.93 🔻
Microsoft.Extensions.ServiceDiscovery.Abstractions Line 75 42.11 🔻
Microsoft.Extensions.ServiceDiscovery.Abstractions Branch 75 42.86 🔻
Microsoft.Extensions.ServiceDiscovery Line 75 68.88 🔻
Microsoft.Extensions.ServiceDiscovery Branch 75 71.43 🔻
Microsoft.Extensions.ServiceDiscovery.Yarp Line 75 73.85 🔻
Microsoft.Extensions.ServiceDiscovery.Yarp Branch 75 70 🔻
Microsoft.Extensions.VectorData.Abstractions Line 75 37.39 🔻
Microsoft.Extensions.VectorData.Abstractions Branch 75 22.73 🔻

🎉 Good job! The coverage increased 🎉
Update MinCodeCoverage in the project files.

Project Expected Actual
Microsoft.Extensions.Http.Diagnostics 94 95
Microsoft.Gen.BuildMetadata 97 100
Microsoft.Gen.MetadataExtractor 57 73
Microsoft.Gen.MetricsReports 67 69
Microsoft.Extensions.AI.Abstractions 82 86
Microsoft.Extensions.AI.Evaluation.NLP 0 78
Microsoft.Extensions.Caching.Hybrid 82 89
Microsoft.Extensions.DataIngestion 75 89
Microsoft.Extensions.DataIngestion.Markdig 75 90
Microsoft.Extensions.Http.Resilience 97 100

Full code coverage report: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1613953&view=codecoverage-tab

Copilot AI balanced review requested due to automatic review settings October 10, 2026 02:41
@Laurianti
Laurianti force-pushed the fix-aichatweb-key-type branch from 984c7e5 to d870cf3 Compare October 10, 2026 02:41
@Laurianti Laurianti changed the title Match the aichatweb vector store key type to the ingested keys Use string keys for Azure AI Search in the aichatweb template Oct 10, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation consistently fixes the registration mismatch while preserving existing key types for other stores.

0 open findings

What changed in this PR

Aligns Azure AI Search template key types with its string-keyed collection registration, preventing generated applications from failing during dependency injection.

Changes:

  • Uses string keys for Azure AI Search collections and records.
  • Preserves Guid keys for local and Qdrant stores.
  • Updates both Azure AI Search snapshots.
File Description
src/​.../​Services/​SemanticSearch.cs Selects the collection key type by vector store.
src/​.../​Services/​IngestedChunk.cs Selects the record key type by vector store.
test/​.../​aichatweb.oai_aais.../​SemanticSearch.cs Updates the non-Aspire snapshot.
test/​.../​aichatweb.oai_aais.../​IngestedChunk.cs Updates its string-key record snapshot.
test/​.../​aichatweb.A_aoai_aais.../​SemanticSearch.cs Updates the Aspire snapshot.
test/​.../​aichatweb.A_aoai_aais.../​IngestedChunk.cs Updates its string-key record snapshot.

🧠 Review effort: Balanced


💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@dotnet-comment-bot

Copy link
Copy Markdown
Collaborator

‼️ Found issues ‼️

Project Coverage Type Expected Actual
Microsoft.Extensions.Diagnostics.Testing Line 99 98.65 🔻
Microsoft.Extensions.Telemetry Line 93 92.32 🔻
Microsoft.Extensions.AI.OpenAI Line 75 68.32 🔻
Microsoft.Extensions.AI.OpenAI Branch 75 57.74 🔻
Microsoft.Extensions.DataIngestion.MarkItDown Line 75 4.46 🔻
Microsoft.Extensions.DataIngestion.MarkItDown Branch 75 0 🔻
Microsoft.Extensions.Diagnostics.ResourceMonitoring Line 99 96.03 🔻
Microsoft.Extensions.Diagnostics.ResourceMonitoring Branch 99 92.76 🔻
Microsoft.Extensions.Diagnostics.ResourceMonitoring.Kubernetes Line 99 97.73 🔻
Microsoft.Extensions.ServiceDiscovery.Dns Line 75 69.93 🔻
Microsoft.Extensions.ServiceDiscovery.Abstractions Line 75 42.11 🔻
Microsoft.Extensions.ServiceDiscovery.Abstractions Branch 75 42.86 🔻
Microsoft.Extensions.ServiceDiscovery Line 75 67.21 🔻
Microsoft.Extensions.ServiceDiscovery Branch 75 71.43 🔻
Microsoft.Extensions.ServiceDiscovery.Yarp Line 75 73.85 🔻
Microsoft.Extensions.ServiceDiscovery.Yarp Branch 75 70 🔻
Microsoft.Extensions.VectorData.Abstractions Line 75 37.39 🔻
Microsoft.Extensions.VectorData.Abstractions Branch 75 22.73 🔻

🎉 Good job! The coverage increased 🎉
Update MinCodeCoverage in the project files.

Project Expected Actual
Microsoft.Extensions.Http.Diagnostics 94 95
Microsoft.Gen.BuildMetadata 97 100
Microsoft.Gen.MetadataExtractor 57 73
Microsoft.Gen.MetricsReports 67 69
Microsoft.Extensions.AI.Abstractions 82 86
Microsoft.Extensions.AI.Evaluation.NLP 0 78
Microsoft.Extensions.Caching.Hybrid 82 85
Microsoft.Extensions.DataIngestion 75 89
Microsoft.Extensions.DataIngestion.Markdig 75 90
Microsoft.Extensions.Http.Resilience 97 100

Full code coverage report: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1630637&view=codecoverage-tab

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-ai-templates Microsoft.Extensions.AI.Templates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants