From 137a79686f91a0430eee3f5b1d7a3c565c841955 Mon Sep 17 00:00:00 2001 From: Roger Barreto <19890735+rogerbarreto@users.noreply.github.com> Date: Fri, 15 May 2026 15:43:29 +0100 Subject: [PATCH 1/2] .NET: Bump Azure.AI.Projects to 2.1.0-beta.2 and add agent-endpoint AsAIAgent path Bumps Azure.AI.Projects to 2.1.0-beta.2 with the matching transitive pins (Azure.Core 1.55.0, System.ClientModel 1.11.0). Foundry agent endpoint plumbing: * FoundryAgent now routes the agent-endpoint constructor through the new GetProjectResponsesClientForAgentEndpoint helper. * Adds an internal FoundryAgent ctor that takes an existing AIProjectClient plus a parsed agent endpoint so the public extension does not need to construct a second project client. * Adds public AIProjectClient.AsAIAgent(Uri agentEndpoint, ...) extension. This is the path consumer samples are expected to use for hosted agents because version selection happens server-side. * Trims the dangling "If you want to construct a FoundryAgent against a project endpoint..." sentence from ParseAgentEndpoint. Unit tests: * Four new tests in AzureAIProjectChatClientExtensionsTests cover the AIProjectClient.AsAIAgent(Uri agentEndpoint, ...) overload. 263/263 pass. Consumer samples (Using-Samples): * SimpleAgent and SessionFilesClient now read AZURE_AI_PROJECT_ENDPOINT and AZURE_AI_AGENT_NAME (both required, throw on missing), derive the agent endpoint with new Uri($"{projectEndpoint}/agents/{agentName}/endpoint/protocols/openai"), then call aiProjectClient.AsAIAgent(agentEndpoint, ...). * SessionFilesClient README updated. Contributor samples (responses/*): * New HostedContributorRouteExtensions.MapDevTemporaryLocalAgentEndpoint() wildcard route extension so localhost contributor servers accept the per-agent OpenAI endpoint shape the production Hosted runtime exposes. * All 11 contributor Program.cs files call MapDevTemporaryLocalAgentEndpoint() with a contributor-only warning comment. * Hosted-Files and Hosted-AzureSearchRag were importing Hosted_Shared_Contributor_Setup but never calling AddDevTemporaryLocalContributorSetup(). Both now call it so HostedSessionIsolationKeyProvider resolves correctly in dev. * Hosted-AzureSearchRag, Hosted-Files, Hosted-MemoryAgent csprojs drop stale VersionOverride="2.1.0-beta.1" pins. * Hosted-AzureSearchRag and Hosted-Files csprojs add ProjectReference to Hosted_Shared_Contributor_Setup. * Hosted-Observability/.dockerignore removed the out/ exclusion that was blocking COPY out/ . in Dockerfile.contributor. Verified: * Full solution-scoped build of changed projects: green. * Scoped CI-parity dotnet format via WSL2 + Docker (mcr.microsoft.com/dotnet/sdk:10.0) over every changed csproj: clean. * Foundry unit tests: 263/263. * Contributor docker smoke for 8 hosted samples (publish + docker build + docker run + curl POST to the wildcard route): HTTP 200 / 500 with route matched. * End-to-end smoke against the real Azure Foundry project with a fresh bearer token: Hosted-Files contributor container served HTTP 200, the agent invoked ListBundledFiles, and returned the expected file name. --- dotnet/Directory.Packages.props | 6 +- .../HostedAzureSearchRag.csproj | 3 +- .../Hosted-AzureSearchRag/Program.cs | 10 +- .../Hosted-ChatClientAgent/Program.cs | 9 +- .../responses/Hosted-Files/HostedFiles.csproj | 5 +- .../responses/Hosted-Files/Program.cs | 10 +- .../responses/Hosted-FoundryAgent/Program.cs | 9 +- .../responses/Hosted-LocalTools/Program.cs | 8 +- .../responses/Hosted-McpTools/Program.cs | 9 +- .../HostedMemoryAgent.csproj | 2 +- .../responses/Hosted-MemoryAgent/Program.cs | 9 +- .../Hosted-Observability/.dockerignore | 1 - .../responses/Hosted-Observability/Program.cs | 8 +- .../responses/Hosted-TextRag/Program.cs | 8 +- .../responses/Hosted-Toolbox/Program.cs | 8 +- .../Hosted-Workflow-Simple/Program.cs | 8 +- .../HostedContributorRouteExtensions.cs | 41 ++++ .../SessionFilesClient/Program.cs | 29 +-- .../SessionFilesClient/README.md | 10 +- .../Using-Samples/SimpleAgent/Program.cs | 27 +-- .../AzureAIProjectChatClientExtensions.cs | 36 ++++ .../FoundryAgent.cs | 177 ++++++++---------- .../Foundry.Hosting.IntegrationTests.csproj | 2 +- ...AzureAIProjectChatClientExtensionsTests.cs | 81 ++++++++ .../FoundryAgentTests.cs | 20 +- 25 files changed, 341 insertions(+), 195 deletions(-) create mode 100644 dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted_Shared_Contributor_Setup/HostedContributorRouteExtensions.cs diff --git a/dotnet/Directory.Packages.props b/dotnet/Directory.Packages.props index 75106b5fcb..2121be9207 100644 --- a/dotnet/Directory.Packages.props +++ b/dotnet/Directory.Packages.props @@ -26,10 +26,10 @@ - + - + @@ -44,7 +44,7 @@ - + diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-AzureSearchRag/HostedAzureSearchRag.csproj b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-AzureSearchRag/HostedAzureSearchRag.csproj index 3b648ffbcb..98f3f57bd4 100644 --- a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-AzureSearchRag/HostedAzureSearchRag.csproj +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-AzureSearchRag/HostedAzureSearchRag.csproj @@ -11,7 +11,7 @@ - + @@ -22,6 +22,7 @@ +