From 7407c0a35ed2e4cb69fdcf9bbe0db5dfb07d7bdc Mon Sep 17 00:00:00 2001 From: Roger Barreto <19890735+rogerbarreto@users.noreply.github.com> Date: Sat, 11 Apr 2026 10:57:16 +0100 Subject: [PATCH] Hosting Samples update --- dotnet/Directory.Packages.props | 1 + dotnet/agent-framework-dotnet.slnx | 38 +++++++---- .../AgentThreadAndHITL.csproj | 0 .../AgentThreadAndHITL/Dockerfile | 0 .../AgentThreadAndHITL/Program.cs | 0 .../AgentThreadAndHITL/README.md | 0 .../AgentThreadAndHITL/agent.yaml | 0 .../AgentThreadAndHITL/run-requests.http | 0 .../AgentWithHostedMCP.csproj | 0 .../AgentWithHostedMCP/Dockerfile | 0 .../AgentWithHostedMCP/Program.cs | 0 .../AgentWithHostedMCP/README.md | 0 .../AgentWithHostedMCP/agent.yaml | 0 .../AgentWithHostedMCP/run-requests.http | 0 .../AgentWithLocalTools/.dockerignore | 0 .../AgentWithLocalTools.csproj | 0 .../AgentWithLocalTools/Dockerfile | 0 .../AgentWithLocalTools/Program.cs | 0 .../AgentWithLocalTools/README.md | 0 .../AgentWithLocalTools/agent.yaml | 0 .../AgentWithLocalTools/run-requests.http | 0 .../AgentWithTextSearchRag.csproj | 0 .../AgentWithTextSearchRag/Dockerfile | 0 .../AgentWithTextSearchRag/Program.cs | 0 .../AgentWithTextSearchRag/README.md | 0 .../AgentWithTextSearchRag/agent.yaml | 0 .../AgentWithTextSearchRag/run-requests.http | 0 .../AgentsInWorkflows.csproj | 0 .../AgentsInWorkflows/Dockerfile | 0 .../AgentsInWorkflows/Program.cs | 0 .../AgentsInWorkflows/README.md | 0 .../AgentsInWorkflows/agent.yaml | 0 .../AgentsInWorkflows/run-requests.http | 0 .../FoundryMultiAgent/Dockerfile | 0 .../FoundryMultiAgent.csproj | 0 .../FoundryMultiAgent/Program.cs | 0 .../FoundryMultiAgent/README.md | 0 .../FoundryMultiAgent/agent.yaml | 0 .../appsettings.Development.json | 0 .../FoundryMultiAgent/run-requests.http | 0 .../FoundrySingleAgent/Dockerfile | 0 .../FoundrySingleAgent.csproj | 0 .../FoundrySingleAgent/Program.cs | 0 .../FoundrySingleAgent/README.md | 0 .../FoundrySingleAgent/agent.yaml | 0 .../FoundrySingleAgent/run-requests.http | 0 .../HostedAgentsV1}/README.md | 0 .../HostedAgentsV2/consumption/Program.cs | 68 +++++++++++++++++++ .../consumption/SimpleAgent.csproj | 22 ++++++ .../HostedAgentsV2/foundry-hosting/Dockerfile | 17 +++++ .../HostedAgentsV2/foundry-hosting/Program.cs | 30 ++++++++ .../Properties/launchSettings.json | 12 ++++ .../HostedAgentsV2/foundry-hosting/agent.yaml | 20 ++++++ .../simple-agent-foundry.csproj | 25 +++++++ .../instance-hosting/Dockerfile | 17 +++++ .../HostedChatClientAgent.csproj | 25 +++++++ .../instance-hosting/Program.cs | 33 +++++++++ .../Properties/launchSettings.json | 12 ++++ .../instance-hosting/agent.yaml | 20 ++++++ .../AzureAIProjectChatClientExtensions.cs | 8 +-- 60 files changed, 329 insertions(+), 19 deletions(-) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/AgentThreadAndHITL/AgentThreadAndHITL.csproj (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/AgentThreadAndHITL/Dockerfile (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/AgentThreadAndHITL/Program.cs (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/AgentThreadAndHITL/README.md (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/AgentThreadAndHITL/agent.yaml (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/AgentThreadAndHITL/run-requests.http (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/AgentWithHostedMCP/AgentWithHostedMCP.csproj (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/AgentWithHostedMCP/Dockerfile (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/AgentWithHostedMCP/Program.cs (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/AgentWithHostedMCP/README.md (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/AgentWithHostedMCP/agent.yaml (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/AgentWithHostedMCP/run-requests.http (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/AgentWithLocalTools/.dockerignore (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/AgentWithLocalTools/AgentWithLocalTools.csproj (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/AgentWithLocalTools/Dockerfile (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/AgentWithLocalTools/Program.cs (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/AgentWithLocalTools/README.md (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/AgentWithLocalTools/agent.yaml (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/AgentWithLocalTools/run-requests.http (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/AgentWithTextSearchRag/AgentWithTextSearchRag.csproj (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/AgentWithTextSearchRag/Dockerfile (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/AgentWithTextSearchRag/Program.cs (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/AgentWithTextSearchRag/README.md (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/AgentWithTextSearchRag/agent.yaml (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/AgentWithTextSearchRag/run-requests.http (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/AgentsInWorkflows/AgentsInWorkflows.csproj (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/AgentsInWorkflows/Dockerfile (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/AgentsInWorkflows/Program.cs (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/AgentsInWorkflows/README.md (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/AgentsInWorkflows/agent.yaml (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/AgentsInWorkflows/run-requests.http (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/FoundryMultiAgent/Dockerfile (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/FoundryMultiAgent/FoundryMultiAgent.csproj (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/FoundryMultiAgent/Program.cs (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/FoundryMultiAgent/README.md (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/FoundryMultiAgent/agent.yaml (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/FoundryMultiAgent/appsettings.Development.json (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/FoundryMultiAgent/run-requests.http (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/FoundrySingleAgent/Dockerfile (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/FoundrySingleAgent/FoundrySingleAgent.csproj (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/FoundrySingleAgent/Program.cs (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/FoundrySingleAgent/README.md (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/FoundrySingleAgent/agent.yaml (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/FoundrySingleAgent/run-requests.http (100%) rename dotnet/samples/{05-end-to-end/HostedAgents => 04-hosting/FoundryHostedAgents/HostedAgentsV1}/README.md (100%) create mode 100644 dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/consumption/Program.cs create mode 100644 dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/consumption/SimpleAgent.csproj create mode 100644 dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/foundry-hosting/Dockerfile create mode 100644 dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/foundry-hosting/Program.cs create mode 100644 dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/foundry-hosting/Properties/launchSettings.json create mode 100644 dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/foundry-hosting/agent.yaml create mode 100644 dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/foundry-hosting/simple-agent-foundry.csproj create mode 100644 dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/instance-hosting/Dockerfile create mode 100644 dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/instance-hosting/HostedChatClientAgent.csproj create mode 100644 dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/instance-hosting/Program.cs create mode 100644 dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/instance-hosting/Properties/launchSettings.json create mode 100644 dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/instance-hosting/agent.yaml diff --git a/dotnet/Directory.Packages.props b/dotnet/Directory.Packages.props index 11628f4e38..36e68c958a 100644 --- a/dotnet/Directory.Packages.props +++ b/dotnet/Directory.Packages.props @@ -27,6 +27,7 @@ + diff --git a/dotnet/agent-framework-dotnet.slnx b/dotnet/agent-framework-dotnet.slnx index 5d746ccd97..f52c04eb7a 100644 --- a/dotnet/agent-framework-dotnet.slnx +++ b/dotnet/agent-framework-dotnet.slnx @@ -263,6 +263,26 @@ + + + + + + + + + + + + + + + + + + + + @@ -315,15 +335,6 @@ - - - - - - - - - @@ -485,13 +496,12 @@ - - + @@ -513,11 +523,10 @@ - + - @@ -533,12 +542,11 @@ - - + diff --git a/dotnet/samples/05-end-to-end/HostedAgents/AgentThreadAndHITL/AgentThreadAndHITL.csproj b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentThreadAndHITL/AgentThreadAndHITL.csproj similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/AgentThreadAndHITL/AgentThreadAndHITL.csproj rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentThreadAndHITL/AgentThreadAndHITL.csproj diff --git a/dotnet/samples/05-end-to-end/HostedAgents/AgentThreadAndHITL/Dockerfile b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentThreadAndHITL/Dockerfile similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/AgentThreadAndHITL/Dockerfile rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentThreadAndHITL/Dockerfile diff --git a/dotnet/samples/05-end-to-end/HostedAgents/AgentThreadAndHITL/Program.cs b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentThreadAndHITL/Program.cs similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/AgentThreadAndHITL/Program.cs rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentThreadAndHITL/Program.cs diff --git a/dotnet/samples/05-end-to-end/HostedAgents/AgentThreadAndHITL/README.md b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentThreadAndHITL/README.md similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/AgentThreadAndHITL/README.md rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentThreadAndHITL/README.md diff --git a/dotnet/samples/05-end-to-end/HostedAgents/AgentThreadAndHITL/agent.yaml b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentThreadAndHITL/agent.yaml similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/AgentThreadAndHITL/agent.yaml rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentThreadAndHITL/agent.yaml diff --git a/dotnet/samples/05-end-to-end/HostedAgents/AgentThreadAndHITL/run-requests.http b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentThreadAndHITL/run-requests.http similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/AgentThreadAndHITL/run-requests.http rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentThreadAndHITL/run-requests.http diff --git a/dotnet/samples/05-end-to-end/HostedAgents/AgentWithHostedMCP/AgentWithHostedMCP.csproj b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentWithHostedMCP/AgentWithHostedMCP.csproj similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/AgentWithHostedMCP/AgentWithHostedMCP.csproj rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentWithHostedMCP/AgentWithHostedMCP.csproj diff --git a/dotnet/samples/05-end-to-end/HostedAgents/AgentWithHostedMCP/Dockerfile b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentWithHostedMCP/Dockerfile similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/AgentWithHostedMCP/Dockerfile rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentWithHostedMCP/Dockerfile diff --git a/dotnet/samples/05-end-to-end/HostedAgents/AgentWithHostedMCP/Program.cs b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentWithHostedMCP/Program.cs similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/AgentWithHostedMCP/Program.cs rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentWithHostedMCP/Program.cs diff --git a/dotnet/samples/05-end-to-end/HostedAgents/AgentWithHostedMCP/README.md b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentWithHostedMCP/README.md similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/AgentWithHostedMCP/README.md rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentWithHostedMCP/README.md diff --git a/dotnet/samples/05-end-to-end/HostedAgents/AgentWithHostedMCP/agent.yaml b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentWithHostedMCP/agent.yaml similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/AgentWithHostedMCP/agent.yaml rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentWithHostedMCP/agent.yaml diff --git a/dotnet/samples/05-end-to-end/HostedAgents/AgentWithHostedMCP/run-requests.http b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentWithHostedMCP/run-requests.http similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/AgentWithHostedMCP/run-requests.http rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentWithHostedMCP/run-requests.http diff --git a/dotnet/samples/05-end-to-end/HostedAgents/AgentWithLocalTools/.dockerignore b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentWithLocalTools/.dockerignore similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/AgentWithLocalTools/.dockerignore rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentWithLocalTools/.dockerignore diff --git a/dotnet/samples/05-end-to-end/HostedAgents/AgentWithLocalTools/AgentWithLocalTools.csproj b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentWithLocalTools/AgentWithLocalTools.csproj similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/AgentWithLocalTools/AgentWithLocalTools.csproj rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentWithLocalTools/AgentWithLocalTools.csproj diff --git a/dotnet/samples/05-end-to-end/HostedAgents/AgentWithLocalTools/Dockerfile b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentWithLocalTools/Dockerfile similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/AgentWithLocalTools/Dockerfile rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentWithLocalTools/Dockerfile diff --git a/dotnet/samples/05-end-to-end/HostedAgents/AgentWithLocalTools/Program.cs b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentWithLocalTools/Program.cs similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/AgentWithLocalTools/Program.cs rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentWithLocalTools/Program.cs diff --git a/dotnet/samples/05-end-to-end/HostedAgents/AgentWithLocalTools/README.md b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentWithLocalTools/README.md similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/AgentWithLocalTools/README.md rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentWithLocalTools/README.md diff --git a/dotnet/samples/05-end-to-end/HostedAgents/AgentWithLocalTools/agent.yaml b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentWithLocalTools/agent.yaml similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/AgentWithLocalTools/agent.yaml rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentWithLocalTools/agent.yaml diff --git a/dotnet/samples/05-end-to-end/HostedAgents/AgentWithLocalTools/run-requests.http b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentWithLocalTools/run-requests.http similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/AgentWithLocalTools/run-requests.http rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentWithLocalTools/run-requests.http diff --git a/dotnet/samples/05-end-to-end/HostedAgents/AgentWithTextSearchRag/AgentWithTextSearchRag.csproj b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentWithTextSearchRag/AgentWithTextSearchRag.csproj similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/AgentWithTextSearchRag/AgentWithTextSearchRag.csproj rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentWithTextSearchRag/AgentWithTextSearchRag.csproj diff --git a/dotnet/samples/05-end-to-end/HostedAgents/AgentWithTextSearchRag/Dockerfile b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentWithTextSearchRag/Dockerfile similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/AgentWithTextSearchRag/Dockerfile rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentWithTextSearchRag/Dockerfile diff --git a/dotnet/samples/05-end-to-end/HostedAgents/AgentWithTextSearchRag/Program.cs b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentWithTextSearchRag/Program.cs similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/AgentWithTextSearchRag/Program.cs rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentWithTextSearchRag/Program.cs diff --git a/dotnet/samples/05-end-to-end/HostedAgents/AgentWithTextSearchRag/README.md b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentWithTextSearchRag/README.md similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/AgentWithTextSearchRag/README.md rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentWithTextSearchRag/README.md diff --git a/dotnet/samples/05-end-to-end/HostedAgents/AgentWithTextSearchRag/agent.yaml b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentWithTextSearchRag/agent.yaml similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/AgentWithTextSearchRag/agent.yaml rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentWithTextSearchRag/agent.yaml diff --git a/dotnet/samples/05-end-to-end/HostedAgents/AgentWithTextSearchRag/run-requests.http b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentWithTextSearchRag/run-requests.http similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/AgentWithTextSearchRag/run-requests.http rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentWithTextSearchRag/run-requests.http diff --git a/dotnet/samples/05-end-to-end/HostedAgents/AgentsInWorkflows/AgentsInWorkflows.csproj b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentsInWorkflows/AgentsInWorkflows.csproj similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/AgentsInWorkflows/AgentsInWorkflows.csproj rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentsInWorkflows/AgentsInWorkflows.csproj diff --git a/dotnet/samples/05-end-to-end/HostedAgents/AgentsInWorkflows/Dockerfile b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentsInWorkflows/Dockerfile similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/AgentsInWorkflows/Dockerfile rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentsInWorkflows/Dockerfile diff --git a/dotnet/samples/05-end-to-end/HostedAgents/AgentsInWorkflows/Program.cs b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentsInWorkflows/Program.cs similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/AgentsInWorkflows/Program.cs rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentsInWorkflows/Program.cs diff --git a/dotnet/samples/05-end-to-end/HostedAgents/AgentsInWorkflows/README.md b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentsInWorkflows/README.md similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/AgentsInWorkflows/README.md rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentsInWorkflows/README.md diff --git a/dotnet/samples/05-end-to-end/HostedAgents/AgentsInWorkflows/agent.yaml b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentsInWorkflows/agent.yaml similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/AgentsInWorkflows/agent.yaml rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentsInWorkflows/agent.yaml diff --git a/dotnet/samples/05-end-to-end/HostedAgents/AgentsInWorkflows/run-requests.http b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentsInWorkflows/run-requests.http similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/AgentsInWorkflows/run-requests.http rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/AgentsInWorkflows/run-requests.http diff --git a/dotnet/samples/05-end-to-end/HostedAgents/FoundryMultiAgent/Dockerfile b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/FoundryMultiAgent/Dockerfile similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/FoundryMultiAgent/Dockerfile rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/FoundryMultiAgent/Dockerfile diff --git a/dotnet/samples/05-end-to-end/HostedAgents/FoundryMultiAgent/FoundryMultiAgent.csproj b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/FoundryMultiAgent/FoundryMultiAgent.csproj similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/FoundryMultiAgent/FoundryMultiAgent.csproj rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/FoundryMultiAgent/FoundryMultiAgent.csproj diff --git a/dotnet/samples/05-end-to-end/HostedAgents/FoundryMultiAgent/Program.cs b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/FoundryMultiAgent/Program.cs similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/FoundryMultiAgent/Program.cs rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/FoundryMultiAgent/Program.cs diff --git a/dotnet/samples/05-end-to-end/HostedAgents/FoundryMultiAgent/README.md b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/FoundryMultiAgent/README.md similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/FoundryMultiAgent/README.md rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/FoundryMultiAgent/README.md diff --git a/dotnet/samples/05-end-to-end/HostedAgents/FoundryMultiAgent/agent.yaml b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/FoundryMultiAgent/agent.yaml similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/FoundryMultiAgent/agent.yaml rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/FoundryMultiAgent/agent.yaml diff --git a/dotnet/samples/05-end-to-end/HostedAgents/FoundryMultiAgent/appsettings.Development.json b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/FoundryMultiAgent/appsettings.Development.json similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/FoundryMultiAgent/appsettings.Development.json rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/FoundryMultiAgent/appsettings.Development.json diff --git a/dotnet/samples/05-end-to-end/HostedAgents/FoundryMultiAgent/run-requests.http b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/FoundryMultiAgent/run-requests.http similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/FoundryMultiAgent/run-requests.http rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/FoundryMultiAgent/run-requests.http diff --git a/dotnet/samples/05-end-to-end/HostedAgents/FoundrySingleAgent/Dockerfile b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/FoundrySingleAgent/Dockerfile similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/FoundrySingleAgent/Dockerfile rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/FoundrySingleAgent/Dockerfile diff --git a/dotnet/samples/05-end-to-end/HostedAgents/FoundrySingleAgent/FoundrySingleAgent.csproj b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/FoundrySingleAgent/FoundrySingleAgent.csproj similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/FoundrySingleAgent/FoundrySingleAgent.csproj rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/FoundrySingleAgent/FoundrySingleAgent.csproj diff --git a/dotnet/samples/05-end-to-end/HostedAgents/FoundrySingleAgent/Program.cs b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/FoundrySingleAgent/Program.cs similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/FoundrySingleAgent/Program.cs rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/FoundrySingleAgent/Program.cs diff --git a/dotnet/samples/05-end-to-end/HostedAgents/FoundrySingleAgent/README.md b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/FoundrySingleAgent/README.md similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/FoundrySingleAgent/README.md rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/FoundrySingleAgent/README.md diff --git a/dotnet/samples/05-end-to-end/HostedAgents/FoundrySingleAgent/agent.yaml b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/FoundrySingleAgent/agent.yaml similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/FoundrySingleAgent/agent.yaml rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/FoundrySingleAgent/agent.yaml diff --git a/dotnet/samples/05-end-to-end/HostedAgents/FoundrySingleAgent/run-requests.http b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/FoundrySingleAgent/run-requests.http similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/FoundrySingleAgent/run-requests.http rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/FoundrySingleAgent/run-requests.http diff --git a/dotnet/samples/05-end-to-end/HostedAgents/README.md b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/README.md similarity index 100% rename from dotnet/samples/05-end-to-end/HostedAgents/README.md rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/README.md diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/consumption/Program.cs b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/consumption/Program.cs new file mode 100644 index 0000000000..f1c3686279 --- /dev/null +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/consumption/Program.cs @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft. All rights reserved. + +using Azure.AI.Projects; +using Azure.Identity; +using DotNetEnv; +using Microsoft.Agents.AI; + +// Load .env file if present (for local development) +Env.TraversePath().Load(); + +string agentEndpoint = Environment.GetEnvironmentVariable("AGENT_ENDPOINT") ?? "http://localhost:8088"; + +// ── Create an agent-framework agent backed by the remote agent endpoint ────── +// The Foundry Agent SDK's AIProjectClient can target any OpenAI-compatible endpoint. + +var aiProjectClient = new AIProjectClient(new Uri(agentEndpoint), new AzureCliCredential()); +var agent = aiProjectClient.AsAIAgent(); + +AgentSession session = await agent.CreateSessionAsync(); + +// ── REPL ────────────────────────────────────────────────────────────────────── + +Console.ForegroundColor = ConsoleColor.Cyan; +Console.WriteLine("╔══════════════════════════════════════════════════════════╗"); +Console.WriteLine("║ Simple Agent Client ║"); +Console.WriteLine($"║ Connected to: {agentEndpoint,-41}║"); +Console.WriteLine("║ Type a message or 'quit' to exit ║"); +Console.WriteLine("╚══════════════════════════════════════════════════════════╝"); +Console.ResetColor(); +Console.WriteLine(); + +while (true) +{ + Console.ForegroundColor = ConsoleColor.Green; + Console.Write("You> "); + Console.ResetColor(); + + string? input = Console.ReadLine(); + + if (string.IsNullOrWhiteSpace(input)) { continue; } + if (input.Equals("quit", StringComparison.OrdinalIgnoreCase) || + input.Equals("exit", StringComparison.OrdinalIgnoreCase)) + { break; } + + try + { + Console.ForegroundColor = ConsoleColor.Yellow; + Console.Write("Agent> "); + Console.ResetColor(); + + await foreach (var update in agent.RunStreamingAsync(input, session)) + { + Console.Write(update); + } + + Console.WriteLine(); + } + catch (Exception ex) + { + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine($"Error: {ex.Message}"); + Console.ResetColor(); + } + + Console.WriteLine(); +} + +Console.WriteLine("Goodbye!"); diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/consumption/SimpleAgent.csproj b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/consumption/SimpleAgent.csproj new file mode 100644 index 0000000000..d2651ef7a7 --- /dev/null +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/consumption/SimpleAgent.csproj @@ -0,0 +1,22 @@ + + + + Exe + net10.0 + enable + enable + false + SimpleAgentClient + simple-agent-client + $(NoWarn);NU1903;NU1605;OPENAI001 + + + + + + + + + + + diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/foundry-hosting/Dockerfile b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/foundry-hosting/Dockerfile new file mode 100644 index 0000000000..2898f31ed0 --- /dev/null +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/foundry-hosting/Dockerfile @@ -0,0 +1,17 @@ +# Use the official .NET 10.0 ASP.NET runtime as a parent image +FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS base +WORKDIR /app + +FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build +WORKDIR /src +COPY . . +RUN dotnet restore +RUN dotnet publish -c Release -o /app/publish + +# Final stage +FROM base AS final +WORKDIR /app +COPY --from=build /app/publish . +EXPOSE 8088 +ENV ASPNETCORE_URLS=http://+:8088 +ENTRYPOINT ["dotnet", "simple-agent.dll"] diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/foundry-hosting/Program.cs b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/foundry-hosting/Program.cs new file mode 100644 index 0000000000..ad0f2b2ca2 --- /dev/null +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/foundry-hosting/Program.cs @@ -0,0 +1,30 @@ +using Azure.AI.Projects; +using Azure.AI.Projects.Agents; +using Azure.Identity; +using DotNetEnv; +using Microsoft.Agents.AI; +using Microsoft.Agents.AI.Foundry.Hosting; + +// Load .env file if present (for local development) +Env.TraversePath().Load(); + +var projectEndpoint = new Uri(Environment.GetEnvironmentVariable("AZURE_AI_PROJECT_ENDPOINT") + ?? throw new InvalidOperationException("AZURE_AI_PROJECT_ENDPOINT is not set.")); +var agentName = Environment.GetEnvironmentVariable("AGENT_NAME") + ?? throw new InvalidOperationException("AGENT_NAME is not set."); + +var aiProjectClient = new AIProjectClient(projectEndpoint, new DefaultAzureCredential()); + +// Retrieve the Foundry-managed agent by name (latest version). +ProjectsAgentRecord agentRecord = await aiProjectClient + .AgentAdministrationClient.GetAgentAsync(agentName); + +AIAgent agent = aiProjectClient.AsAIAgent(agentRecord); + +// Host the agent as a Foundry Hosted Agent using the Responses API. +var builder = WebApplication.CreateBuilder(args); +builder.Services.AddFoundryResponses(agent); + +var app = builder.Build(); +app.MapFoundryResponses(); +app.Run(); diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/foundry-hosting/Properties/launchSettings.json b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/foundry-hosting/Properties/launchSettings.json new file mode 100644 index 0000000000..fc4cf2a105 --- /dev/null +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/foundry-hosting/Properties/launchSettings.json @@ -0,0 +1,12 @@ +{ + "profiles": { + "simple-agent-foundry": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "https://localhost:59703;http://localhost:59708" + } + } +} \ No newline at end of file diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/foundry-hosting/agent.yaml b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/foundry-hosting/agent.yaml new file mode 100644 index 0000000000..a0fe89f966 --- /dev/null +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/foundry-hosting/agent.yaml @@ -0,0 +1,20 @@ +name: simple-agent +description: > + A simple general-purpose AI assistant hosted as a Foundry Hosted Agent, + backed by a Foundry-managed agent definition. +metadata: + tags: + - AI Agent Hosting + - Simple Agent + - Foundry Agent +template: + name: simple-agent + kind: hosted + protocols: + - protocol: responses + version: v1 + environment_variables: + - name: AZURE_AI_PROJECT_ENDPOINT + value: ${AZURE_AI_PROJECT_ENDPOINT} + - name: AGENT_NAME + value: ${AGENT_NAME} diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/foundry-hosting/simple-agent-foundry.csproj b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/foundry-hosting/simple-agent-foundry.csproj new file mode 100644 index 0000000000..a9adf5bb21 --- /dev/null +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/foundry-hosting/simple-agent-foundry.csproj @@ -0,0 +1,25 @@ + + + + net10.0 + enable + enable + false + SimpleAgent + simple-agent + $(NoWarn);NU1903;NU1605 + + + + + + + + + + + + + + + diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/instance-hosting/Dockerfile b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/instance-hosting/Dockerfile new file mode 100644 index 0000000000..2898f31ed0 --- /dev/null +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/instance-hosting/Dockerfile @@ -0,0 +1,17 @@ +# Use the official .NET 10.0 ASP.NET runtime as a parent image +FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS base +WORKDIR /app + +FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build +WORKDIR /src +COPY . . +RUN dotnet restore +RUN dotnet publish -c Release -o /app/publish + +# Final stage +FROM base AS final +WORKDIR /app +COPY --from=build /app/publish . +EXPOSE 8088 +ENV ASPNETCORE_URLS=http://+:8088 +ENTRYPOINT ["dotnet", "simple-agent.dll"] diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/instance-hosting/HostedChatClientAgent.csproj b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/instance-hosting/HostedChatClientAgent.csproj new file mode 100644 index 0000000000..a9adf5bb21 --- /dev/null +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/instance-hosting/HostedChatClientAgent.csproj @@ -0,0 +1,25 @@ + + + + net10.0 + enable + enable + false + SimpleAgent + simple-agent + $(NoWarn);NU1903;NU1605 + + + + + + + + + + + + + + + diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/instance-hosting/Program.cs b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/instance-hosting/Program.cs new file mode 100644 index 0000000000..8571f0a1f0 --- /dev/null +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/instance-hosting/Program.cs @@ -0,0 +1,33 @@ +using Azure.AI.Projects; +using Azure.Identity; +using DotNetEnv; +using Microsoft.Agents.AI; +using Microsoft.Agents.AI.Foundry.Hosting; + +// Load .env file if present (for local development) +Env.TraversePath().Load(); + +var projectEndpoint = new Uri(Environment.GetEnvironmentVariable("AZURE_AI_PROJECT_ENDPOINT") + ?? throw new InvalidOperationException("AZURE_AI_PROJECT_ENDPOINT is not set.")); +var deployment = Environment.GetEnvironmentVariable("AZURE_AI_MODEL_DEPLOYMENT_NAME") ?? "gpt-4o"; + +// Create the agent via the AI project client using the Responses API. +AIAgent agent = new AIProjectClient(projectEndpoint, new DefaultAzureCredential()) + .AsAIAgent( + model: deployment, + instructions: """ + You are a helpful AI assistant hosted as a Foundry Hosted Agent. + You can help with a wide range of tasks including answering questions, + providing explanations, brainstorming ideas, and offering guidance. + Be concise, clear, and helpful in your responses. + """, + name: "simple-agent", + description: "A simple general-purpose AI assistant"); + +// Host the agent as a Foundry Hosted Agent using the Responses API. +var builder = WebApplication.CreateBuilder(args); +builder.Services.AddFoundryResponses(agent); + +var app = builder.Build(); +app.MapFoundryResponses(); +app.Run(); diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/instance-hosting/Properties/launchSettings.json b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/instance-hosting/Properties/launchSettings.json new file mode 100644 index 0000000000..5f47fe2db6 --- /dev/null +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/instance-hosting/Properties/launchSettings.json @@ -0,0 +1,12 @@ +{ + "profiles": { + "Hosted-ChatClientAgent": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "https://localhost:59054;http://localhost:59055" + } + } +} \ No newline at end of file diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/instance-hosting/agent.yaml b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/instance-hosting/agent.yaml new file mode 100644 index 0000000000..dfab24e712 --- /dev/null +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/instance-hosting/agent.yaml @@ -0,0 +1,20 @@ +name: simple-agent +description: > + A simple general-purpose AI assistant hosted as a Foundry Hosted Agent. +metadata: + tags: + - AI Agent Hosting + - Simple Agent +template: + name: simple-agent + kind: hosted + protocols: + - protocol: responses + version: v1 + environment_variables: + - name: AZURE_AI_PROJECT_ENDPOINT + value: ${AZURE_AI_PROJECT_ENDPOINT} + - name: AZURE_AI_MODEL_DEPLOYMENT_NAME + value: ${AZURE_AI_MODEL_DEPLOYMENT_NAME} + - name: AGENT_NAME + value: ${AGENT_NAME} diff --git a/dotnet/src/Microsoft.Agents.AI.Foundry/AzureAIProjectChatClientExtensions.cs b/dotnet/src/Microsoft.Agents.AI.Foundry/AzureAIProjectChatClientExtensions.cs index 4383cfb6d4..4b895e4bc0 100644 --- a/dotnet/src/Microsoft.Agents.AI.Foundry/AzureAIProjectChatClientExtensions.cs +++ b/dotnet/src/Microsoft.Agents.AI.Foundry/AzureAIProjectChatClientExtensions.cs @@ -13,6 +13,7 @@ using Microsoft.Agents.AI; using Microsoft.Agents.AI.Foundry; using Microsoft.Extensions.AI; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; using Microsoft.Shared.DiagnosticIds; using Microsoft.Shared.Diagnostics; using OpenAI.Responses; @@ -181,7 +182,7 @@ public static partial class AzureAIProjectChatClientExtensions /// Creates a non-versioned backed by the project's Responses API using the specified options. /// /// The to use for Responses API calls. Cannot be . - /// Configuration options that control the agent's behavior. is required. + /// Optional configuration options that control the agent's behavior. /// Provides a way to customize the creation of the underlying used by the agent. /// Optional logger factory for creating loggers used by the agent. /// An optional to use for resolving services required by the instances being invoked. @@ -190,15 +191,14 @@ public static partial class AzureAIProjectChatClientExtensions /// Thrown when does not specify . public static ChatClientAgent AsAIAgent( this AIProjectClient aiProjectClient, - ChatClientAgentOptions options, + ChatClientAgentOptions? options = null, Func? clientFactory = null, ILoggerFactory? loggerFactory = null, IServiceProvider? services = null) { Throw.IfNull(aiProjectClient); - Throw.IfNull(options); - return CreateResponsesChatClientAgent(aiProjectClient, options, clientFactory, loggerFactory, services); + return CreateResponsesChatClientAgent(aiProjectClient, options ?? new(), clientFactory, loggerFactory, services); } #region Private