Files
agent-framework/dotnet
T
Roger Barreto 9551f9ebd7 .NET: OpenTelemetryAgent normalize sourceName once and add OTEL wiring path coverage
Normalize the configured source name once in the constructor so the outer OpenTelemetryChatClient and the auto-wired inner OpenTelemetryChatClient always emit spans on the same ActivitySource. A caller passing an empty string previously produced agent-level spans on DefaultSourceName but auto-wired chat spans on the empty source, causing the chat spans to be silently dropped by exporters subscribed to the default source.

Tests added to cover the previously unexercised OTEL wiring branches:

- Ctor_NullOrEmptySourceName_AutoWiredChatClientUsesDefaultSource_Async (Theory: null and empty)

- AutoWireChatClient_PlainAgentRunOptions_PreservesContinuationToken_Async

- AutoWireChatClient_ChatClientAgentRunOptions_NoUserFactory_PreservesChatOptions_Async

- AutoWireChatClient_StreamingDisabled_DoesNotEmitChatSpan_Async
9551f9ebd7 · 2026-05-13 12:45:56 +01:00
History
..
2026-05-08 00:17:44 +00:00
2026-04-03 11:27:36 +00:00

Get Started with Microsoft Agent Framework for C# Developers

Quickstart

Basic Agent - .NET

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

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

var agent = new AzureOpenAIClient(new Uri(endpoint), new AzureCliCredential())
    .GetResponsesClient(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