db620d33df
dotnet-build-and-test / dotnet-test-functions (push) Has been cancelled
dotnet-build-and-test / paths-filter (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Debug, windows-latest, net9.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, ubuntu-latest, net10.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, ubuntu-latest, net8.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, windows-latest, net472) (push) Has been cancelled
dotnet-build-and-test / dotnet-test (Release, integration, true, ubuntu-latest, net10.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-test (Release, integration, true, windows-latest, net472) (push) Has been cancelled
dotnet-build-and-test / dotnet-foundry-hosted-it (push) Has been cancelled
dotnet-build-and-test / dotnet-build-and-test-check (push) Has been cancelled
dotnet-build-and-test / Integration Test Report (push) Has been cancelled
CodeQL / Analyze (csharp) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
91 lines
4.1 KiB
Markdown
91 lines
4.1 KiB
Markdown
# Getting started with Foundry Agents
|
|
|
|
These samples demonstrate how to use Microsoft Foundry with Agent Framework.
|
|
|
|
## Quick start
|
|
|
|
You can create a Foundry agent directly with the `FoundryAgent` type:
|
|
|
|
```csharp
|
|
FoundryAgent agent = new(
|
|
new Uri(endpoint),
|
|
new DefaultAzureCredential(),
|
|
model: "gpt-5.4-mini",
|
|
instructions: "You are good at telling jokes.",
|
|
name: "JokerAgent");
|
|
|
|
Console.WriteLine(await agent.RunAsync("Tell me a joke about a pirate."));
|
|
```
|
|
|
|
Or using the `AIProjectClient.AsAIAgent(...)` extensions:
|
|
|
|
```csharp
|
|
AIProjectClient aiProjectClient = new(new Uri(endpoint), new DefaultAzureCredential());
|
|
|
|
FoundryAgent agent = aiProjectClient.AsAIAgent(
|
|
model: deploymentName,
|
|
instructions: "You are good at telling jokes.",
|
|
name: "JokerAgent");
|
|
```
|
|
|
|
## Prerequisites
|
|
|
|
- .NET 10 SDK or later
|
|
- Foundry project endpoint
|
|
- An authenticated Azure identity (for example, sign in with `az login`)
|
|
|
|
Set:
|
|
|
|
```powershell
|
|
$env:FOUNDRY_PROJECT_ENDPOINT="https://your-foundry-service.services.ai.azure.com/api/projects/your-foundry-project"
|
|
$env:FOUNDRY_MODEL="gpt-5.4-mini"
|
|
```
|
|
|
|
Some samples require extra tool-specific environment variables. See each sample for details.
|
|
|
|
## Samples
|
|
|
|
| Sample | Description |
|
|
| --- | --- |
|
|
| [FoundryAgent lifecycle](./Agent_Step00_FoundryAgentLifecycle/) | Create a FoundryAgent directly with endpoint and credentials |
|
|
| [Basics (Responses API)](./Agent_Step01_Basics/) | Create and run an agent using AsAIAgent extensions |
|
|
| [Multi-turn conversation](./Agent_Step02.1_MultiturnConversation/) | Multi-turn using sessions and response ID chaining |
|
|
| [Multi-turn with server conversations](./Agent_Step02.2_MultiturnWithServerConversations/) | Server-side conversations visible in Foundry UI |
|
|
| [Using function tools](./Agent_Step03_UsingFunctionTools/) | Function tools |
|
|
| [Function tools with approvals](./Agent_Step04_UsingFunctionToolsWithApprovals/) | Human-in-the-loop approval |
|
|
| [Structured output](./Agent_Step05_StructuredOutput/) | Structured output with JSON schema |
|
|
| [Persisted conversations](./Agent_Step06_PersistedConversations/) | Persisting and resuming conversations |
|
|
| [Observability](./Agent_Step07_Observability/) | OpenTelemetry observability |
|
|
| [Dependency injection](./Agent_Step08_DependencyInjection/) | DI with a hosted service |
|
|
| [Using MCP client as tools](./Agent_Step09_UsingMcpClientAsTools/) | MCP client tools |
|
|
| [Using images](./Agent_Step10_UsingImages/) | Image multi-modality |
|
|
| [Agent as function tool](./Agent_Step11_AsFunctionTool/) | Agent as a function tool for another |
|
|
| [Middleware](./Agent_Step12_Middleware/) | Multiple middleware layers |
|
|
| [Plugins](./Agent_Step13_Plugins/) | Plugins with dependency injection |
|
|
| [Code interpreter](./Agent_Step14_CodeInterpreter/) | Code interpreter tool |
|
|
| [Computer use](./Agent_Step15_ComputerUse/) | Computer use tool |
|
|
| [File search](./Agent_Step16_FileSearch/) | File search tool |
|
|
| [OpenAPI tools](./Agent_Step17_OpenAPITools/) | OpenAPI tools |
|
|
| [Bing custom search](./Agent_Step18_BingCustomSearch/) | Bing Custom Search tool |
|
|
| [SharePoint](./Agent_Step19_SharePoint/) | SharePoint grounding tool |
|
|
| [Microsoft Fabric](./Agent_Step20_MicrosoftFabric/) | Microsoft Fabric tool |
|
|
| [Web search](./Agent_Step21_WebSearch/) | Web search tool |
|
|
| [Memory search](./Agent_Step22_MemorySearch/) | Memory search tool |
|
|
| [Local MCP](./Agent_Step23_LocalMCP/) | Local MCP client with HTTP transport |
|
|
| [Code interpreter file download](./Agent_Step24_CodeInterpreterFileDownload/) | Download container files generated by code interpreter |
|
|
| [Foundry toolbox via MCP](./Agent_Step25_FoundryToolboxMcp/README.md) | Use a Foundry Toolbox from a non-hosted agent via its MCP endpoint |
|
|
| [Foundry toolbox MCP skills](./Agent_Step26_FoundryToolboxMcpSkills/README.md) | Use a Foundry Toolbox with MCP-based skills discovery (SEP-2640) via AIContextProviders |
|
|
|
|
## Running the samples
|
|
|
|
Use the basics sample for a quick smoke test:
|
|
|
|
```powershell
|
|
cd dotnet/samples/02-agents/AgentProviders/foundry
|
|
dotnet run --project .\Agent_Step01_Basics
|
|
```
|
|
|
|
If you want to exercise the full create-run-delete lifecycle, run `Agent_Step00_FoundryAgentLifecycle`.
|
|
|
|
|