<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/from-dotnet-run-to-foundry-hosted-agent-in-3-lines-of-c--hzr3e26yx" -->

---
title: From dotnet run to Foundry Hosted Agent in 3 lines of C#
description: Microsoft Foundry Hosted Agents let developers deploy an existing Microsoft Agent Framework console app to Azure with just one NuGet package...
canonical: https://daily.dev/posts/from-dotnet-run-to-foundry-hosted-agent-in-3-lines-of-c--hzr3e26yx
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: From dotnet run to Foundry Hosted Agent in 3 lines of C# | daily.dev
og:description: Microsoft Foundry Hosted Agents let developers deploy an existing Microsoft Agent Framework console app to Azure with just one NuGet package...
og:url: https://daily.dev/posts/from-dotnet-run-to-foundry-hosted-agent-in-3-lines-of-c--hzr3e26yx
og:image: https://api.daily.dev/og/posts/Hzr3E26yx.png
og:image:alt: From dotnet run to Foundry Hosted Agent in 3 lines of C#
og:image:width: 1200
og:image:height: 630
og:locale: en
---

[.NET Blog](https://daily.dev/sources/dotnet)

[Read post](https://api.daily.dev/r/Hzr3E26yx)

# [From dotnet run to Foundry Hosted Agent in 3 lines of C#](https://api.daily.dev/r/Hzr3E26yx "Go to post")

Microsoft Foundry Hosted Agents let developers deploy an existing Microsoft Agent Framework console app to Azure with just one NuGet package (Microsoft.Agents.AI.Foundry.Hosting), three lines of C# code, and two azd commands (azd provision, azd deploy). The managed hosting layer handles compute scaling, session state, a dedicated Microsoft Entra identity, an OpenAI-compatible /responses endpoint, telemetry via Application Insights, agent evaluators, and immutable versioning for rollbacks. The post walks through testing locally with azd ai agent run/invoke, then shipping to production, plus a VS Code extension (Microsoft Foundry Toolkit) that automates scaffolding, debugging, and deployment. Hosted Agents is now generally available.

[#ai-agents](/tags/ai-agents "Check all #ai-agents posts")[#azure](/tags/azure "Check all #azure posts")[#.net](/tags/.net "Check all #.net posts")[#c#](/tags/c%23 "Check all #c# posts")

Aug 24•9m read time•From [devblogs.microsoft.com](https://api.daily.dev/r/Hzr3E26yx "devblogs.microsoft.com")

[![Post cover image](https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/710114eca4223d59989528be6eef9643?_a=AQAEuop)](https://api.daily.dev/r/Hzr3E26yx "Go to post")

Table of contents

[What you will build Copy link](https://api.daily.dev/r/Hzr3E26yx?a=what-you-will-build "What you will build Copy link")[The starting point: a minimal MAF agent Copy link](https://api.daily.dev/r/Hzr3E26yx?a=the-starting-point:-a-minimal-maf-agent "The starting point: a minimal MAF agent Copy link")[So… how do I deploy this? Enter Foundry Hosted Agents Copy link](https://api.daily.dev/r/Hzr3E26yx?a=so…-how-do-i-deploy-this-enter-foundry-hosted-agents "So… how do I deploy this? Enter Foundry Hosted Agents Copy link")[The diff: 1 package + 3 lines Copy link](https://api.daily.dev/r/Hzr3E26yx?a=the-diff:-1-package-+-3-lines "The diff: 1 package + 3 lines Copy link")[Run it locally first Copy link](https://api.daily.dev/r/Hzr3E26yx?a=run-it-locally-first "Run it locally first Copy link")[Deploy: two commands Copy link](https://api.daily.dev/r/Hzr3E26yx?a=deploy:-two-commands "Deploy: two commands Copy link")[Your agent, living its best life in the Foundry portal Copy link](https://api.daily.dev/r/Hzr3E26yx?a=your-agent-living-its-best-life-in-the-foundry-portal "Your agent, living its best life in the Foundry portal Copy link")[Bonus: the VS Code experience Copy link](https://api.daily.dev/r/Hzr3E26yx?a=bonus:-the-vs-code-experience-🎁 "Bonus: the VS Code experience Copy link")[Wrap-up Copy link](https://api.daily.dev/r/Hzr3E26yx?a=wrap-up "Wrap-up Copy link")[Want to see all of this built live? Copy link](https://api.daily.dev/r/Hzr3E26yx?a=want-to-see-all-of-this-built-live-🦾 "Want to see all of this built live? Copy link")[Learn more Copy link](https://api.daily.dev/r/Hzr3E26yx?a=learn-more "Learn more Copy link")

Questions this post answers

How do I deploy a Microsoft Agent Framework console agent to Azure as a hosted agent?

Add the Microsoft.Agents.AI.Foundry.Hosting NuGet package, then add three lines of C# code: AgentHost.CreateBuilder(args) to create the host, builder.Services.AddFoundryResponses(agent) to register the agent, and builder.RegisterProtocol("responses", endpoints => endpoints.MapFoundryResponses()) to expose the /responses endpoint. Then run azd provision followed by azd deploy to ship it to Microsoft Foundry Agent Service. daily.dev surfaces practical walkthroughs like this for teams moving agent prototypes into production.

What does Microsoft Foundry Hosted Agents manage automatically for a deployed agent?

Foundry Hosted Agents provision compute per session and scale to zero when idle, persist session state including $HOME and uploaded files across turns, create a dedicated Microsoft Entra ID identity per agent for secure access, and expose an OpenAI-compatible /responses endpoint usable from any compatible SDK. They also inject OpenTelemetry tracing and Application Insights automatically, with no manual configuration required. developers evaluating managed agent hosting can track these platform capabilities on daily.dev.

How do I test a Foundry Hosted Agent locally before deploying it?

Install the azd AI agent extension with azd ext install azure.ai.agents, scaffold the project with azd ai agent init, set the FOUNDRY\_PROJECT\_ENDPOINT and AZURE\_AI\_MODEL\_DEPLOYMENT\_NAME environment variables, then run azd ai agent run to start the host on localhost:8088\. Invoke it locally with azd ai agent invoke --local or a curl POST to the /responses endpoint. anyone wiring up local agent testing loops can keep tabs on tooling updates like this via daily.dev.

1.7K Impressions2 Upvotes

Comment

Bookmark

Copy

![Placeholder image for anonymous user](https://media.daily.dev/image/upload/s--qsFuKGv_--/t_logo,f_auto/public/noProfile)Share your thoughtsPost

[![.NET Blog's image](https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/f23eb59371bd4f07aeef64c4eef73266)](https://daily.dev/sources/dotnet)

[.NET Blog](https://daily.dev/sources/dotnet "https://daily.dev/sources/dotnet")

dotnet offers insights into .NET development, C# programming language, and cross-platform applicatio... Read more

1.2K Followers

•

2.3K Upvotes

#### Would you recommend this post?

Copy link

WhatsApp

Facebook

X

New Squad

Copy linkShare with your friends

2

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"From dotnet run to Foundry Hosted Agent in 3 lines of C#","url":"https://daily.dev/posts/from-dotnet-run-to-foundry-hosted-agent-in-3-lines-of-c--hzr3e26yx","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/from-dotnet-run-to-foundry-hosted-agent-in-3-lines-of-c--hzr3e26yx"},"datePublished":"2026-08-24T19:00:56.343Z","dateModified":"2026-08-24T19:01:24.590Z","description":"Microsoft Foundry Hosted Agents let developers deploy an existing Microsoft Agent Framework console app to Azure with just one NuGet package...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/710114eca4223d59989528be6eef9643?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/710114eca4223d59989528be6eef9643?_a=AQAEuop","isAccessibleForFree":true,"articleSection":".NET Blog","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":".NET Blog","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/f23eb59371bd4f07aeef64c4eef73266","url":"https://daily.dev/sources/dotnet"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/from-dotnet-run-to-foundry-hosted-agent-in-3-lines-of-c--hzr3e26yx","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"ai-agents,azure,.net,c#","timeRequired":"PT9M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":".NET Blog","item":"https://daily.dev/sources/dotnet"},{"@type":"ListItem","position":3,"name":"From dotnet run to Foundry Hosted Agent in 3 lines of C#"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/from-dotnet-run-to-foundry-hosted-agent-in-3-lines-of-c--hzr3e26yx#faq","mainEntity":[{"@type":"Question","name":"How do I deploy a Microsoft Agent Framework console agent to Azure as a hosted agent?","acceptedAnswer":{"@type":"Answer","text":"Add the Microsoft.Agents.AI.Foundry.Hosting NuGet package, then add three lines of C# code: AgentHost.CreateBuilder(args) to create the host, builder.Services.AddFoundryResponses(agent) to register the agent, and builder.RegisterProtocol(\"responses\", endpoints => endpoints.MapFoundryResponses()) to expose the /responses endpoint. Then run azd provision followed by azd deploy to ship it to Microsoft Foundry Agent Service. daily.dev surfaces practical walkthroughs like this for teams moving agent prototypes into production."}},{"@type":"Question","name":"What does Microsoft Foundry Hosted Agents manage automatically for a deployed agent?","acceptedAnswer":{"@type":"Answer","text":"Foundry Hosted Agents provision compute per session and scale to zero when idle, persist session state including $HOME and uploaded files across turns, create a dedicated Microsoft Entra ID identity per agent for secure access, and expose an OpenAI-compatible /responses endpoint usable from any compatible SDK. They also inject OpenTelemetry tracing and Application Insights automatically, with no manual configuration required. developers evaluating managed agent hosting can track these platform capabilities on daily.dev."}},{"@type":"Question","name":"How do I test a Foundry Hosted Agent locally before deploying it?","acceptedAnswer":{"@type":"Answer","text":"Install the azd AI agent extension with azd ext install azure.ai.agents, scaffold the project with azd ai agent init, set the FOUNDRY_PROJECT_ENDPOINT and AZURE_AI_MODEL_DEPLOYMENT_NAME environment variables, then run azd ai agent run to start the host on localhost:8088. Invoke it locally with azd ai agent invoke --local or a curl POST to the /responses endpoint. anyone wiring up local agent testing loops can keep tabs on tooling updates like this via daily.dev."}}]}
```

