.NET: Hosted Agents - RAG Sample with Azure AI Search (#5693)#5701
Open
rogerbarreto wants to merge 2 commits intomicrosoft:mainfrom
Open
Conversation
Adds a Hosted-AzureSearchRag sample plus a live Foundry.Hosting integration test scenario backed by a real Azure AI Search index. Sample (Hosted-AzureSearchRag): keyword-only Azure AI Search via SearchClient adapter into TextSearchProvider, scope-aware DevTemporaryTokenCredential consuming AZURE_BEARER_TOKEN_FOUNDRY + AZURE_BEARER_TOKEN_SEARCH for local Docker, Dockerfile + contributor Dockerfile mirroring Hosted-TextRag. Integration test: AzureSearchRagHostedAgentFixture extends the PR microsoft#5598 HostedAgentFixture with the new azure-search-rag scenario branch in the shared test container; AzureSearchRagHostedAgentTests asserts the model returns canary tokens (TR-CANARY-7821, SHIP-CANARY-4493) that exist only in the seeded documents - real proof the agent grounded its answer in retrieved content rather than training data.
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a new Hosted Agents RAG sample backed by Azure AI Search, and extends the Foundry.Hosting live integration tests + CI to validate grounding via canary tokens.
Changes:
- Introduces
Hosted-AzureSearchRagsample (agent YAML/manifest, .NET app, Dockerfiles, env template, and provisioning README). - Adds a new
azure-search-ragintegration test scenario (fixture + tests) and wires it into the test container. - Updates bootstrap/docs, central packages, solution, and CI workflow to support Azure AI Search configuration.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| dotnet/tests/Foundry.Hosting.IntegrationTests/scripts/it-bootstrap-agents.ps1 | Adds scenario name and documents that data-plane RBAC is manual/out-of-band. |
| dotnet/tests/Foundry.Hosting.IntegrationTests/README.md | Documents new AZURE_SEARCH_* vars + manual Search RBAC + index prerequisite steps. |
| dotnet/tests/Foundry.Hosting.IntegrationTests/Foundry.Hosting.IntegrationTests.csproj | Adds Azure AI Search SDK dependency for integration test project. |
| dotnet/tests/Foundry.Hosting.IntegrationTests/Fixtures/AzureSearchRagHostedAgentFixture.cs | New fixture to provision hosted agent env vars for the Search-backed scenario. |
| dotnet/tests/Foundry.Hosting.IntegrationTests/AzureSearchRagHostedAgentTests.cs | New live canary-token grounding tests for the Search-backed scenario. |
| dotnet/tests/Foundry.Hosting.IntegrationTests.TestContainer/Program.cs | Adds azure-search-rag scenario branch and SearchClient→TextSearchProvider adapter. |
| dotnet/tests/Foundry.Hosting.IntegrationTests.TestContainer/Foundry.Hosting.IntegrationTests.TestContainer.csproj | Adds Azure AI Search SDK dependency for the test container. |
| dotnet/src/Shared/IntegrationTests/TestSettings.cs | Adds shared constants for AZURE_SEARCH_ENDPOINT / AZURE_SEARCH_INDEX_NAME. |
| dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-AzureSearchRag/agent.yaml | New hosted agent YAML for the sample. |
| dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-AzureSearchRag/agent.manifest.yaml | New manifest metadata/template for the sample. |
| dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-AzureSearchRag/README.md | New sample documentation including index schema + provisioning snippet. |
| dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-AzureSearchRag/Program.cs | New sample app: Search-backed TextSearchProvider + scope-aware dev credential. |
| dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-AzureSearchRag/HostedAzureSearchRag.csproj | New sample project file with Azure SDK dependencies and local ProjectReferences. |
| dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-AzureSearchRag/Dockerfile.contributor | Contributor docker flow using pre-published output. |
| dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-AzureSearchRag/Dockerfile | Standard multi-stage docker build for package consumers. |
| dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-AzureSearchRag/.env.example | Adds sample env var template including Search settings + dev token placeholders. |
| dotnet/agent-framework-dotnet.slnx | Adds the new sample project to the solution. |
| dotnet/Directory.Packages.props | Pins Azure.Search.Documents version centrally. |
| .github/workflows/dotnet-build-and-test.yml | Extends paths filter + injects AZURE_SEARCH_* secrets for integration tests. |
- Sample README: drop stale 'bootstraps the index on first run' line; index is pre-provisioned out of band - Sample + TestContainer search adapters: propagate CancellationToken to await foreach via .WithCancellation()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #5693.
Adds a hosted-agent RAG sample backed by Azure AI Search, plus a live Foundry.Hosting integration test scenario with canary-token assertions that prove the model grounded its answer in retrieved content (not training data).
Sample (
Hosted-AzureSearchRag)SearchClientadapter intoTextSearchProvider(keyword-only, no embeddings)DevTemporaryTokenCredentialconsumingAZURE_BEARER_TOKEN_FOUNDRY+AZURE_BEARER_TOKEN_SEARCH(single chained credential serves both clients in local Docker)Hosted-TextRagstructure (Dockerfile, contributor Dockerfile,.env.example,agent.yaml,agent.manifest.yaml)Integration test (
Foundry.Hosting.IntegrationTests)AzureSearchRagHostedAgentFixtureextendsHostedAgentFixturewith theazure-search-ragscenario branch in the sharedTestContainer/Program.csTR-CANARY-7821,SHIP-CANARY-4493) that exist only in the seeded Contoso Outdoors documentstao-foundry-prj+aisearch-integration-test-basic: 3/3 passed in 30sAZURE_SEARCH_ENDPOINT/AZURE_SEARCH_INDEX_NAME(reuses existing integration secrets shared withpython-sample-validation.yml)One-time bootstrap (documented, not scripted)
The
it-azure-search-ragagent's MI needsSearch Index Data Readeron the search service;it-bootstrap-agents.ps1notes this and the IT README has copy-pasteableaz role assignment createtemplate plus theaadOrApiKeyflip command for services stuck on key-only auth.Out of scope (follow-ups)
Microsoft.Agents.AI.AzureAISearchpackageHosted-TextRag'sDevTemporaryTokenCredentialto be scope-aware