A hands-on walkthrough demonstrates hosting an AI agent built with Microsoft Agent Framework as a Foundry hosted agent in .NET, contrasting it with self-hosting (Azure Functions) and prompt agents. The agent code, tools, and dependencies run entirely inside a Foundry-managed container with its own Microsoft Entra identity, endpoint, versioning, and playground. Steps cover writing the agent, running it locally on port 8088, deploying with the Azure Developer CLI and Foundry extension, invoking the deployed agent, calling it from code via ProjectResponsesClient, and cleanly deleting it via REST with force=true to cascade session cleanup. Notes a versioning mismatch gotcha between the azure.yaml manifest (2.0.0) and docs examples (1.0.0) that must align with the Microsoft.Agents.AI.Foundry.Hosting package.
Questions this post answers
What is the difference between a Foundry prompt agent and a Foundry hosted agent in Microsoft Agent Framework?
With prompt agents, Foundry only stores the agent definition while your own application code runs the tools. With hosted agents, Foundry runs the entire agent, code and tools included, packaging it as a container with its own managed endpoint, Microsoft Entra identity, versioning, scaling, and a working playground since the tools execute inside Foundry itself. daily.dev surfaces comparisons like this for developers deciding between hosting models for their AI agents.
Why does my Foundry hosted agent deployment fail even though I'm using the latest Microsoft.Agents.AI.Foundry.Hosting package?
The azure.yaml manifest's protocols version field and the hosting package version must agree, but SDK and REST docs examples still show version 1.0.0 while newer hosting packages (like 1.22.0-preview) require version 2.0.0 under protocols. Copying the version straight from documentation examples while referencing a newer hosting package causes a mismatch and deployment failure. developers deploying Foundry agents can check daily.dev to avoid version mismatch pitfalls before shipping.
How do I delete a Foundry hosted agent that still has active sessions without getting a 409 error?
Send a DELETE request to the agent's endpoint with force=true in the query string, which cascades the deletion to the agent, all its versions, and any active sessions. Without force=true, attempting to delete an agent with open sessions returns a 409 conflict response. Note that azd down is not appropriate here since it only removes azd-provisioned environments, not agents deployed into an existing project. engineers cleaning up cloud AI agent deployments can find practical fixes like this on daily.dev.