From 3984ef4ef14ca086c1f4d8044d26bb775674cfea Mon Sep 17 00:00:00 2001
From: Roger Barreto <19890735+rogerbarreto@users.noreply.github.com>
Date: Sat, 11 Apr 2026 11:36:00 +0100
Subject: [PATCH] Hosting Samples update
---
dotnet/agent-framework-dotnet.slnx | 8 ++++----
.../HostedAgentsV2/consumption/Program.cs | 18 +++++++++---------
...oundry.csproj => HostedFoundryAgent.csproj} | 0
.../HostedAgentsV2/foundry-hosting/Program.cs | 6 ++++--
.../Properties/launchSettings.json | 2 +-
5 files changed, 18 insertions(+), 16 deletions(-)
rename dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/foundry-hosting/{simple-agent-foundry.csproj => HostedFoundryAgent.csproj} (100%)
diff --git a/dotnet/agent-framework-dotnet.slnx b/dotnet/agent-framework-dotnet.slnx
index f52c04eb7a..16778e2278 100644
--- a/dotnet/agent-framework-dotnet.slnx
+++ b/dotnet/agent-framework-dotnet.slnx
@@ -274,14 +274,14 @@
-
-
-
-
+
+
+
+
diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/consumption/Program.cs b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/consumption/Program.cs
index f1c3686279..f0a1e74069 100644
--- a/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/consumption/Program.cs
+++ b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/consumption/Program.cs
@@ -8,7 +8,7 @@ using Microsoft.Agents.AI;
// Load .env file if present (for local development)
Env.TraversePath().Load();
-string agentEndpoint = Environment.GetEnvironmentVariable("AGENT_ENDPOINT") ?? "http://localhost:8088";
+string agentEndpoint = Environment.GetEnvironmentVariable("AGENT_ENDPOINT") ?? "http://localhost:59055";
// ── Create an agent-framework agent backed by the remote agent endpoint ──────
// The Foundry Agent SDK's AIProjectClient can target any OpenAI-compatible endpoint.
@@ -21,11 +21,13 @@ 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.WriteLine($"""
+ ══════════════════════════════════════════════════════════
+ Simple Agent Sample
+ Connected to: {agentEndpoint}
+ Type a message or 'quit' to exit
+ ══════════════════════════════════════════════════════════
+ """);
Console.ResetColor();
Console.WriteLine();
@@ -38,9 +40,7 @@ while (true)
string? input = Console.ReadLine();
if (string.IsNullOrWhiteSpace(input)) { continue; }
- if (input.Equals("quit", StringComparison.OrdinalIgnoreCase) ||
- input.Equals("exit", StringComparison.OrdinalIgnoreCase))
- { break; }
+ if (input.Equals("quit", StringComparison.OrdinalIgnoreCase)) { break; }
try
{
diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/foundry-hosting/simple-agent-foundry.csproj b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/foundry-hosting/HostedFoundryAgent.csproj
similarity index 100%
rename from dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/foundry-hosting/simple-agent-foundry.csproj
rename to dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/foundry-hosting/HostedFoundryAgent.csproj
diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/foundry-hosting/Program.cs b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/foundry-hosting/Program.cs
index ad0f2b2ca2..0fe1ad9ac3 100644
--- a/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/foundry-hosting/Program.cs
+++ b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/foundry-hosting/Program.cs
@@ -1,8 +1,10 @@
+// Copyright (c) Microsoft. All rights reserved.
+
using Azure.AI.Projects;
using Azure.AI.Projects.Agents;
using Azure.Identity;
using DotNetEnv;
-using Microsoft.Agents.AI;
+using Microsoft.Agents.AI.Foundry;
using Microsoft.Agents.AI.Foundry.Hosting;
// Load .env file if present (for local development)
@@ -19,7 +21,7 @@ var aiProjectClient = new AIProjectClient(projectEndpoint, new DefaultAzureCrede
ProjectsAgentRecord agentRecord = await aiProjectClient
.AgentAdministrationClient.GetAgentAsync(agentName);
-AIAgent agent = aiProjectClient.AsAIAgent(agentRecord);
+FoundryAgent agent = aiProjectClient.AsAIAgent(agentRecord);
// Host the agent as a Foundry Hosted Agent using the Responses API.
var builder = WebApplication.CreateBuilder(args);
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
index fc4cf2a105..11588cf909 100644
--- a/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/foundry-hosting/Properties/launchSettings.json
+++ b/dotnet/samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/foundry-hosting/Properties/launchSettings.json
@@ -6,7 +6,7 @@
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
- "applicationUrl": "https://localhost:59703;http://localhost:59708"
+ "applicationUrl": "http://localhost:8089"
}
}
}
\ No newline at end of file