Skip to content

MicrosoftFoundry

Rasmus Wulff Jensen edited this page Jul 17, 2026 · 2 revisions

NuGet README

Features

  • AgentFactory (MicrosoftFoundryAgentFactory)
  • Declarative agent creation and management (MicrosoftFoundryDeclarativeAgentFactory)
  • AIToolsFactory integration (tools in AgentOptions.Tools)
  • ChatClient and Responses API support
  • Azure RBAC authentication

Package

dotnet add package AgentFrameworkToolkit.MicrosoftFoundry

Quick start

MicrosoftFoundryAgentFactory agentFactory = new("<projectEndpoint>", new AzureCliCredential());
MicrosoftFoundryAgent agent = agentFactory.CreateAgent(new AgentOptions
{
    Model = "gpt-5",
    Instructions = "You are a nice AI"
});

AgentResponse response = await agent.RunAsync("Hello World");
Console.WriteLine(response);

Declarative agents

Declarative agents persist in the Microsoft Foundry project. Creating an agent with an existing name and a changed definition creates a new version.

MicrosoftFoundryAgentFactory agentFactory = new("<projectEndpoint>", new AzureCliCredential());
MicrosoftFoundryDeclarativeAgentFactory declarativeFactory = agentFactory.DeclarativeAgentFactory;

MicrosoftFoundryAgent agent = declarativeFactory.CreateAgent(new DeclarativeAgentOptions
{
    Name = "my-agent",
    Model = "gpt-5-nano",
    Instructions = "You are a concise assistant.",
    Tools = [],
    McpTools = [],
    WebSearchTool = false,
    CodeInterpreterTool = false
});

AgentResponse response = await agent.RunAsync("Hello World");

The declarative factory can also retrieve agents and versions with GetAgent, GetAgents, and GetAgentVersions, or remove an agent with DeleteAgent.

Connection options

  • Endpoint (required Microsoft Foundry project endpoint)
  • AuthenticationTokenProvider (optional, defaults to DefaultAzureCredential)
  • NetworkTimeout
  • DefaultClientType (Responses API by default)
  • AdditionalProjectClientOptions

Dependency injection

builder.Services.AddMicrosoftFoundryAgentFactory("<projectEndpoint>", new AzureCliCredential());
builder.Services.AddMicrosoftFoundryAgentFactory(new MicrosoftFoundryConnection
{
    Endpoint = "<projectEndpoint>",
    AuthenticationTokenProvider = new AzureCliCredential()
});

Notes

  • MicrosoftFoundryAgentFactory creates model-backed agents without persisting an agent definition.
  • Declarative agents persist in the Foundry project; delete temporary agents when they are no longer needed.
  • See AgentFactories for shared agent options and middleware.
  • See AIToolsFactory for tool creation and MCP support.

Clone this wiki locally