- Scaffold a hosted agent project
- Test the agent locally
- Deploy to Foundry Agent Service
- Chat with the agent in the playground
- Clean up resources Choose your preferred development experience to get started, VS Code or CLI.
This document is for Hosted Agents on the new backend and requires azd ai agent version 0.1.27-preview or later.
For the legacy experience that uses Azure Container Apps, continue using 0.1.25-preview.Hosted agents are currently in preview.
Prerequisites
Before you begin, you need:- An Azure subscription—Create one for free.
- The Foundry Project Manager role at project scope (or another role that grants both data-plane and role-assignment permissions). For the full role matrix, see Hosted agent permissions reference.
- Python 3.13 or later.
- Git.
- (Optional) GitHub Copilot for Azure plugin Recommended for coding agents and includes agent skills for creating, testing, and deploying hosted agents.
Required permissions
You need the Foundry Project Manager role at project scope to create and deploy hosted agents. The Azure Developer CLI and the Visual Studio Code extension handle the remaining role assignments (project managed identity, agent identity, and Azure Container Registry (ACR) pull) automatically when you also have Owner or User Access Administrator on the subscription. If you don’t have those subscription-level roles, ask an administrator to assign the roles described in Hosted agent permissions reference.The Foundry RBAC roles were recently renamed. Foundry User, Foundry Owner, Foundry Account Owner, and Foundry Project Manager were previously named Azure AI User, Azure AI Owner, Azure AI Account Owner, and Azure AI Project Manager. You might still see the previous names in some places while the rename rolls out. The role IDs and core permissions are unchanged by the rename.
Verify and test your agent
Test in the Foundry playground
The Foundry portal includes a shared playground you can use to test the agent.- Open the Foundry portal and sign in.
- Select your project from Recent projects or All projects.
- In the left navigation, select Build > Agents.
- Select your agent, then select Open in playground.
- Enter a prompt such as
Write a haiku about deploying cloud applications.and press Enter. If the playground doesn’t load or the agent doesn’t respond, verify the agent status isStartedon the agent detail page.
Clean up resources
Delete the resources when you’re finished so you stop incurring charges.Troubleshooting
| Issue | Solution |
|---|---|
SubscriptionNotRegistered | Register the provider: az provider register --namespace Microsoft.CognitiveServices. |
AuthorizationFailed during provisioning | Request the Contributor role on the subscription or resource group. |
AuthenticationError or DefaultAzureCredential failure | To refresh credentials, run azd auth logout and then azd auth login. |
ResourceNotFound or DeploymentNotFound | Verify the endpoint URL and model deployment name in the Foundry portal under Build > Deployments. |
AcrPullUnauthorized | Grant the AcrPull role to the project’s managed identity on the Container Registry. |
Connection refused on local run | Ensure no other process is using port 8088. |
azd ai agent init fails | Run azd version to verify 1.25.0 or later. Update with winget upgrade Microsoft.Azd (Windows) or brew upgrade azd (macOS). Run azd ext list and upgrade the agent extension with azd ext upgrade azure.ai.agents to get 0.1.34-preview or later. |
| Microsoft Foundry Toolkit extension not found | Install the Microsoft Foundry Toolkit for Visual Studio Code from the Marketplace and switch to the prerelease channel. |
Local run fails on Windows ARM64 with build errors for aiohttp, grpcio, cryptography, or httptools | Prebuilt arm64 wheels aren’t published for these packages, and source builds require Microsoft C++ Build Tools. As a workaround, skip Step 3 and validate the agent remotely with azd deploy followed by azd ai agent invoke. |
What you learned
In this quickstart, you:- Scaffolded a hosted agent project from the Basic agent sample.
- Tested the agent locally.
- Deployed the agent to Foundry Agent Service.
- Sent test prompts from both the CLI (or VS Code) and the Foundry playground.
Next steps
Manage hosted agent lifecycle
- Optimize your hosted agent to automatically improve its instructions
- Add web search to ground responses in real-time public web results.
- Connect MCP tools to extend agent functionality
- Use function calling to integrate custom logic
- Add file search to search your documents
- Enable code interpreter to run Python code
- See the tool catalog for the full list.