Files
agent-framework/dotnet
T
Roger Barreto 2b66ca03b2 .NET: Fix Error 404 Agent Hosted MCP (#3678)
* Initial plan

* Fix issue #3195: Handle empty Version and ID in Azure AI agent responses

This fix addresses the issue where hosted MCP agents (like AgentWithHostedMCP)
fail with "ID cannot be null or empty (Parameter 'id')" error when deployed
to Azure AI Foundry.

Changes:
- Add CreateAgentReference helper method in AzureAIProjectChatClient that defaults
  empty version to "latest"
- Update CreateChatClientAgentOptions to generate a fallback ID from name and version
  when AgentVersion.Id is null or empty
- Add GetAgentVersionResponseJsonWithEmptyVersion and GetAgentResponseJsonWithEmptyVersion
  test data methods
- Add unit tests for empty version handling scenarios

Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com>

* Address code review feedback: improve documentation and test comments

Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com>

* Address PR review: Use IsNullOrWhiteSpace and add whitespace unit tests

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
2b66ca03b2 ยท 2026-02-05 13:39:59 +00:00
History
..
2025-11-22 04:14:15 +00:00

Get Started with Microsoft Agent Framework for C# Developers

Samples

Quickstart

Basic Agent - .NET

using System;
using Azure.AI.OpenAI;
using Azure.Identity;
using Microsoft.Agents.AI;

var endpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT")!;
var deploymentName = Environment.GetEnvironmentVariable("AZURE_OPENAI_DEPLOYMENT_NAME")!;

var agent = new AzureOpenAIClient(new Uri(endpoint), new AzureCliCredential())
    .GetOpenAIResponseClient(deploymentName)
    .AsAIAgent(name: "HaikuBot", instructions: "You are an upbeat assistant that writes beautifully.");

Console.WriteLine(await agent.RunAsync("Write a haiku about Microsoft Agent Framework."));

Examples & Samples

Agent Framework Documentation