From b2741ff1e068317747f7184a54c0e531ed1c36e9 Mon Sep 17 00:00:00 2001 From: Roger Barreto <19890735+RogerBarreto@users.noreply.github.com> Date: Fri, 19 Jun 2026 17:39:17 +0100 Subject: [PATCH 1/2] Bring Hosted-Toolbox sample to parity with sibling hosting samples Adds the standard scaffolding files (.env.example, agent.yaml, agent.manifest.yaml, Dockerfile, Dockerfile.contributor) that every other 04-hosting Foundry sample ships but Hosted-Toolbox lacked. Fixes the toolbox name environment variable: reads TOOLBOX_NAME instead of the platform reserved FOUNDRY_TOOLBOX_NAME so it survives agent create, and aligns the default to my-toolset. Rewrites the README to the standard section layout with PowerShell fenced commands, and adds Using-Samples READMEs documenting why the client REPLs exist. Renames Azure AI Foundry to Foundry across the 04-hosting sample READMEs and comments for consistent product naming. --- .../responses/Hosted-AgentSkills/README.md | 2 +- .../responses/Hosted-AzureSearchRag/README.md | 2 +- .../Hosted-ChatClientAgent/README.md | 4 +- .../responses/Hosted-Files/Program.cs | 2 +- .../responses/Hosted-Files/README.md | 2 +- .../responses/Hosted-FoundryAgent/README.md | 4 +- .../responses/Hosted-LocalCodeAct/README.md | 4 +- .../responses/Hosted-LocalTools/README.md | 4 +- .../responses/Hosted-McpTools/README.md | 2 +- .../responses/Hosted-MemoryAgent/README.md | 2 +- .../responses/Hosted-Observability/README.md | 4 +- .../responses/Hosted-TextRag/README.md | 4 +- .../Hosted-Toolbox-AuthPaths/.env.example | 2 +- .../Hosted-Toolbox-AuthPaths/Program.cs | 2 +- .../responses/Hosted-Toolbox/.env.example | 16 +++ .../responses/Hosted-Toolbox/Dockerfile | 17 +++ .../Hosted-Toolbox/Dockerfile.contributor | 21 ++++ .../responses/Hosted-Toolbox/Program.cs | 19 ++-- .../responses/Hosted-Toolbox/README.md | 104 ++++++++++++++++-- .../Hosted-Toolbox/agent.manifest.yaml | 47 ++++++++ .../responses/Hosted-Toolbox/agent.yaml | 9 ++ .../Hosted-ToolboxMcpSkills/Program.cs | 2 +- .../Hosted-ToolboxMcpSkills/README.md | 4 +- .../Hosted-Workflow-Handoff/README.md | 2 +- .../Hosted-Workflow-Simple/README.md | 4 +- .../responses/Using-Samples/README.md | 51 +++++++++ .../Using-Samples/SimpleAgent/README.md | 63 +++++++++++ 27 files changed, 352 insertions(+), 47 deletions(-) create mode 100644 dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox/.env.example create mode 100644 dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox/Dockerfile create mode 100644 dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox/Dockerfile.contributor create mode 100644 dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox/agent.manifest.yaml create mode 100644 dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox/agent.yaml create mode 100644 dotnet/samples/04-hosting/FoundryHostedAgents/responses/Using-Samples/README.md create mode 100644 dotnet/samples/04-hosting/FoundryHostedAgents/responses/Using-Samples/SimpleAgent/README.md diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-AgentSkills/README.md b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-AgentSkills/README.md index 747e1dec4f4..31379c8c63e 100644 --- a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-AgentSkills/README.md +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-AgentSkills/README.md @@ -42,7 +42,7 @@ The agent is hosted using the [Agent Framework](https://github.com/microsoft/age ## Prerequisites -- An Azure AI Foundry project with a deployed model (e.g., `gpt-4o`) +- A Foundry project with a deployed model (e.g., `gpt-4o`) - Azure CLI logged in (`az login`) ### Required RBAC diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-AzureSearchRag/README.md b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-AzureSearchRag/README.md index 638ca559dfb..e57b90201d0 100644 --- a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-AzureSearchRag/README.md +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-AzureSearchRag/README.md @@ -7,7 +7,7 @@ This sample is the Azure AI Search counterpart to `Hosted-TextRag`. Where `Hoste ## Prerequisites - [.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0) -- An Azure AI Foundry project with a deployed model (e.g., `gpt-4o`) +- A Foundry project with a deployed model (e.g., `gpt-4o`) - An Azure AI Search service ([create one](https://learn.microsoft.com/azure/search/search-create-service-portal)) - **A pre-provisioned search index** with the schema and content described in the next section - Azure CLI logged in (`az login`) diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-ChatClientAgent/README.md b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-ChatClientAgent/README.md index 89c9bb85924..9a91909177a 100644 --- a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-ChatClientAgent/README.md +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-ChatClientAgent/README.md @@ -5,7 +5,7 @@ A simple general-purpose AI assistant hosted as a Foundry Hosted Agent using the ## Prerequisites - [.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0) -- An Azure AI Foundry project with a deployed model (e.g., `gpt-4o`) +- A Foundry project with a deployed model (e.g., `gpt-4o`) - Azure CLI logged in (`az login`) ## Configuration @@ -16,7 +16,7 @@ Copy the template and fill in your project endpoint: cp .env.example .env ``` -Edit `.env` and set your Azure AI Foundry project endpoint: +Edit `.env` and set your Foundry project endpoint: ```env FOUNDRY_PROJECT_ENDPOINT=https://.services.ai.azure.com/api/projects/ diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Files/Program.cs b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Files/Program.cs index 4472370e9a3..9d562c3012c 100644 --- a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Files/Program.cs +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Files/Program.cs @@ -20,7 +20,7 @@ // indirect prompt injection in an uploaded file. // // Required environment variables: -// FOUNDRY_PROJECT_ENDPOINT - Azure AI Foundry project endpoint +// FOUNDRY_PROJECT_ENDPOINT - Foundry project endpoint // FOUNDRY_MODEL - Model deployment name (default: gpt-4o) // // Optional: diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Files/README.md b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Files/README.md index d9c77c073d9..2ab61b55f20 100644 --- a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Files/README.md +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Files/README.md @@ -43,7 +43,7 @@ The end-to-end alpha-SDK round trip (client uploads via `AgentSessionFiles.Uploa ## Prerequisites - [.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0) -- An Azure AI Foundry project with a deployed model (e.g., `gpt-4o`) +- A Foundry project with a deployed model (e.g., `gpt-4o`) - Azure CLI logged in (`az login`) ## Configuration diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-FoundryAgent/README.md b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-FoundryAgent/README.md index a4894e0d24d..88a8cec48e9 100644 --- a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-FoundryAgent/README.md +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-FoundryAgent/README.md @@ -7,7 +7,7 @@ This is the **Foundry hosting** pattern — the agent's behavior is configured i ## Prerequisites - [.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0) -- An Azure AI Foundry project with a **registered agent** (created via Foundry UI, CLI, or API) +- A Foundry project with a **registered agent** (created via Foundry UI, CLI, or API) - Azure CLI logged in (`az login`) ## Configuration @@ -18,7 +18,7 @@ Copy the template and fill in your project endpoint: cp .env.example .env ``` -Edit `.env` and set your Azure AI Foundry project endpoint: +Edit `.env` and set your Foundry project endpoint: ```env FOUNDRY_PROJECT_ENDPOINT=https://.services.ai.azure.com/api/projects/ diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-LocalCodeAct/README.md b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-LocalCodeAct/README.md index 229ff4f5839..bc0dfdd581a 100644 --- a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-LocalCodeAct/README.md +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-LocalCodeAct/README.md @@ -21,7 +21,7 @@ sample for the `agent-framework-local-codeact` package. - Python 3 available on `PATH` (used by `LocalCodeActProvider` to execute the embedded runner and validator). Override with the `LOCAL_CODEACT_PYTHON` environment variable if you need a specific interpreter path. -- An Azure AI Foundry project with a deployed model (e.g., `gpt-4o`) +- A Foundry project with a deployed model (e.g., `gpt-4o`) - Azure CLI logged in (`az login`) ## Configuration @@ -32,7 +32,7 @@ Copy the template and fill in your project endpoint: cp .env.example .env ``` -Edit `.env` and set your Azure AI Foundry project endpoint: +Edit `.env` and set your Foundry project endpoint: ```env FOUNDRY_PROJECT_ENDPOINT=https://.services.ai.azure.com/api/projects/ diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-LocalTools/README.md b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-LocalTools/README.md index 246c2a495ae..f1b132fbcfa 100644 --- a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-LocalTools/README.md +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-LocalTools/README.md @@ -7,7 +7,7 @@ The agent specializes in finding hotels in Seattle, with a `GetAvailableHotels` ## Prerequisites - [.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0) -- An Azure AI Foundry project with a deployed model (e.g., `gpt-4o`) +- A Foundry project with a deployed model (e.g., `gpt-4o`) - Azure CLI logged in (`az login`) ## Configuration @@ -18,7 +18,7 @@ Copy the template and fill in your project endpoint: cp .env.example .env ``` -Edit `.env` and set your Azure AI Foundry project endpoint: +Edit `.env` and set your Foundry project endpoint: ```env FOUNDRY_PROJECT_ENDPOINT=https://.services.ai.azure.com/api/projects/ diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-McpTools/README.md b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-McpTools/README.md index d635de65bd9..337366a563f 100644 --- a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-McpTools/README.md +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-McpTools/README.md @@ -19,7 +19,7 @@ A hosted agent demonstrating **two layers of MCP (Model Context Protocol) tool i ## Prerequisites - [.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0) -- An Azure AI Foundry project with a deployed model (e.g., `gpt-4o`) +- A Foundry project with a deployed model (e.g., `gpt-4o`) - Azure CLI logged in (`az login`) ## Configuration diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-MemoryAgent/README.md b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-MemoryAgent/README.md index 69c8e34ec51..ea3bf51c5bd 100644 --- a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-MemoryAgent/README.md +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-MemoryAgent/README.md @@ -17,7 +17,7 @@ This sample exists to demonstrate two things together: ## Prerequisites - [.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0) -- An Azure AI Foundry project with at least one chat model deployment and one embedding model deployment +- A Foundry project with at least one chat model deployment and one embedding model deployment - Azure CLI logged in (`az login`) ## Configuration diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Observability/README.md b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Observability/README.md index 20e6a7f2b15..dd954c493cf 100644 --- a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Observability/README.md +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Observability/README.md @@ -27,7 +27,7 @@ Foundry injects `APPLICATIONINSIGHTS_CONNECTION_STRING` when the agent runs in t ## Prerequisites - [.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0) -- An Azure AI Foundry project with a deployed model (e.g., `gpt-4o`) +- A Foundry project with a deployed model (e.g., `gpt-4o`) - Azure CLI logged in (`az login`) ## Configuration @@ -36,7 +36,7 @@ Foundry injects `APPLICATIONINSIGHTS_CONNECTION_STRING` when the agent runs in t cp .env.example .env ``` -Edit `.env` and set your Azure AI Foundry project endpoint: +Edit `.env` and set your Foundry project endpoint: ```env FOUNDRY_PROJECT_ENDPOINT=https://.services.ai.azure.com/api/projects/ diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-TextRag/README.md b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-TextRag/README.md index 2e7511fb6b1..792b980db72 100644 --- a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-TextRag/README.md +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-TextRag/README.md @@ -7,7 +7,7 @@ This sample demonstrates how to add knowledge grounding to a hosted agent withou ## Prerequisites - [.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0) -- An Azure AI Foundry project with a deployed model (e.g., `gpt-4o`) +- A Foundry project with a deployed model (e.g., `gpt-4o`) - Azure CLI logged in (`az login`) ## Configuration @@ -18,7 +18,7 @@ Copy the template and fill in your project endpoint: cp .env.example .env ``` -Edit `.env` and set your Azure AI Foundry project endpoint: +Edit `.env` and set your Foundry project endpoint: ```env FOUNDRY_PROJECT_ENDPOINT=https://.services.ai.azure.com/api/projects/ diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox-AuthPaths/.env.example b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox-AuthPaths/.env.example index e4302a5a9a8..d32068c0533 100644 --- a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox-AuthPaths/.env.example +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox-AuthPaths/.env.example @@ -1,4 +1,4 @@ -# Azure AI Foundry project endpoint (auto-injected in hosted containers). +# Foundry project endpoint (auto-injected in hosted containers). AZURE_AI_PROJECT_ENDPOINT=https://.services.ai.azure.com/api/projects/ # Model deployment name. Must exist in the Foundry project above. diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox-AuthPaths/Program.cs b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox-AuthPaths/Program.cs index 7bf9baeaf53..96c16298a9d 100644 --- a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox-AuthPaths/Program.cs +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox-AuthPaths/Program.cs @@ -11,7 +11,7 @@ // // Required environment variables: // AZURE_AI_PROJECT_ENDPOINT (local-dev) OR FOUNDRY_PROJECT_ENDPOINT (hosted runtime) -// - Azure AI Foundry project endpoint. The Foundry hosted +// - Foundry project endpoint. The Foundry hosted // runtime auto-injects FOUNDRY_PROJECT_ENDPOINT; locally // set AZURE_AI_PROJECT_ENDPOINT (the AF-repo convention). // TOOLBOX_NAME - Name of the Foundry Toolbox to load diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox/.env.example b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox/.env.example new file mode 100644 index 00000000000..ad065ab0d34 --- /dev/null +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox/.env.example @@ -0,0 +1,16 @@ +# Foundry project endpoint (auto-injected in hosted containers). +AZURE_AI_PROJECT_ENDPOINT=https://.services.ai.azure.com/api/projects/ + +# Model deployment name. Must exist in the Foundry project above. +AZURE_AI_MODEL_DEPLOYMENT_NAME=gpt-4o + +# Name of the Foundry Toolbox you provisioned in the portal (see README.md). +TOOLBOX_NAME=my-toolset + +# Agent name advertised over the wire. Must be unique if running side-by-side with +# other Hosted-* samples (e.g. Hosted-Toolbox-AuthPaths), otherwise the REPL client +# cannot disambiguate which agent to chat with. +AGENT_NAME=hosted-toolbox-agent + +# Application Insights connection string (auto-injected in hosted containers; optional locally). +# APPLICATIONINSIGHTS_CONNECTION_STRING=InstrumentationKey=... diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox/Dockerfile b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox/Dockerfile new file mode 100644 index 00000000000..2a71c19858d --- /dev/null +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox/Dockerfile @@ -0,0 +1,17 @@ +# Use the official .NET 10.0 ASP.NET runtime as a parent image +FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS base +WORKDIR /app + +FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build +WORKDIR /src +COPY . . +RUN dotnet restore +RUN dotnet publish -c Release -o /app/publish + +# Final stage +FROM base AS final +WORKDIR /app +COPY --from=build /app/publish . +EXPOSE 8088 +ENV ASPNETCORE_URLS=http://+:8088 +ENTRYPOINT ["dotnet", "HostedToolbox.dll"] diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox/Dockerfile.contributor b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox/Dockerfile.contributor new file mode 100644 index 00000000000..cd01987e403 --- /dev/null +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox/Dockerfile.contributor @@ -0,0 +1,21 @@ +# Dockerfile for contributors building from the agent-framework repository source. +# +# This project uses ProjectReference to the local source, which means a standard +# multi-stage Docker build cannot resolve dependencies outside this folder. +# Pre-publish the app targeting the container runtime and copy the output: +# +# dotnet publish -c Debug -f net10.0 -r linux-musl-x64 --self-contained false -o out +# docker build -f Dockerfile.contributor -t hosted-toolbox . +# docker run --rm -p 8088:8088 \ +# -e AGENT_NAME=hosted-toolbox-agent \ +# -e AZURE_BEARER_TOKEN=$AZURE_BEARER_TOKEN \ +# --env-file .env hosted-toolbox +# +# For end-users consuming the NuGet package (not ProjectReference), use the standard +# Dockerfile which performs a full dotnet restore + publish inside the container. +FROM mcr.microsoft.com/dotnet/aspnet:10.0-alpine AS final +WORKDIR /app +COPY out/ . +EXPOSE 8088 +ENV ASPNETCORE_URLS=http://+:8088 +ENTRYPOINT ["dotnet", "HostedToolbox.dll"] diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox/Program.cs b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox/Program.cs index 3adae070047..3cc5d8bdcd0 100644 --- a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox/Program.cs +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox/Program.cs @@ -7,20 +7,18 @@ // // Required environment variables: // FOUNDRY_PROJECT_ENDPOINT (hosted runtime) OR AZURE_AI_PROJECT_ENDPOINT (local-dev) -// - Azure AI Foundry project endpoint. The Foundry hosted +// - Foundry project endpoint. The Foundry hosted // runtime auto-injects FOUNDRY_PROJECT_ENDPOINT; locally // set AZURE_AI_PROJECT_ENDPOINT. // FOUNDRY_MODEL - Model deployment name (default: gpt-4o) // // Optional: -// FOUNDRY_TOOLBOX_NAME - Name of the toolbox to load (default: my-toolset) -// FOUNDRY_AGENT_TOOLSET_ENDPOINT - Foundry Toolsets proxy base URL -// (injected automatically by Foundry platform at runtime) -// FOUNDRY_AGENT_NAME - Client name reported to MCP server (auto-injected in hosted runtime) -// FOUNDRY_AGENT_VERSION - Client version reported to MCP server (auto-injected in hosted runtime) -// FOUNDRY_AGENT_TOOLSET_FEATURES - Additional Foundry-Features header flags (the mandatory -// Toolboxes=V1Preview flag is always sent; this env var -// appends additional flags if present). +// TOOLBOX_NAME - Name of the toolbox to load (default: my-toolset). +// NOTE: All FOUNDRY_* and AGENT_* env-var prefixes (other +// than the platform-injected ones above) are reserved by the +// Foundry container platform and rejected at agent-create. +// Use TOOLBOX_NAME, not FOUNDRY_TOOLBOX_NAME, for the +// sample-owned toolbox name so it survives deployment. // // The Foundry.Hosting package builds the toolbox proxy URL from FOUNDRY_PROJECT_ENDPOINT // per tools-integration-spec.md §2–§3. @@ -43,8 +41,7 @@ "nor AZURE_AI_PROJECT_ENDPOINT (local-dev convention) is set."); string deploymentName = Environment.GetEnvironmentVariable("FOUNDRY_MODEL") ?? Environment.GetEnvironmentVariable("AZURE_AI_MODEL_DEPLOYMENT_NAME") ?? "gpt-4o"; -string toolboxName = Environment.GetEnvironmentVariable("FOUNDRY_TOOLBOX_NAME") - ?? Environment.GetEnvironmentVariable("TOOLBOX_NAME") ?? "my-toolset"; +string toolboxName = Environment.GetEnvironmentVariable("TOOLBOX_NAME") ?? "my-toolset"; // WARNING: DefaultAzureCredential is convenient for development but requires careful consideration in production. // In production, consider using a specific credential (e.g., ManagedIdentityCredential) to avoid diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox/README.md b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox/README.md index 37d4dd7d281..026ca49007b 100644 --- a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox/README.md +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox/README.md @@ -1,27 +1,111 @@ # Hosted-Toolbox -A hosted Foundry agent that loads tools from a Foundry Toolbox via the AF Foundry hosting bridge. +A hosted Foundry agent that loads tools from a single Foundry Toolbox via the AF Foundry hosting bridge. -The agent declares one `FoundryAITool.CreateHostedMcpToolbox(name)` marker; `AddFoundryToolboxes(name)` registers a `FoundryToolboxService` that resolves the marker into the individual MCP tools the toolbox bundles, connecting to the Foundry Toolboxes MCP proxy at startup and discovering tools via `tools/list`. +`AddFoundryToolboxes(name)` registers a `FoundryToolboxService` that connects to the Foundry Toolboxes MCP proxy at startup, discovers the toolbox's bundled tools via `tools/list`, and makes them available to the agent on every request. The agent code does nothing per request; the toolbox is baked in on the server. + +This is the minimal toolbox intro. For a richer walkthrough where a single toolbox bundles three MCP tools each authenticated differently, see [`Hosted-Toolbox-AuthPaths/`](../Hosted-Toolbox-AuthPaths/). ## Prerequisites -- A Microsoft Foundry project with a Toolbox configured. -- Azure CLI logged in (`az login`). -- Set environment variables: - - `AZURE_AI_PROJECT_ENDPOINT` (local-dev) or `FOUNDRY_PROJECT_ENDPOINT` (auto-injected in hosted containers) - - `AZURE_AI_MODEL_DEPLOYMENT_NAME` (default `gpt-4o`) - - `TOOLBOX_NAME` (default `my-toolbox`) +- [.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0) +- A Foundry project with a deployed model (e.g., `gpt-4o`) and a Toolbox configured +- Azure CLI logged in (`az login`) + +## Configuration + +Copy the template and fill in your values: + +```powershell +Copy-Item .env.example .env +``` + +Edit `.env`: + +```env +AZURE_AI_PROJECT_ENDPOINT=https://.services.ai.azure.com/api/projects/ +AZURE_AI_MODEL_DEPLOYMENT_NAME=gpt-4o +TOOLBOX_NAME=my-toolset +``` + +Configuration notes: + +- `AZURE_AI_PROJECT_ENDPOINT` (local-dev) or `FOUNDRY_PROJECT_ENDPOINT` (auto-injected in hosted containers). +- `AZURE_AI_MODEL_DEPLOYMENT_NAME` (default `gpt-4o`). +- `TOOLBOX_NAME` (default `my-toolset`). Use `TOOLBOX_NAME`, not `FOUNDRY_TOOLBOX_NAME`: all `FOUNDRY_*` env-var names are reserved by the Foundry platform and rejected at agent-create, so a `FOUNDRY_*`-named value would not survive deployment. The `Foundry.Hosting` package builds the toolbox proxy URL from `FOUNDRY_PROJECT_ENDPOINT` as `{FOUNDRY_PROJECT_ENDPOINT}/toolboxes/{TOOLBOX_NAME}/mcp?api-version=v1` per [`tools-integration-spec.md`](https://github.com/microsoft/AgentSchema/blob/main/specs/agents/hosted_agents/container-spec/docs/tools-integration-spec.md) §2–§3. -## Run +## Running directly (contributors) ```powershell +cd dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox dotnet run --tl:off ``` +### Test it + +Using the Azure Developer CLI: + +```powershell +azd ai agent invoke --local "What tools do you have available, and what can they do?" +``` + +## Running with Docker + +### 1. Publish for the container runtime + +```powershell +dotnet publish -c Debug -f net10.0 -r linux-musl-x64 --self-contained false -o out +``` + +### 2. Build and run + +```powershell +docker build -f Dockerfile.contributor -t hosted-toolbox . + +$env:AZURE_BEARER_TOKEN = (az account get-access-token --resource https://ai.azure.com --query accessToken -o tsv) + +docker run --rm -p 8088:8088 ` + -e AGENT_NAME=hosted-toolbox-agent ` + -e AZURE_BEARER_TOKEN=$env:AZURE_BEARER_TOKEN ` + --env-file .env ` + hosted-toolbox +``` + +## Deploying to Foundry (azd spec) + +This sample includes an `azd` manifest (`agent.manifest.yaml`) and hosted agent spec (`agent.yaml`) for deployment to Foundry. + +Initialize an `azd` project from this sample's manifest: + +```powershell +mkdir hosted-toolbox; cd hosted-toolbox +azd ai agent init -m https://github.com/microsoft/agent-framework/blob/main/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox/agent.manifest.yaml +``` + +Then deploy: + +```powershell +azd deploy +``` + +If you need to override defaults, set deployment-time environment variables in the `azd` environment before deploying: + +```powershell +azd env set AZURE_AI_MODEL_DEPLOYMENT_NAME gpt-4o +azd env set TOOLBOX_NAME my-toolset +``` + +For end-to-end hosted agent deployment guidance, see the [official deployment guide](https://learn.microsoft.com/en-us/azure/foundry/agents/how-to/deploy-hosted-agent). + +--- + +## NuGet package users + +Use the standard `Dockerfile` instead of `Dockerfile.contributor`. See the commented section in `HostedToolbox.csproj` for the `PackageReference` alternative. + ## Related samples -- [`Hosted-Toolbox-AuthPaths/`](../Hosted-Toolbox-AuthPaths/) — extends this pattern with a three-tool toolbox demonstrating different MCP-tool authentication paths (key, Entra agent identity, inline `Authorization`), driven by the shared `Using-Samples/SimpleAgent/` REPL. +- [`Hosted-Toolbox-AuthPaths/`](../Hosted-Toolbox-AuthPaths/) — same hosting bones as this sample, but the toolbox bundles three MCP tools each authenticated differently (key, Entra agent identity, inline `Authorization`), driven by the shared `Using-Samples/SimpleAgent/` REPL. - [`Hosted-McpTools/`](../Hosted-McpTools/) — contrasts client-side `McpClient` vs server-side `HostedMcpServerTool` for non-toolbox MCP servers. diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox/agent.manifest.yaml b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox/agent.manifest.yaml new file mode 100644 index 00000000000..40bda33f185 --- /dev/null +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox/agent.manifest.yaml @@ -0,0 +1,47 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/microsoft/AgentSchema/refs/heads/main/schemas/v1.0/AgentManifest.yaml +name: hosted-toolbox +displayName: "Hosted Toolbox" + +description: > + A hosted agent that loads its tools from a single Foundry Toolbox via the + AF Foundry hosting bridge. AddFoundryToolboxes(name) connects to the Foundry + Toolboxes MCP proxy at startup and exposes the toolbox's bundled tools to the + agent on every request. The toolbox itself is provisioned out of band; see this + sample's README for the portal walkthrough. + +metadata: + tags: + - AI Agent Hosting + - Azure AI AgentServer + - Responses Protocol + - Agent Framework + - Foundry Toolbox + - MCP + +template: + name: hosted-toolbox + kind: hosted + protocols: + - protocol: responses + version: 1.0.0 + resources: + cpu: "0.25" + memory: 0.5Gi + environment_variables: + - name: AZURE_AI_MODEL_DEPLOYMENT_NAME + value: "{{AZURE_AI_MODEL_DEPLOYMENT_NAME}}" + - name: TOOLBOX_NAME + value: "{{TOOLBOX_NAME}}" +parameters: + properties: + - name: TOOLBOX_NAME + type: string + default: "my-toolset" + description: "Name of the Foundry Toolbox to load at runtime." +resources: + - kind: model + id: gpt-4o + name: AZURE_AI_MODEL_DEPLOYMENT_NAME + - kind: toolbox + name: "{{TOOLBOX_NAME}}" + tools: [] diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox/agent.yaml b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox/agent.yaml new file mode 100644 index 00000000000..3a743b81e5e --- /dev/null +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox/agent.yaml @@ -0,0 +1,9 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/microsoft/AgentSchema/refs/heads/main/schemas/v1.0/ContainerAgent.yaml +kind: hosted +name: hosted-toolbox +protocols: + - protocol: responses + version: 1.0.0 +resources: + cpu: "0.25" + memory: 0.5Gi diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-ToolboxMcpSkills/Program.cs b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-ToolboxMcpSkills/Program.cs index 99dbdc65737..ee61f1b953e 100644 --- a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-ToolboxMcpSkills/Program.cs +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-ToolboxMcpSkills/Program.cs @@ -7,7 +7,7 @@ // AgentSkillsProviderBuilder.UseMcpSkills(). // // Required environment variables: -// FOUNDRY_PROJECT_ENDPOINT - Azure AI Foundry project endpoint +// FOUNDRY_PROJECT_ENDPOINT - Foundry project endpoint // FOUNDRY_TOOLBOX_NAME - Name of the Foundry Toolbox to connect to // FOUNDRY_MODEL - Model deployment name (default: gpt-5) diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-ToolboxMcpSkills/README.md b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-ToolboxMcpSkills/README.md index 7b091095200..7071158cfcf 100644 --- a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-ToolboxMcpSkills/README.md +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-ToolboxMcpSkills/README.md @@ -13,7 +13,7 @@ This way the full skill body and resources are only loaded when the agent actual ## Prerequisites - [.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0) -- An Azure AI Foundry project with a deployed model (e.g., `gpt-5`) +- A Foundry project with a deployed model (e.g., `gpt-5`) - A Foundry Toolbox already configured with skills provisioned - Azure CLI logged in (`az login`) @@ -25,7 +25,7 @@ Copy the template and fill in your values: cp .env.example .env ``` -Edit `.env` and set your Azure AI Foundry project endpoint and toolbox name: +Edit `.env` and set your Foundry project endpoint and toolbox name: ```env FOUNDRY_PROJECT_ENDPOINT=https://.services.ai.azure.com/api/projects/ diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Workflow-Handoff/README.md b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Workflow-Handoff/README.md index 341564ad738..0d722aef7e1 100644 --- a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Workflow-Handoff/README.md +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Workflow-Handoff/README.md @@ -7,7 +7,7 @@ A hosted agent server demonstrating two patterns in a single app: Both agents are served over the Responses protocol. The server also exposes interactive web demos at `/tool-demo` and `/workflow-demo`. -> Unlike the other samples in this folder, this one connects to an **Azure OpenAI** resource directly (not an Azure AI Foundry project endpoint). +> Unlike the other samples in this folder, this one connects to an **Azure OpenAI** resource directly (not a Foundry project endpoint). ## Prerequisites diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Workflow-Simple/README.md b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Workflow-Simple/README.md index cdbe36911d3..8facce34395 100644 --- a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Workflow-Simple/README.md +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Workflow-Simple/README.md @@ -5,7 +5,7 @@ A hosted agent that demonstrates **multi-agent workflow orchestration**. Three t ## Prerequisites - [.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0) -- An Azure AI Foundry project with a deployed model (e.g., `hosted-workflow-simple`) +- A Foundry project with a deployed model (e.g., `hosted-workflow-simple`) - Azure CLI logged in (`az login`) ## Configuration @@ -16,7 +16,7 @@ Copy the template and fill in your project endpoint: cp .env.example .env ``` -Edit `.env` and set your Azure AI Foundry project endpoint: +Edit `.env` and set your Foundry project endpoint: ```env FOUNDRY_PROJECT_ENDPOINT=https://.services.ai.azure.com/api/projects/ diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Using-Samples/README.md b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Using-Samples/README.md new file mode 100644 index 00000000000..656c2f247e0 --- /dev/null +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Using-Samples/README.md @@ -0,0 +1,51 @@ +# Using-Samples — client REPLs for the hosted agents + +This folder holds small **client** console apps that connect to the **server** samples in the +sibling `Hosted-*` folders. Each `Hosted-*` project is an agent you host (locally with +`dotnet run` or deployed to Foundry); the projects here are the thing that *talks* to them. + +## Why these exist + +A hosted Foundry agent is an HTTP server, not a chat UI. It exposes only the per-agent OpenAI +endpoint shape that the platform routes to: + +``` +{FOUNDRY_PROJECT_ENDPOINT}/agents/{AZURE_AI_AGENT_NAME}/endpoint/protocols/openai +``` + +There is no built-in console to poke it with. To actually exercise an agent — send a prompt, +watch it call its tools, read the streamed answer — you need a client that builds a +`FoundryAgent` against that endpoint and drives a conversation. That is all these REPLs do: + +1. Read `FOUNDRY_PROJECT_ENDPOINT` + `AZURE_AI_AGENT_NAME` from the environment. +2. Derive the per-agent OpenAI endpoint URL. +3. `AIProjectClient(...).AsAIAgent(agentEndpoint)` → `FoundryAgent`. +4. Loop: read a line, `RunStreamingAsync`, print the streamed reply. + +The client is deliberately dumb. It knows nothing about tools, files, toolboxes, or auth — all +of that is the hosted agent's concern on the server side. Swapping which agent you chat with is +just a matter of changing `AZURE_AI_AGENT_NAME`. + +## Local HTTP dev + +When the target is a local `http://localhost:8088` dev server, the REPLs install a small +`HttpSchemeRewritePolicy`: `AIProjectClient`/`BearerTokenPolicy` require HTTPS, so the client +presents the endpoint as `https://` to satisfy the TLS check, then rewrites the scheme back to +`http://` right before the request hits the wire. This is local-development only. + +## The clients + +| Client | What it targets | Notes | +|---|---|---| +| [`SimpleAgent/`](./SimpleAgent/) | Any hosted agent | Generic, agent-agnostic REPL. Point it at any `Hosted-*` server via `AZURE_AI_AGENT_NAME`. Used by `Hosted-Toolbox`, `Hosted-Toolbox-AuthPaths`, and `Hosted-McpTools`. | +| [`SessionFilesClient/`](./SessionFilesClient/) | [`Hosted-Files`](../Hosted-Files/) | Same shape as `SimpleAgent`, framed around the bundled-files demo. | + +## Configuration (common to all clients) + +```env +FOUNDRY_PROJECT_ENDPOINT=https:///api/projects/ +AZURE_AI_AGENT_NAME= +``` + +Both are required. Authenticate with `az login` before running. See each client's own README for +its end-to-end walkthrough. diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Using-Samples/SimpleAgent/README.md b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Using-Samples/SimpleAgent/README.md new file mode 100644 index 00000000000..b68cafee200 --- /dev/null +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Using-Samples/SimpleAgent/README.md @@ -0,0 +1,63 @@ +# SimpleAgent + +A generic, agent-agnostic chat REPL for any hosted Foundry agent. Point it at a running +`Hosted-*` agent via `AZURE_AI_AGENT_NAME`, and it builds a `FoundryAgent` against that agent's +per-agent OpenAI endpoint and streams replies. This is the shared client that `Hosted-Toolbox`, +`Hosted-Toolbox-AuthPaths`, and `Hosted-McpTools` reference for their end-to-end demos. + +It knows nothing about the agent's tools, toolboxes, files, or auth — those are entirely the +server's concern. Changing which agent you chat with is just a different `AZURE_AI_AGENT_NAME`. +See [`../README.md`](../README.md) for why these client REPLs exist at all. + +## Prerequisites + +- [.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0) +- A running hosted agent (any `Hosted-*` sample, locally via `dotnet run` or deployed to Foundry) +- Azure CLI logged in (`az login`) + +## Configuration + +```env +FOUNDRY_PROJECT_ENDPOINT=https:///api/projects/ +AZURE_AI_AGENT_NAME= +``` + +Both are required. `FOUNDRY_PROJECT_ENDPOINT` is the Foundry project endpoint URL and +`AZURE_AI_AGENT_NAME` is the registered server-side agent name. The sample builds the per-agent +OpenAI endpoint URL (`{FOUNDRY_PROJECT_ENDPOINT}/agents/{AZURE_AI_AGENT_NAME}/endpoint/protocols/openai`) +from these. + +## Run + +Against a local Hosted-Toolbox agent listening on `http://localhost:8088`: + +```powershell +cd dotnet/samples/04-hosting/FoundryHostedAgents/responses/Using-Samples/SimpleAgent +$env:FOUNDRY_PROJECT_ENDPOINT = "http://localhost:8088/api/projects/local" +$env:AZURE_AI_AGENT_NAME = "hosted-toolbox-agent" +dotnet run +``` + +When the project endpoint is `http://`, the client presents it as `https://` to satisfy the +bearer-token TLS check, then rewrites the scheme back to `http://` right before transport +(local-development only). + +## End-to-end demo + +With a hosted agent running: + +```text +══════════════════════════════════════════════════════════ +Simple Agent Sample +Connected to: http://localhost:8088/agents/hosted-toolbox-agent/endpoint/protocols/openai +Type a message or 'quit' to exit +══════════════════════════════════════════════════════════ + +You> What tools do you have available, and what can they do? +Agent> I have the following tools from the toolbox: ... + +You> quit +Goodbye! +``` + +The client only sent a chat prompt; the agent resolved its toolbox tools server-side and answered. From 947cd41fe240d7e8d9871a10bc00a3e09ab9580c Mon Sep 17 00:00:00 2001 From: Roger Barreto <19890735+RogerBarreto@users.noreply.github.com> Date: Fri, 19 Jun 2026 18:01:40 +0100 Subject: [PATCH 2/2] Address PR review: accurate docs and TOOLBOX_NAME in ToolboxMcpSkills - SimpleAgent README: correct the demo banner to the real per-agent URL the client prints (https scheme and the /api/projects/ segment). - Hosted-Toolbox Program.cs: move FOUNDRY_MODEL out of the Required block into Optional since it has a gpt-4o default and an AZURE_AI_MODEL_DEPLOYMENT_NAME fallback. - Hosted-ToolboxMcpSkills: switch the toolbox name from the reserved FOUNDRY_TOOLBOX_NAME to TOOLBOX_NAME across Program.cs, .env.example, agent.yaml, agent.manifest.yaml and README so it is deployable via the manifest, matching the other toolbox samples. --- .../responses/Hosted-Toolbox/Program.cs | 3 ++- .../Hosted-ToolboxMcpSkills/.env.example | 2 +- .../responses/Hosted-ToolboxMcpSkills/Program.cs | 15 +++++++++++---- .../responses/Hosted-ToolboxMcpSkills/README.md | 2 +- .../Hosted-ToolboxMcpSkills/agent.manifest.yaml | 6 +++--- .../responses/Hosted-ToolboxMcpSkills/agent.yaml | 4 ++-- .../responses/Using-Samples/SimpleAgent/README.md | 2 +- 7 files changed, 21 insertions(+), 13 deletions(-) diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox/Program.cs b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox/Program.cs index 3cc5d8bdcd0..306a6d4eea8 100644 --- a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox/Program.cs +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Toolbox/Program.cs @@ -10,9 +10,10 @@ // - Foundry project endpoint. The Foundry hosted // runtime auto-injects FOUNDRY_PROJECT_ENDPOINT; locally // set AZURE_AI_PROJECT_ENDPOINT. -// FOUNDRY_MODEL - Model deployment name (default: gpt-4o) // // Optional: +// FOUNDRY_MODEL (or AZURE_AI_MODEL_DEPLOYMENT_NAME) +// - Model deployment name (default: gpt-4o) // TOOLBOX_NAME - Name of the toolbox to load (default: my-toolset). // NOTE: All FOUNDRY_* and AGENT_* env-var prefixes (other // than the platform-injected ones above) are reserved by the diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-ToolboxMcpSkills/.env.example b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-ToolboxMcpSkills/.env.example index 0f603ea20c0..064a6ce629d 100644 --- a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-ToolboxMcpSkills/.env.example +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-ToolboxMcpSkills/.env.example @@ -2,5 +2,5 @@ FOUNDRY_PROJECT_ENDPOINT= ASPNETCORE_URLS=http://+:8088 ASPNETCORE_ENVIRONMENT=Development FOUNDRY_MODEL=gpt-5 -FOUNDRY_TOOLBOX_NAME= +TOOLBOX_NAME= AZURE_BEARER_TOKEN=DefaultAzureCredential diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-ToolboxMcpSkills/Program.cs b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-ToolboxMcpSkills/Program.cs index ee61f1b953e..f3a8e4aa6d0 100644 --- a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-ToolboxMcpSkills/Program.cs +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-ToolboxMcpSkills/Program.cs @@ -8,8 +8,15 @@ // // Required environment variables: // FOUNDRY_PROJECT_ENDPOINT - Foundry project endpoint -// FOUNDRY_TOOLBOX_NAME - Name of the Foundry Toolbox to connect to -// FOUNDRY_MODEL - Model deployment name (default: gpt-5) +// TOOLBOX_NAME - Name of the Foundry Toolbox to connect to +// +// Optional: +// FOUNDRY_MODEL - Model deployment name (default: gpt-5) +// +// NOTE: All FOUNDRY_* and AGENT_* env-var prefixes (other than the platform-injected ones +// listed above) are reserved by the Foundry container platform and rejected at agent-create. +// Use TOOLBOX_NAME, not FOUNDRY_TOOLBOX_NAME, for the sample-owned toolbox name so it +// survives deployment. using System.Net.Http.Headers; using Azure.AI.Projects; @@ -27,8 +34,8 @@ var projectEndpoint = Environment.GetEnvironmentVariable("FOUNDRY_PROJECT_ENDPOINT") ?? throw new InvalidOperationException("FOUNDRY_PROJECT_ENDPOINT is not set."); var deployment = Environment.GetEnvironmentVariable("FOUNDRY_MODEL") ?? "gpt-5"; -var toolboxName = Environment.GetEnvironmentVariable("FOUNDRY_TOOLBOX_NAME") - ?? throw new InvalidOperationException("FOUNDRY_TOOLBOX_NAME is not set."); +var toolboxName = Environment.GetEnvironmentVariable("TOOLBOX_NAME") + ?? throw new InvalidOperationException("TOOLBOX_NAME is not set."); // Build the Toolbox MCP URL from the project endpoint and toolbox name. var toolboxMcpServerUrl = $"{projectEndpoint.TrimEnd('/')}/toolboxes/{toolboxName}/mcp?api-version=v1"; diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-ToolboxMcpSkills/README.md b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-ToolboxMcpSkills/README.md index 7071158cfcf..76fe45866d8 100644 --- a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-ToolboxMcpSkills/README.md +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-ToolboxMcpSkills/README.md @@ -32,7 +32,7 @@ FOUNDRY_PROJECT_ENDPOINT=https://.services.ai.azure.com/api/projec ASPNETCORE_URLS=http://+:8088 ASPNETCORE_ENVIRONMENT=Development FOUNDRY_MODEL=gpt-5 -FOUNDRY_TOOLBOX_NAME=my-toolbox +TOOLBOX_NAME=my-toolbox ``` > **Note:** `.env` is gitignored. The `.env.example` template is checked in as a reference. diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-ToolboxMcpSkills/agent.manifest.yaml b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-ToolboxMcpSkills/agent.manifest.yaml index ad85fb1bca5..ed3d6a9eb0c 100644 --- a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-ToolboxMcpSkills/agent.manifest.yaml +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-ToolboxMcpSkills/agent.manifest.yaml @@ -30,11 +30,11 @@ template: environment_variables: - name: FOUNDRY_MODEL value: "{{FOUNDRY_MODEL}}" - - name: FOUNDRY_TOOLBOX_NAME - value: "{{FOUNDRY_TOOLBOX_NAME}}" + - name: TOOLBOX_NAME + value: "{{TOOLBOX_NAME}}" parameters: properties: - - name: FOUNDRY_TOOLBOX_NAME + - name: TOOLBOX_NAME secret: false description: Name of the Foundry Toolbox to connect to for MCP skill discovery resources: diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-ToolboxMcpSkills/agent.yaml b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-ToolboxMcpSkills/agent.yaml index 140a5fc4c61..ac766bff9c3 100644 --- a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-ToolboxMcpSkills/agent.yaml +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-ToolboxMcpSkills/agent.yaml @@ -10,5 +10,5 @@ resources: environment_variables: - name: FOUNDRY_MODEL value: ${FOUNDRY_MODEL} - - name: FOUNDRY_TOOLBOX_NAME - value: ${FOUNDRY_TOOLBOX_NAME} + - name: TOOLBOX_NAME + value: ${TOOLBOX_NAME} diff --git a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Using-Samples/SimpleAgent/README.md b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Using-Samples/SimpleAgent/README.md index b68cafee200..6d98560bb27 100644 --- a/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Using-Samples/SimpleAgent/README.md +++ b/dotnet/samples/04-hosting/FoundryHostedAgents/responses/Using-Samples/SimpleAgent/README.md @@ -49,7 +49,7 @@ With a hosted agent running: ```text ══════════════════════════════════════════════════════════ Simple Agent Sample -Connected to: http://localhost:8088/agents/hosted-toolbox-agent/endpoint/protocols/openai +Connected to: https://localhost:8088/api/projects/local/agents/hosted-toolbox-agent/endpoint/protocols/openai Type a message or 'quit' to exit ══════════════════════════════════════════════════════════