{"id":5388,"date":"2026-05-06T12:30:33","date_gmt":"2026-05-06T19:30:33","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/agent-framework\/?p=5388"},"modified":"2026-05-07T11:51:11","modified_gmt":"2026-05-07T18:51:11","slug":"from-local-to-production-deploy-your-microsoft-agent-framework-agent-with-foundry-hosted-agents","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/agent-framework\/from-local-to-production-deploy-your-microsoft-agent-framework-agent-with-foundry-hosted-agents\/","title":{"rendered":"From Local to Production: Deploy Your Microsoft Agent Framework Agent with Foundry Hosted Agents"},"content":{"rendered":"<p>Once you have your Microsoft Agent Framework (MAF) agent or workflow happily running locally on your dev machine, it&#8217;s time to decide how to deploy your agent to production, monitor it, evaluate it and version it. These decisions are just as important as getting the agent running. <a href=\"https:\/\/devblogs.microsoft.com\/foundry\/introducing-the-new-hosted-agents-in-foundry-agent-service-secure-scalable-compute-built-for-agents\/\"><strong>Hosted Agents in Foundry Agent Service<\/strong><\/a> is the easiest way to deploy Agent Framework agent to the cloud &#8211; with built-in identity, automatic scaling, managed session state, observability, and versioning.<\/p>\n<h3>What are Foundry Hosted Agents?<\/h3>\n<p>Foundry Hosted Agents are containerized applications that run inside <a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/foundry\/agents\/overview\">Foundry Agent Service<\/a>. Foundry Hosted Agents brings agent-optimized compute and services designed for production-grade enterprise agents, giving agents secure per-session sandboxes with filesystem persistence, integrated identity, and scale-to-zero economics. They are your own code, packaged as a container image and deployed to Foundry-manage infrastructure.<\/p>\n<p><strong>Core Capabilities:<\/strong><\/p>\n<ul>\n<li><strong>Predictable cold starts<\/strong>\u00a0\u2014 spin up agent sessions and harnesses in your custom environment virtually instantly<\/li>\n<li><strong>Scale to zero<\/strong>\u00a0\u2014 pay nothing while your agent is idle, with an agent that will scale down on its own during inactivity<\/li>\n<li><strong>Resume with filesystem intact<\/strong>\u00a0\u2014 files, disk state, and session identity persist across scale-to-zero events. Your agent restarts with its full working directory exactly where it left off<\/li>\n<li><strong>Per-session isolation is automatic<\/strong> \u2014 Every single agent session gets its own VM-isolated sandbox with persistent session state. Use isolation keys to easily manage and namespace your end users\u2019 sessions<\/li>\n<li><strong>BYO VNet Support \u2013<\/strong>\u00a0drive your agents\u2019 outbound traffic via your VNet<\/li>\n<li><strong>Production-ready agent endpoints \u2013\u00a0<\/strong>built-in agent versioning with stable endpoints for easy integration, weighted rollouts across versions<\/li>\n<li><strong>Multiple protocols out of the box \u2013<\/strong>\u00a0OpenResponses protocol support with automatic mapping to\/from Activity Protocol for one-click publish to Microsoft 365. Flexible Invocations protocol for custom application integrations, AG-UI support<\/li>\n<\/ul>\n<p>When you deploy your MAF agent to Foundry Hosted Agents using <code>azd<\/code> it:<\/p>\n<ul>\n<li>(Optional) Creates all necessary resources, including a Foundry project and deploys a model.<\/li>\n<li>Packages your code, builds an image, and pushes it to Azure Container Registry (ACR).<\/li>\n<li>Pulls the image from ACR and provisions compute.<\/li>\n<li>Assigns a dedicated Entra ID to the agent.<\/li>\n<li>Expose a dedicated endpoint at, for example <code>https:\/\/{project_endpoint}\/agents\/{agent_name}<\/code>.<\/li>\n<li>Handles scaling, session state persistence, observability, and lifecycle management.<\/li>\n<\/ul>\n<p>If unused, sessions persist for up to 30 days; idle compute is deprovisioned after 15 minutes and seamlessly restored on the next request.\u00a0Read more about sessions in the <a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/foundry\/agents\/concepts\/hosted-agents#sessions-and-conversations\">here<\/a>.<\/p>\n<h3>Choose your protocol: Responses or Invocations<\/h3>\n<p>Hosted agents speak one or both of two protocols:<\/p>\n<ul>\n<li><strong>Responses<\/strong>: An OpenAI-compatible <code>\/responses<\/code> endpoint. The platform manages conversation history, streaming events, and background execution.<\/li>\n<li><strong>Invocations<\/strong>: A generic <code>invocations<\/code> endpoint where you define the request\/response schema, giving you flexibility for any non-conversational workflow that doesn&#8217;t fit a chat-shaped contract.<\/li>\n<\/ul>\n<p>We recommend starting with `\/responses` if you are not sure which one to use. Read more about supported protocols in the <a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/foundry\/agents\/concepts\/hosted-agents#protocols-responses-and-invocations\">here<\/a>.<\/p>\n<h3>Foundry Hosted Agents + Microsoft Agent Framework<\/h3>\n<p>Microsoft Agent Framework gives you a clean programming model for building agents &#8211; chat clients, tools, MCP integrations, context providers, middleware, and multi-step workflows, with the same concepts and APIs across .Net and Python. Foundry Hosted Agents give that code a production-grade home. Using MAF and Foundry Hosted Agents together enables a bunch of exciting capabilities<\/p>\n<ul>\n<li><strong>Bring your code as-is<\/strong>: The same agents and workflows you run locally are the ones running in the sandbox.<\/li>\n<li><strong>First class identity<\/strong>: Each agent gets its own Entra ID, allowing your agent to call <a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/foundry\/concepts\/foundry-models-overview\">Foundry models<\/a>, <a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/foundry\/agents\/concepts\/tool-catalog#toolbox-preview\">Foundry toolbox<\/a>, and any other Azure services, without the need to store secrets in the image. \u00a0Read more about Agent Identity in the <a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/foundry\/agents\/concepts\/hosted-agents#agent-identity-and-endpoint\">here<\/a>.<\/li>\n<li><strong>Version and safe rollout<\/strong>: Every deployment is an immutable version snapshot of your agent. Split traffic between versions for canary or blue\/green rollout, and roll back instantly.<\/li>\n<li><strong>Built-in observability<\/strong>: `APPLICATIONINSIGHTS_CONNECTION_STRING` is injected at runtime, so MAF&#8217;s OpenTelemetry traces flow into Application Insights with zero extra wiring.<\/li>\n<li><strong>Stateful sessions<\/strong>: persist files and state to sessions and the platform restores them when a session resumes, even after idle scale-down.<\/li>\n<li><strong>Foundry Toolbox<\/strong>: Connect to a Foundry Toolbox provisioned in the same Foundry project to use a wide variety of existing tools.<\/li>\n<\/ul>\n<p><iframe src=\"\/\/www.youtube.com\/embed\/iR7_57lJOz8\" width=\"560\" height=\"314\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<h3>From local agent to hosted agent<\/h3>\n<p>To turn an agent into an agent host, it only takes a few lines of code.<\/p>\n<p>In .Net:<\/p>\n<pre class=\"prettyprint language-cs language-csharp\"><code class=\"language-cs language-csharp\">using Microsoft.Agents.AI.Foundry.Hosting;\r\n\r\nvar builder = WebApplication.CreateBuilder(args);\r\nbuilder.Services.AddFoundryResponses(agent);\r\n\r\nvar app = builder.Build();\r\napp.MapFoundryResponses();\r\n\r\napp.Run();<\/code><\/pre>\n<p>In Python:<\/p>\n<pre class=\"prettyprint language-py\"><code class=\"language-py\">server = ResponsesHostServer(agent)\r\nserver.run()<\/code><\/pre>\n<p>Get started today by exploring our samples:<\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/microsoft\/agent-framework\/tree\/main\/dotnet\/samples\/04-hosting\/FoundryHostedAgents\">.Net samples<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/microsoft\/agent-framework\/tree\/main\/python\/samples\/04-hosting\/foundry-hosted-agents\">Python samples<\/a><\/li>\n<\/ul>\n<p>Each sample contains detailed instructions to run the agent locally and as a Foundry Hosted Agent.<\/p>\n<h3>Wrapping up<\/h3>\n<p>Microsoft Agent Framework lets you focus on agent logic. Foundry Hosted Agents give that logic a managed home with identity, scaling, sessions, versioning, and observability handled for you. Together, they shorten the distance between a prototype agent and a production agent. If you already have a local agent built using Microsoft Agent Framework, now it is the time to try hosting it in Foundry and experience the production benefits firsthand!<\/p>\n<p>Our teams are working hard to bring Foundry Hosted Agent and MAF integration to General Availability soon. Stay tuned for more!<\/p>\n<p>Further reading:<\/p>\n<ul>\n<li><a href=\"https:\/\/devblogs.microsoft.com\/foundry\/introducing-the-new-hosted-agents-in-foundry-agent-service-secure-scalable-compute-built-for-agents\/\">Hosted Agent Announcement<\/a><\/li>\n<li><a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/foundry\/agents\/concepts\/hosted-agents\">Foundry Hosted Agent Docs<\/a><\/li>\n<li><a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/foundry\/concepts\/foundry-models-overview\">Foundry Models Docs<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/microsoft-foundry\/foundry-samples\/tree\/main\/samples\/csharp\/hosted-agents\">Foundry Hosted Agent .Net Samples<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/microsoft-foundry\/foundry-samples\/tree\/main\/samples\/python\/hosted-agents\">Foundry Hosted Agent Python Samples<\/a><\/li>\n<li><a href=\"ttps:\/\/learn.microsoft.com\/en-us\/agent-framework\/hosting\/foundry-hosted-agent\">MAF Hosted Agent Integration Doc<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/microsoft\/agent-framework\/tree\/main\/dotnet\/samples\">MAF .Net Samples<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/microsoft\/agent-framework\/tree\/main\/python\/samples\">MAF Python Samples<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><em>The Microsoft Agent Framework team is dedicated to empowering developers by providing access to the latest advancements in the industry. We encourage you to leverage your creativity and build remarkable solutions with MAF! Please reach out if you have any questions or feedback through our <a href=\"https:\/\/github.com\/microsoft\/agent-framework\/discussions\" target=\"_blank\" rel=\"noopener\">Agent Framework GitHub Discussion Channel<\/a>. We look forward to hearing from you! We would also love your support, if you\u2019ve enjoyed using Agent Framework, give us a star on <a href=\"https:\/\/github.com\/microsoft\/agent-framework\" target=\"_blank\" rel=\"noopener\">GitHub<\/a>.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Once you have your Microsoft Agent Framework (MAF) agent or workflow happily running locally on your dev machine, it&#8217;s time to decide how to deploy your agent to production, monitor it, evaluate it and version it. These decisions are just as important as getting the agent running. Hosted Agents in Foundry Agent Service is the [&hellip;]<\/p>\n","protected":false},"author":165150,"featured_media":5425,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[143,47],"tags":[],"class_list":["post-5388","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-agent-framework","category-announcement"],"acf":[],"blog_post_summary":"<p>Once you have your Microsoft Agent Framework (MAF) agent or workflow happily running locally on your dev machine, it&#8217;s time to decide how to deploy your agent to production, monitor it, evaluate it and version it. These decisions are just as important as getting the agent running. Hosted Agents in Foundry Agent Service is the [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts\/5388","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/users\/165150"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/comments?post=5388"}],"version-history":[{"count":2,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts\/5388\/revisions"}],"predecessor-version":[{"id":5430,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts\/5388\/revisions\/5430"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/media\/5425"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/media?parent=5388"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/categories?post=5388"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/tags?post=5388"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}