Skip to content

.NET: Migrate remaining Foundry hosted samples to source deployment - #7668

Merged
Roger Barreto (rogerbarreto) merged 11 commits into
microsoft:mainfrom
rogerbarreto:zip-samples-phase-02
Aug 19, 2026
Merged

.NET: Migrate remaining Foundry hosted samples to source deployment#7668
Roger Barreto (rogerbarreto) merged 11 commits into
microsoft:mainfrom
rogerbarreto:zip-samples-phase-02

Conversation

@rogerbarreto

Copy link
Copy Markdown
Member

Motivation & Context

Source deployment, where Foundry receives a code or ZIP upload and builds it remotely, is now the default path for .NET hosted agents. PR #7372 established that path for Hosted-ChatClientAgent, but the remaining samples still required Dockerfiles, container registry configuration, and older split agent manifests. This made the documented path more complex than the platform requires and left contributors using a different deployment path from end users.

This change completes that migration across the remaining Foundry hosted agent samples while preserving the configuration, packaged resources, permissions, and external dependencies that are specific to each scenario.

Description & Review Guide

  • What are the major changes?

    Migrates the remaining 16 hosted agent samples to one azure.yaml with codeConfiguration, remote dotnet restore and dotnet publish, and a generated .agentignore. Removes the source deployment Dockerfiles and split agent.yaml and agent.manifest.yaml files.

    Makes every uploaded project self-contained because repository build configuration does not travel in the ZIP. Projects declare their target framework and package versions directly, opt out of central package management, and include required resources such as AgentSkills content in the published output.

    Aligns every README with the same documented azd ai agent init, azd provision, azd deploy, and azd ai agent invoke flow. Each README also documents its own model, search, memory, toolbox, OAuth consent, Azure OpenAI role, resource packaging, and cleanup requirements.

    Includes fixes found through standalone and live deployment testing, including the Invocations readiness endpoint, copying AgentSkills resources, and suppressing OPENAI001 inside the Workflow Handoff project because repository-wide warning settings are unavailable during remote ZIP builds.

  • What is the impact of these changes?

    End users can deploy these samples directly from source without authoring a container image or managing a registry. Contributors use the same flow with one optional step that places locally built Agent Framework packages inside the upload. Existing sample behavior and protocols remain unchanged.

  • What do you want reviewers to focus on?

    Please focus on the consistency of each azure.yaml and self-contained project file, and on whether each README clearly distinguishes the common deployment flow from the sample-specific resources and permissions it requires.

Related Issue

Fixes#7667

This is the continuation of merged PR #7372. No other open PR targets #7667.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

Extend the source (ZIP) deploy pattern established for Hosted-ChatClientAgent to Hosted-LocalTools, Hosted-Workflow-Simple, Hosted-TextRag, Hosted-Observability, Hosted-Files and Hosted-FoundryAgent. Each gains an azure.yaml (codeConfiguration/remote_build, ASPNETCORE_URLS, model env) and the canonical .agentignore, a self-contained csproj (single target, CPM opt-out, explicit published package versions, AgentFrameworkVersion), a Program.cs that drops the shared contributor scaffolding for DefaultAzureCredential, an updated .env.example and README, and drops the container-mode files (agent.yaml, agent.manifest.yaml, Dockerfile, Dockerfile.contributor). LocalTools, Workflow-Simple, TextRag, Observability and Files were verified deploying live via remote_build; Workflow-Simple returns a workflow runtime error at invoke that is unrelated to the deploy mode.
… source (ZIP) deploy
EchoAgent (Invocations protocol) and LocalCodeAct migrated to the zip/code-deploy pattern (azure.yaml, .agentignore, self-contained csproj, README, container files removed). EchoAgent maps /readiness explicitly because the Invocations SDK does not auto-map it. Both verified live via remote_build on a Foundry project; LocalCodeAct's execute_code ran server-side (compute 21+21 -> 42).
Migrate Hosted-McpTools, Hosted-MemoryAgent, Hosted-AgentSkills, Hosted-AzureSearchRag, Hosted-Toolbox, Hosted-Toolbox-AuthPaths and Hosted-ToolboxMcpSkills to the zip/code-deploy pattern (azure.yaml with codeConfiguration + sample-specific env passthrough, canonical .agentignore, self-contained csproj, Program.cs dropping the shared contributor scaffolding for DefaultAzureCredential, updated .env.example and README, container files removed). Also restore the Hosted-Invocations-EchoAgent csproj filename the solution references. McpTools verified live via remote_build against the public Microsoft Learn MCP server; the memory/search/toolbox/skills samples build locally and deploy via remote_build but need their external resources (memory store, search index, toolbox connections, skills) provisioned to exercise end to end.
Migrate the triage handoff workflow sample to the zip/code-deploy pattern (azure.yaml with codeConfiguration and Azure OpenAI env passthrough, canonical .agentignore, self-contained csproj using AgentFrameworkVersion for Foundry/Foundry.Hosting/Hosting, Program.cs dropping the shared contributor scaffolding for DefaultAzureCredential, updated .env.example and README, container files removed). Builds via remote_build; live needs an Azure OpenAI resource (AZURE_OPENAI_ENDPOINT/AZURE_OPENAI_DEPLOYMENT).
The startup provisioning helper reads SKILL.md files from AppContext.BaseDirectory/skills, but the project did not copy the skills/ folder to the build/publish output, so at runtime the source directory did not exist and provisioning was silently skipped. Add a Content include (PreserveNewest), matching the resources/ pattern already used by Hosted-Files.
…P build
The repo-wide Directory.Build.props suppresses OPENAI001, but that file does
not travel in the code/ZIP deploy package. The standalone dotnet publish the
Foundry code deploy runs then fails with error OPENAI001 on the experimental
GetResponsesClient().AsIChatClient() call. Add OPENAI001 to the project NoWarn
so the sample builds in the code-deploy pipeline, matching SimpleAgent.csproj.
…READMEs
Align every FoundryHostedAgents sample README with the documented azd flow and
add the idiosyncrasies found while live-testing each sample on a Foundry project:
- All samples: 'azd down' reports success but does not delete the hosted agent;
document the explicit REST DELETE needed to remove it.
- Hosted-Workflow-Handoff: it builds its own AzureOpenAIClient (data-plane), so
the agent identity needs the 'Cognitive Services OpenAI User' role on the
Azure OpenAI account. azd only grants 'Foundry User' on the project, so add a
step to grant the data-plane role and explain the triage-step failure without it.
- Hosted-Toolbox / Toolbox-AuthPaths / ToolboxMcpSkills: the toolbox must already
exist and the agent identity must be able to read it; toolboxes with OAuth-gated
tools return an oauth_consent_request and response.incomplete on first invoke.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Migrates the remaining .NET Foundry hosted-agent samples from container-image deployment to source/ZIP deployment while retaining each scenario’s configuration and dependencies.

Changes:

  • Adds unified azure.yaml source-deployment configurations and self-contained project files.
  • Removes obsolete Dockerfiles and split agent manifests; adds upload exclusions and updated setup guidance.
  • Adds resource packaging and readiness fixes for Agent Skills and Invocations samples.

Reviewed changes

Copilot reviewed 163 out of 163 changed files in this pull request and generated 9 comments.

Show a summary per file

Base path: dotnet/samples/04-hosting/FoundryHostedAgents/

FileDescription
responses/Hosted-Workflow-Simple/Program.csUpdates source-hosted configuration and authentication.
responses/Hosted-Workflow-Simple/HostedWorkflowSimple.csprojMakes the ZIP project self-contained.
responses/Hosted-Workflow-Simple/README.mdDocuments source deployment.
responses/Hosted-Workflow-Simple/Dockerfile.contributorRemoves contributor container deployment.
responses/Hosted-Workflow-Simple/DockerfileRemoves image deployment.
responses/Hosted-Workflow-Simple/azure.yamlAdds unified source deployment.
responses/Hosted-Workflow-Simple/agent.yamlRemoves obsolete agent definition.
responses/Hosted-Workflow-Simple/agent.manifest.yamlRemoves obsolete manifest.
responses/Hosted-Workflow-Simple/.env.exampleUpdates local configuration.
responses/Hosted-Workflow-Simple/.agentignoreDefines ZIP exclusions.
responses/Hosted-Workflow-Handoff/Program.csUpdates hosted authentication.
responses/Hosted-Workflow-Handoff/HostedWorkflowHandoff.csprojAdds standalone dependencies and warning settings.
responses/Hosted-Workflow-Handoff/README.mdDocuments source deployment and Azure OpenAI permissions.
responses/Hosted-Workflow-Handoff/Dockerfile.contributorRemoves contributor container deployment.
responses/Hosted-Workflow-Handoff/DockerfileRemoves image deployment.
responses/Hosted-Workflow-Handoff/azure.yamlAdds unified source deployment.
responses/Hosted-Workflow-Handoff/agent.yamlRemoves obsolete agent definition.
responses/Hosted-Workflow-Handoff/agent.manifest.yamlRemoves obsolete manifest.
responses/Hosted-Workflow-Handoff/.env.exampleUpdates Azure OpenAI configuration.
responses/Hosted-Workflow-Handoff/.agentignoreDefines ZIP exclusions.
responses/Hosted-ToolboxMcpSkills/Program.csUpdates credentials and hosted endpoints.
responses/Hosted-ToolboxMcpSkills/HostedToolboxMcpSkills.csprojAdds standalone MCP dependencies.
responses/Hosted-ToolboxMcpSkills/README.mdDocuments toolbox source deployment.
responses/Hosted-ToolboxMcpSkills/Dockerfile.contributorRemoves contributor container deployment.
responses/Hosted-ToolboxMcpSkills/DockerfileRemoves image deployment.
responses/Hosted-ToolboxMcpSkills/azure.yamlAdds toolbox source deployment.
responses/Hosted-ToolboxMcpSkills/agent.yamlRemoves obsolete agent definition.
responses/Hosted-ToolboxMcpSkills/agent.manifest.yamlRemoves obsolete manifest.
responses/Hosted-ToolboxMcpSkills/.env.exampleUpdates model and toolbox configuration.
responses/Hosted-ToolboxMcpSkills/.agentignoreDefines ZIP exclusions.
responses/Hosted-Toolbox/Program.csUpdates credentials and configuration access.
responses/Hosted-Toolbox/HostedToolbox.csprojMakes the ZIP project self-contained.
responses/Hosted-Toolbox/README.mdDocuments toolbox deployment.
responses/Hosted-Toolbox/Dockerfile.contributorRemoves contributor container deployment.
responses/Hosted-Toolbox/DockerfileRemoves image deployment.
responses/Hosted-Toolbox/azure.yamlAdds toolbox source deployment.
responses/Hosted-Toolbox/agent.yamlRemoves obsolete agent definition.
responses/Hosted-Toolbox/agent.manifest.yamlRemoves obsolete manifest.
responses/Hosted-Toolbox/.env.exampleUpdates model and toolbox configuration.
responses/Hosted-Toolbox/.agentignoreDefines ZIP exclusions.
responses/Hosted-Toolbox-AuthPaths/Program.csRemoves temporary-token support.
responses/Hosted-Toolbox-AuthPaths/Hosted-Toolbox-AuthPaths.csprojMakes the ZIP project self-contained.
responses/Hosted-Toolbox-AuthPaths/README.mdDocuments OAuth toolbox deployment.
responses/Hosted-Toolbox-AuthPaths/Dockerfile.contributorRemoves contributor container deployment.
responses/Hosted-Toolbox-AuthPaths/DockerfileRemoves image deployment.
responses/Hosted-Toolbox-AuthPaths/azure.yamlAdds OAuth toolbox source deployment.
responses/Hosted-Toolbox-AuthPaths/agent.yamlRemoves obsolete agent definition.
responses/Hosted-Toolbox-AuthPaths/agent.manifest.yamlRemoves obsolete manifest.
responses/Hosted-Toolbox-AuthPaths/.env.exampleUpdates local OAuth configuration.
responses/Hosted-Toolbox-AuthPaths/.agentignoreDefines ZIP exclusions.
responses/Hosted-TextRag/Program.csUpdates model selection and authentication.
responses/Hosted-TextRag/HostedTextRag.csprojMakes the ZIP project self-contained.
responses/Hosted-TextRag/README.mdDocuments source deployment.
responses/Hosted-TextRag/Dockerfile.contributorRemoves contributor container deployment.
responses/Hosted-TextRag/DockerfileRemoves image deployment.
responses/Hosted-TextRag/azure.yamlAdds RAG source deployment.
responses/Hosted-TextRag/agent.yamlRemoves obsolete agent definition.
responses/Hosted-TextRag/agent.manifest.yamlRemoves obsolete manifest.
responses/Hosted-TextRag/.env.exampleUpdates local model configuration.
responses/Hosted-TextRag/.agentignoreDefines ZIP exclusions.
responses/Hosted-Observability/Program.csUpdates source-hosted configuration.
responses/Hosted-Observability/HostedObservability.csprojMakes the ZIP project self-contained.
responses/Hosted-Observability/README.mdDocuments observable source deployment.
responses/Hosted-Observability/Dockerfile.contributorRemoves contributor container deployment.
responses/Hosted-Observability/DockerfileRemoves image deployment.
responses/Hosted-Observability/azure.yamlAdds telemetry-enabled source deployment.
responses/Hosted-Observability/agent.yamlRemoves obsolete agent definition.
responses/Hosted-Observability/agent.manifest.yamlRemoves obsolete manifest.
responses/Hosted-Observability/.env.exampleUpdates local configuration.
responses/Hosted-Observability/.dockerignoreRemoves obsolete Docker exclusions.
responses/Hosted-Observability/.agentignoreDefines ZIP exclusions.
responses/Hosted-MemoryAgent/Program.csUpdates memory and model configuration.
responses/Hosted-MemoryAgent/HostedMemoryAgent.csprojMakes the ZIP project self-contained.
responses/Hosted-MemoryAgent/README.mdDocuments memory deployment requirements.
responses/Hosted-MemoryAgent/Dockerfile.contributorRemoves contributor container deployment.
responses/Hosted-MemoryAgent/DockerfileRemoves image deployment.
responses/Hosted-MemoryAgent/azure.yamlAdds memory-agent source deployment.
responses/Hosted-MemoryAgent/agent.yamlRemoves obsolete agent definition.
responses/Hosted-MemoryAgent/agent.manifest.yamlRemoves obsolete manifest.
responses/Hosted-MemoryAgent/.env.exampleUpdates memory configuration.
responses/Hosted-MemoryAgent/.agentignoreDefines ZIP exclusions.
responses/Hosted-McpTools/Program.csUpdates MCP source-hosted configuration.
responses/Hosted-McpTools/HostedMcpTools.csprojAdds standalone MCP dependencies.
responses/Hosted-McpTools/README.mdDocuments MCP source deployment.
responses/Hosted-McpTools/Dockerfile.contributorRemoves contributor container deployment.
responses/Hosted-McpTools/DockerfileRemoves image deployment.
responses/Hosted-McpTools/azure.yamlAdds MCP source deployment.
responses/Hosted-McpTools/agent.yamlRemoves obsolete agent definition.
responses/Hosted-McpTools/agent.manifest.yamlRemoves obsolete manifest.
responses/Hosted-McpTools/.env.exampleUpdates model configuration.
responses/Hosted-McpTools/.agentignoreDefines ZIP exclusions.
responses/Hosted-LocalTools/Program.csUpdates model selection and hosting.
responses/Hosted-LocalTools/HostedLocalTools.csprojMakes the ZIP project self-contained.
responses/Hosted-LocalTools/README.mdDocuments local-tools deployment.
responses/Hosted-LocalTools/Dockerfile.contributorRemoves contributor container deployment.
responses/Hosted-LocalTools/DockerfileRemoves image deployment.
responses/Hosted-LocalTools/azure.yamlAdds local-tools source deployment.
responses/Hosted-LocalTools/agent.yamlRemoves obsolete agent definition.
responses/Hosted-LocalTools/agent.manifest.yamlRemoves obsolete manifest.
responses/Hosted-LocalTools/.env.exampleUpdates model configuration.
responses/Hosted-LocalTools/.agentignoreDefines ZIP exclusions.
responses/Hosted-LocalCodeAct/Program.csUpdates CodeAct source-hosted configuration.
responses/Hosted-LocalCodeAct/HostedLocalCodeAct.csprojAdds standalone CodeAct dependencies.
responses/Hosted-LocalCodeAct/README.mdDocuments CodeAct source deployment.
responses/Hosted-LocalCodeAct/Dockerfile.contributorRemoves Python-enabled contributor image.
responses/Hosted-LocalCodeAct/DockerfileRemoves Python-enabled image deployment.
responses/Hosted-LocalCodeAct/azure.yamlAdds CodeAct source deployment.
responses/Hosted-LocalCodeAct/agent.yamlRemoves obsolete agent definition.
responses/Hosted-LocalCodeAct/agent.manifest.yamlRemoves obsolete manifest.
responses/Hosted-LocalCodeAct/.env.exampleUpdates local configuration.
responses/Hosted-LocalCodeAct/.agentignoreDefines ZIP exclusions.
responses/Hosted-FoundryAgent/Program.csUpdates managed-agent hosting credentials.
responses/Hosted-FoundryAgent/HostedFoundryAgent.csprojMakes the ZIP project self-contained.
responses/Hosted-FoundryAgent/README.mdDocuments managed-agent deployment.
responses/Hosted-FoundryAgent/Dockerfile.contributorRemoves contributor container deployment.
responses/Hosted-FoundryAgent/DockerfileRemoves image deployment.
responses/Hosted-FoundryAgent/azure.yamlAdds managed-agent source deployment.
responses/Hosted-FoundryAgent/agent.yamlRemoves obsolete agent definition.
responses/Hosted-FoundryAgent/agent.manifest.yamlRemoves obsolete manifest.
responses/Hosted-FoundryAgent/.env.exampleUpdates local authentication settings.
responses/Hosted-FoundryAgent/.agentignoreDefines ZIP exclusions.
responses/Hosted-Files/Program.csUpdates file roots and authentication.
responses/Hosted-Files/HostedFiles.csprojPackages bundled files for publishing.
responses/Hosted-Files/README.mdDocuments bundled/session-file deployment.
responses/Hosted-Files/Dockerfile.contributorRemoves contributor container deployment.
responses/Hosted-Files/DockerfileRemoves image deployment.
responses/Hosted-Files/azure.yamlAdds files-agent source deployment.
responses/Hosted-Files/agent.yamlRemoves obsolete agent definition.
responses/Hosted-Files/agent.manifest.yamlRemoves obsolete manifest.
responses/Hosted-Files/.env.exampleUpdates model configuration.
responses/Hosted-Files/.dockerignoreRemoves obsolete Docker exclusions.
responses/Hosted-Files/.agentignoreDefines ZIP exclusions.
responses/Hosted-AzureSearchRag/Program.csUpdates Search authentication and model settings.
responses/Hosted-AzureSearchRag/HostedAzureSearchRag.csprojAdds standalone Search dependencies.
responses/Hosted-AzureSearchRag/README.mdDocuments Search deployment requirements.
responses/Hosted-AzureSearchRag/Dockerfile.contributorRemoves contributor container deployment.
responses/Hosted-AzureSearchRag/DockerfileRemoves image deployment.
responses/Hosted-AzureSearchRag/azure.yamlAdds Search RAG source deployment.
responses/Hosted-AzureSearchRag/agent.yamlRemoves obsolete agent definition.
responses/Hosted-AzureSearchRag/agent.manifest.yamlRemoves obsolete manifest.
responses/Hosted-AzureSearchRag/.env.exampleUpdates Search configuration.
responses/Hosted-AzureSearchRag/.agentignoreDefines ZIP exclusions.
responses/Hosted-AgentSkills/Program.csUpdates skill provisioning authentication.
responses/Hosted-AgentSkills/HostedAgentSkills.csprojPackages bundled skill resources.
responses/Hosted-AgentSkills/README.mdDocuments skills deployment.
responses/Hosted-AgentSkills/Dockerfile.contributorRemoves contributor container deployment.
responses/Hosted-AgentSkills/DockerfileRemoves image deployment.
responses/Hosted-AgentSkills/azure.yamlAdds skills source deployment.
responses/Hosted-AgentSkills/agent.yamlRemoves obsolete agent definition.
responses/Hosted-AgentSkills/agent.manifest.yamlRemoves obsolete manifest.
responses/Hosted-AgentSkills/.env.exampleUpdates skill configuration.
responses/Hosted-AgentSkills/.agentignoreDefines ZIP exclusions.
invocations/Hosted-Invocations-EchoAgent/Program.csAdds the required readiness endpoint.
invocations/Hosted-Invocations-EchoAgent/Hosted-Invocations-EchoAgent.csprojMakes the ZIP project self-contained.
invocations/Hosted-Invocations-EchoAgent/README.mdDocuments Invocations source deployment.
invocations/Hosted-Invocations-EchoAgent/Dockerfile.contributorRemoves contributor container deployment.
invocations/Hosted-Invocations-EchoAgent/DockerfileRemoves image deployment.
invocations/Hosted-Invocations-EchoAgent/azure.yamlAdds Invocations source deployment.
invocations/Hosted-Invocations-EchoAgent/agent.yamlRemoves obsolete agent definition.
invocations/Hosted-Invocations-EchoAgent/agent.manifest.yamlRemoves obsolete manifest.
invocations/Hosted-Invocations-EchoAgent/.env.exampleUpdates local port configuration.
invocations/Hosted-Invocations-EchoAgent/.agentignoreDefines ZIP exclusions.
responses/Hosted-ChatClientAgent/README.mdDocuments explicit hosted-agent cleanup.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@github-actionsgithub-actionsBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAF Automated Review — Iteration 1

Result: Findings reported
Scope: full PR (7 commit(s)): 9b166f0e7221, d95fda3970f8, f7bba0da05bd, 9f9aa7e4e103, d54c8b28bd2c, 88de4cd33c1f, 986d6510fce3
Model:gpt-5.6-sol

Overview

The migration consistently adopts source deployment, self-contained project metadata, explicit readiness behavior, upload exclusions, and sample-specific resource packaging. The remaining risks are concentrated in copy/paste deployment workflows: the Workflow Handoff guide configures and invokes the scaffold in the wrong lifecycle order, the contributor helper cannot restore all newly documented package closures, and cleanup commands expose bearer tokens in process arguments.

Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
4 verified findings remained after source verification (4 medium) across 3 files. Details are attached to the affected lines below.

Affected areas:dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-FoundryAgent/README.md, dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-LocalCodeAct/README.md, dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Workflow-Handoff/README.md

Make sample configuration reject blank azd substitutions and document every required environment value inside the scaffolded project flow.
Separate the hosted endpoint name from the Foundry managed prompt-agent name, fix standalone MemoryAgent diagnostics, and complete the contributor local package feed for Hosting, LocalCodeAct, and MCP.
Use azd for agent invocation and az rest for authenticated administration without exposing tokens. Add native MCP approval handling to the toolbox consent client and make its local path target the standard responses endpoint.
Validated all changed samples locally, the contributor flow in PowerShell and Bash, and the supported live scenarios on the TAO cace project.
This was referenced Aug 24, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentationUsage: [Issues, PRs], Target: documentation in the code base and learn docs.NETUsage: [Issues, PRs], Target: .Net

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.NET: Migrate remaining Foundry hosted samples to source deployment

4 participants

@rogerbarreto@SergeyMenshykh@peibekwe