Developing powerful AI agents with the Microsoft Agent Framework (MAF) is straightforward locally. However, moving them to production requires handling deployment, scaling, security, observability, versioning, and session management. Microsoft’s Foundry Hosted Agents in the Foundry Agent Service simplifies this transition, providing a managed, production-grade environment for your agents.
What Are Foundry Hosted Agents?
Foundry Hosted Agents are containerized applications that run within the Foundry Agent Service. They deliver agent-optimized compute with enterprise features, including:
- Secure per session sandboxes with filesystem persistence.
- Integrated identity (dedicated Entra ID per agent).
- Scale-to-zero economics — pay only for active usage.
- Predictable cold starts for near-instant session spin-up.
- Automatic isolation — each session gets its own VM-isolated sandbox.
- BYO VNet support for controlling outbound traffic.
- Built-in versioning and stable endpoints for easy integration and rollouts.
- Multiple protocol support (Responses and Invocations).
Your code remains unchanged: package it as a container image and let Foundry manage the infrastructure.
Key benefits include resuming sessions with the full filesystem intact (even after scale-down), persistent state for up to 30 days, and seamless restoration after idle periods (typically 15 minutes).
Core Capabilities and Advantages
When deploying a MAF agent to Foundry Hosted Agents (often via azd):
- It optionally provisions a Foundry project and models.
- It builds and pushes your container image to Azure Container Registry (ACR).
- It assigns a dedicated Entra ID and exposes a stable endpoint (e.g., https://{project_endpoint}/agents/{agent_name}).
- It manages scaling, state persistence, observability, and lifecycle automatically.
Microsoft Agent Framework + Foundry Hosted Agents unlocks powerful features:
- Bring your code as-is — Local agents run identically in production.
- First-class identity — Agents securely access Foundry models, Toolbox, and other Azure services without storing secrets.
- Versioning & safe rollouts — Immutable versions support canary/blue-green deployments and instant rollbacks.
- Built-in observability — OpenTelemetry traces flow automatically into Application Insights.
- Stateful sessions — Files and state persist across restarts.
- Foundry Toolbox integration — Easily use pre-provisioned tools.
Choose Your Protocol: Responses or Invocations
Hosted agents support two main protocols:
- Responses Protocol — OpenAI-compatible /responses endpoint. The platform manages conversation history, streaming, and background tasks. Recommended for most chat-style agents.
- Invocations Protocol — Flexible generic endpoint for custom request/response schemas and non-conversational workflows.
You can support both protocols in the same container.
Minimal Code Changes to Host Your Microsoft Agent Framework Agent
Transitioning from a local MAF agent to a hosted one requires just a few lines.
In .NET:
C#
using Microsoft.Agents.AI.Foundry.Hosting;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddFoundryResponses(agent);
var app = builder.Build();
app.MapFoundryResponses();
app.Run();
In Python:
Python
server = ResponsesHostServer(agent)
server.run()
Detailed samples with local and hosted instructions are available:
Wrapping Up
The Microsoft Agent Framework lets developers focus on intelligent agent logic, while Foundry Hosted Agents provide the production runtime with identity, scaling, sessions, versioning, and observability built in. This combination dramatically reduces the gap between prototype and production-ready agents.
The integration is currently in preview, with General Availability coming soon. If you have a local Microsoft Agent Framework agent, now is a great time to try deploying it to Foundry Hosted Agents.
Practical Takeaways: Deployment Checklist
- Validate your local agent’s functionality and dependencies
- Choose Foundry Hosted Agents to simplify cloud deployment
- Leverage built-in identity management to meet security policies
- Plan for automatic scaling to handle variable workloads
- Utilize session state management to maintain user context
- Monitor agent performance with Foundry observability tools
- Implement versioning workflows for safe production updates
How We Help
As a Microsoft Dynamics 365 Solutions Partner specializing in automation and integration, we guide enterprises through deploying Microsoft Agent Framework agents using Foundry Hosted Agents. Our consulting services include architecture design, security compliance, and ongoing operational support to ensure your agents run smoothly in production.
Ready to deploy your Microsoft Agent Framework solution confidently and efficiently? Contact us to explore how Foundry Hosted Agents can transform your automation strategy.
Contact AX AI Labs today for a consultation and lets put AI to work!

Arwin is a Partner & Customer Success Manager (CSM) at AXSource, a leading Microsoft Dynamics 365 partner. With 7+ years supporting Dynamics 365 Finance & Operations implementations, Arwin helps organisations drive measurable value—bridging process design with user adoption, training, and ongoing optimisation. He has guided clients across manufacturing, automotive, pharmaceuticals, hospitality, and more, aligning ERP capabilities to business goals and ensuring long-term success. He is very passionate about driving business success and ensuring businesses are empowered using new Microsoft tools.
