{"id":3652,"date":"2026-03-23T09:54:40","date_gmt":"2026-03-23T16:54:40","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/azure-sdk\/?p=3652"},"modified":"2026-04-29T15:48:43","modified_gmt":"2026-04-29T22:48:43","slug":"azd-ai-agent-end-to-end","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/azure-sdk\/azd-ai-agent-end-to-end\/","title":{"rendered":"From code to cloud: Deploy an AI agent to Microsoft Foundry in minutes with azd"},"content":{"rendered":"<p><div class=\"alert alert-info\"><p class=\"alert-divider\"><i class=\"fabric-icon fabric-icon--Info\"><\/i><strong>IMPORTANT<\/strong><\/p>Updated <strong>4\/29\/2026<\/strong> to sync with <a href=\"https:\/\/devblogs.microsoft.com\/foundry\/from-local-to-production-the-complete-developer-journey-for-building-composing-and-deploying-ai-agents\/\">v1.0 release of Microsoft Agent Framework<\/a>.<\/div><\/p>\n<p>You built an AI agent. It works locally. Now what?<\/p>\n<p>Getting an agent from your laptop to a production endpoint on Microsoft Foundry usually means stitching together resource provisioning, model deployments, identity configuration, and connection wiring\u2014and that doesn&#8217;t even cover monitoring or debugging.<\/p>\n<p><strong>What if you could go from a repo to a live agent you can invoke in two commands?<\/strong><\/p>\n<p>That workflow is exactly what <code>azd ai agent<\/code> provides. This post walks through the full end-to-end workflow: deploying an AI agent to Microsoft Foundry, invoking it remotely, running it locally for development, and monitoring it in real time\u2014all from Visual Studio (VS) Code.<\/p>\n<h2>Prerequisites<\/h2>\n<p>Before you get started, make sure you have:<\/p>\n<ul>\n<li><a href=\"https:\/\/code.visualstudio.com\/\">VS Code<\/a> installed<\/li>\n<li><a href=\"https:\/\/learn.microsoft.com\/azure\/developer\/azure-developer-cli\/install-azd\">Azure Developer CLI (<code>azd<\/code>)<\/a> installed<\/li>\n<li><a href=\"https:\/\/git-scm.com\/\">Git<\/a> installed<\/li>\n<li>An Azure subscription with access to <a href=\"https:\/\/ai.azure.com\/\">Microsoft Foundry<\/a>. Confirm that your subscription has quota for the model you plan to deploy (for example, GPT-4o) in your target region.<\/li>\n<\/ul>\n<h2>Step 1: Clone a sample agent project<\/h2>\n<p>This walkthrough uses a sample Python-based hotel concierge agent. Clone the repo and open it in VS Code:<\/p>\n<pre><code class=\"language-bash\">git clone https:\/\/github.com\/puicchan\/seattle-hotel-agent\r\ncd seattle-hotel-agent\r\ncode .<\/code><\/pre>\n<h2>Step 2: Authenticate and deploy<\/h2>\n<p>Open the integrated terminal in VS Code. To sign in to Azure, run:<\/p>\n<pre><code class=\"language-bash\">azd auth login<\/code><\/pre>\n<p>Then initialize:<\/p>\n<pre><code class=\"language-bash\">azd ai agent init<\/code><\/pre>\n<p>When prompted:<\/p>\n<ul>\n<li>select &#8220;Use the code in the current directory&#8221;<\/li>\n<li>for protocols, keep the default: <strong>responses<\/strong><\/li>\n<li>select &#8220;Deploy a new model from the catalog&#8221;\n<blockquote><p><div class=\"alert alert-danger\"><p class=\"alert-divider\"><i class=\"fabric-icon fabric-icon--ErrorBadge\"><\/i><strong>CAUTION<\/strong><\/p>Make sure to deploy to a supported region (<a href=\"https:\/\/learn.microsoft.com\/azure\/foundry\/agents\/concepts\/hosted-agents?branch=release-hosted-agents-vnext#region-availability\">Region Availability<\/a>).<\/div><\/p><\/blockquote>\n<\/li>\n<\/ul>\n<p>And deploy:<\/p>\n<pre><code class=\"language-bash\">azd up<\/code><\/pre>\n<p>Two commands\u2014<code>azd ai agent init<\/code> and <code>azd up<\/code>\u2014scaffold the infrastructure and deploy your agent. After deployment completes, <code>azd<\/code> prints a direct link to your agent in the Microsoft Foundry portal.<\/p>\n<h3>Under the hood<\/h3>\n<p><strong><code>azd ai agent init<\/code><\/strong> generates a full infrastructure-as-code (IaC) definition in your repo:<\/p>\n<ul>\n<li><code>infra\/main.bicep<\/code>\u2014entry point that wires together all resources<\/li>\n<li>A <strong>Foundry Resource<\/strong> (the top-level container for your AI resources)<\/li>\n<li>A <strong>Foundry Project<\/strong> under the hub (where your agent lives)<\/li>\n<li><strong>Model deployment<\/strong> configuration (for example, GPT-4o)<\/li>\n<li><strong>Managed identity<\/strong> with role-based access control role assignments so your agent can securely access the model and any connected data sources<\/li>\n<li><code>azure.yaml<\/code>\u2014the <code>azd<\/code> service map that ties your agent code to the Foundry host<\/li>\n<li><code>agent.yaml<\/code>\u2014agent definition file with metadata about the agent and environment variables<\/li>\n<\/ul>\n<p><strong><code>azd up<\/code><\/strong> provisions all of these resources on Azure, then publishes your agent to Foundry. Behind the scenes, the command runs Bicep deployment, uploads your agent definition, and registers the agent endpoint. The Foundry link in the output points directly to the agent&#8217;s playground.<\/p>\n<p>You own all of these artifacts. The generated Bicep is in your repo\u2014inspect it, customize it, version-control it.<\/p>\n<h2>Step 3: Try it in the Foundry playground<\/h2>\n<p>To open your agent&#8217;s playground in the browser, click the Foundry link from the <code>azd up<\/code> output. You now have a live agent endpoint. Ask it a question\u2014for example, <em>&#8220;What suites are available at the downtown Seattle hotel?&#8221;<\/em>\u2014and see it respond in real time.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-content\/uploads\/sites\/58\/2026\/04\/03-27-azd-ai-agent-end-to-end-foundry-playground.webp\" alt=\"Agent playground in Microsoft Foundry\" \/><\/p>\n<p>Your agent is deployed and serving traffic. You can interact with it directly from the terminal too.<\/p>\n<h2>Step 4: Invoke your agent from the terminal<\/h2>\n<p>Back in VS Code, run:<\/p>\n<pre><code class=\"language-bash\">azd ai agent invoke<\/code><\/pre>\n<p>This command sends a prompt to your <strong>remote<\/strong> agent endpoint directly from the terminal. It preserves conversation context across turns, so you can have a multi-turn conversation.<\/p>\n<blockquote><p><strong>Tip:<\/strong> By default, <code>azd ai agent invoke<\/code> targets the remote endpoint. When a local agent is running (see Step 5), it automatically routes to the local instance instead.<\/p><\/blockquote>\n<h2>Step 5: Run locally for development<\/h2>\n<p>When you iterate on your agent&#8217;s logic and want a faster feedback loop, run it locally:<\/p>\n<pre><code class=\"language-bash\">azd ai agent run<\/code><\/pre>\n<p>This command starts the agent on your local machine. To test prompts against the local instance, pair the command with <code>azd ai agent invoke<\/code>. Edit your agent code, restart, and invoke again\u2014no redeployment needed.<\/p>\n<h2>Step 6: Monitor in real time<\/h2>\n<p>One of the most powerful debugging features: real-time log streaming.<\/p>\n<pre><code class=\"language-bash\">azd ai agent monitor<\/code><\/pre>\n<p>By default, this command prints the ~50 most recent log entries and exits. To stream logs continuously as requests come in, add <code>--follow<\/code>. If you have a frontend app or any client consuming your agent endpoint, you can watch every request and response flow through in real time\u2014invaluable for troubleshooting issues in production.<\/p>\n<h2>Step 7: Check agent health<\/h2>\n<p>Want a quick status check?<\/p>\n<pre><code class=\"language-bash\">azd ai agent show<\/code><\/pre>\n<p>This command tells you whether your published agent is healthy and running, along with key metadata about the deployment.<\/p>\n<h2>Step 8: Clean up resources<\/h2>\n<p>To delete all Azure resources created during this walkthrough, run:<\/p>\n<pre><code class=\"language-bash\">azd down<\/code><\/pre>\n<p>This command removes the resource group and all provisioned resources so you avoid ongoing charges.<\/p>\n<h2>Bonus: Wire up a frontend chat app<\/h2>\n<p>Want to see your agent in action through a real UI? A separate, lightweight chat app is available to clone and point at your published agent. The chat app consumes the agent you deployed in the earlier steps, so make sure the agent is running first.<\/p>\n<pre><code class=\"language-bash\">git clone https:\/\/github.com\/puicchan\/chat-app-foundry\r\ncd chat-app-foundry<\/code><\/pre>\n<p>Set the environment variables that wire the app to your published agent. You can find these values in the <code>azd up<\/code> output from your agent deployment, or by running <code>azd env get-values<\/code> in the <code>seattle-hotel-agent<\/code> project directory:<\/p>\n<pre><code class=\"language-bash\">azd env set AZURE_AI_AGENT_NAME \"seattle-hotel-agent\"\r\nazd env set AZURE_AI_AGENT_VERSION \"&lt;version-number&gt;\"\r\nazd env set AI_ACCOUNT_NAME \"&lt;your-ai-account-name&gt;\"\r\nazd env set AI_ACCOUNT_RESOURCE_GROUP \"&lt;your-resource-group&gt;\"\r\nazd env set AZURE_AI_PROJECT_ENDPOINT \"&lt;your-foundry-endpoint&gt;\"\r\nazd env set AZURE_TENANT_ID \"&lt;your-azure-tenant-id&gt;\"<\/code><\/pre>\n<p>Then provision and deploy the chat app:<\/p>\n<pre><code class=\"language-bash\">azd up<\/code><\/pre>\n<p>Once the app is running, open a second terminal and start streaming logs:<\/p>\n<pre><code class=\"language-bash\">azd ai agent monitor --follow<\/code><\/pre>\n<p>Now ask a question in the chat UI and watch the log light up in real time. This setup is the best way to see the full loop: a user question in the browser, the request hitting your published agent on Foundry, and the log streaming back to your terminal\u2014all visible at once.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-content\/uploads\/sites\/58\/2026\/04\/03-27-azd-ai-agent-end-to-end-monitor.webp\" alt=\"Chat app UI with agent monitor running side-by-side\" \/><\/p>\n<h2>The full command set at a glance<\/h2>\n<table>\n<thead>\n<tr>\n<th>Command<\/th>\n<th>What it does<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>azd ai agent init<\/code><\/td>\n<td>Scaffold a Foundry agent project with IaC<\/td>\n<\/tr>\n<tr>\n<td><code>azd up<\/code><\/td>\n<td>Provision Azure resources and deploy the agent<\/td>\n<\/tr>\n<tr>\n<td><code>azd ai agent invoke<\/code><\/td>\n<td>Send prompts to the remote or locally run agent<\/td>\n<\/tr>\n<tr>\n<td><code>azd ai agent run<\/code><\/td>\n<td>Run the agent locally for development<\/td>\n<\/tr>\n<tr>\n<td><code>azd ai agent monitor<\/code><\/td>\n<td>Stream real-time logs from the published agent<\/td>\n<\/tr>\n<tr>\n<td><code>azd ai agent show<\/code><\/td>\n<td>Check the health and status of the published agent<\/td>\n<\/tr>\n<tr>\n<td><code>azd down<\/code><\/td>\n<td>Delete all provisioned Azure resources<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>What comes next<\/h2>\n<p>This workflow is the inner loop for AI agent development: build, deploy, test, monitor\u2014all from the terminal. The same <code>azd<\/code> workflow plugs into your CI\/CD pipeline. To deploy on every push to <code>main<\/code>, add <code>azd up<\/code> to a GitHub Actions workflow. To manage dev, staging, and production environments with the same commands, use <code>azd env<\/code>.<\/p>\n<p>The <code>azd ai agent<\/code> commands are powered by an <code>azd<\/code> extension built by the Foundry team\u2014an example of how partner teams can extend <code>azd<\/code> to support new hosts and workflows. The <code>azd ai agent<\/code> command set is actively evolving, with capabilities like local dev-test and live agent monitoring. The goal: the full agent lifecycle\u2014from scaffolding to evaluation to production monitoring\u2014lives in your terminal.<\/p>\n<h2>Get started<\/h2>\n<p>With a few commands you can scaffold, deploy, invoke, monitor, and tear down a Foundry agent\u2014all from your terminal. To try it, <a href=\"https:\/\/learn.microsoft.com\/azure\/developer\/azure-developer-cli\/install-azd\">install <code>azd<\/code><\/a> and run <code>azd ai agent init<\/code> in any agent project. The command automatically installs the azd ai agent extension, so there&#8217;s nothing extra to set up.<\/p>\n<p>We&#8217;d love to hear how the experience works for you. File bugs or feature requests in the <a href=\"https:\/\/github.com\/Azure\/azure-dev\/issues\"><code>azure-dev<\/code> repo on GitHub<\/a>, and tag them with <code>ai-agent<\/code> so the team can triage quickly.<\/p>\n<p><strong>Resources:<\/strong><\/p>\n<ul>\n<li><a href=\"https:\/\/learn.microsoft.com\/azure\/developer\/azure-developer-cli\/\">Azure Developer CLI documentation<\/a>\u2014full docs, install guides, and reference<\/li>\n<li><a href=\"https:\/\/github.com\/puicchan\/seattle-hotel-agent\">Sample agent repo<\/a>\u2014the hotel concierge agent used in this post<\/li>\n<li><a href=\"https:\/\/github.com\/puicchan\/chat-app-foundry\">Sample chat app repo<\/a>\u2014lightweight frontend for your published agent<\/li>\n<li><a href=\"https:\/\/ai.azure.com\/\">Microsoft Foundry<\/a>\u2014manage your agents in the portal<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Deploy and monitor an AI agent on Microsoft Foundry using the Azure Developer CLI (azd). This tutorial covers infrastructure scaffolding with Bicep, one-command deployment, local development, and real-time log streaming\u2014all from Visual Studio Code.<\/p>\n","protected":false},"author":111321,"featured_media":3653,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[908,864],"class_list":["post-3652","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure-sdk","tag-azd","tag-azure-developer-cli"],"acf":[],"blog_post_summary":"<p>Deploy and monitor an AI agent on Microsoft Foundry using the Azure Developer CLI (azd). This tutorial covers infrastructure scaffolding with Bicep, one-command deployment, local development, and real-time log streaming\u2014all from Visual Studio Code.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/posts\/3652","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/users\/111321"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/comments?post=3652"}],"version-history":[{"count":2,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/posts\/3652\/revisions"}],"predecessor-version":[{"id":3790,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/posts\/3652\/revisions\/3790"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/media\/3653"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/media?parent=3652"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/categories?post=3652"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/tags?post=3652"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}