Azure AI Foundry Agent Service simplifies building, deploying, and scaling autonomous AI agents for enterprise workflows. It handles orchestration, safety, and observability, enabling agents to automate tasks like data analysis or process coordination.
What is Azure AI Foundry Agent Service?
Azure AI Foundry Agent Service forms the core of Azure AI Foundry, a unified platform for intelligent agents. Agents combine large language models (LLMs) like GPT-4o with custom instructions and tools to reason, retrieve data, and act autonomously.
Each agent consists of three components: an LLM for reasoning, instructions defining goals and behavior, and tools for actions like code execution or API calls. Unlike chatbots, agents complete goals independently or collaborate with other agents and humans, supporting production-scale automation.
Key benefits include full thread visibility for debugging, built-in multi-agent coordination, server-side tool orchestration with retries, and enterprise-grade trust features like content filters and Microsoft Entra ID integration.
Prerequisites for Deployment
Start with an active Azure subscription. Assign the Azure AI Account Owner role at the subscription level for project creation, or Contributor/Cognitive Services Contributor roles as alternatives.
Team members creating agents need the Azure AI User role at the project scope, granting permissions for agents read/action/delete operations. Log in via az login to authenticate the SDK using DefaultAzureCredential.
Provision an Azure AI Foundry project, which auto-deploys GPT-4o and creates a default agent. Use your own Cosmos DB for business continuity, ensuring state preservation across regional outages.
Setting Up Your Environment
Access the Azure AI Foundry portal and click "Create an agent" for the fastest setup. Enter a project name, optionally customize advanced options, and select Create to provision resources, including the account, project, and GPT-4o deployment.
Locate your project endpoint in the portal under Overview > Libraries > Foundry, formatted as https://<AIFoundryResourceName>.services.ai.azure.com/api/projects/<ProjectName>. Note the model deployment name from Models + Endpoints, typically "gpt-4o".
Set environment variables: PROJECT_ENDPOINT for the endpoint and MODEL_DEPLOYMENT_NAME for the model. Install SDKs like Azure.AI.Agents.Persistent for .NET or azure-ai-projects for Python.
Creating Your First Agent
Agents gain intelligence from deployed models, behavior from instructions, and capabilities from tools like CodeInterpreterToolDefinition for data visualization or analysis.
.NET Example
Create a console app and install packages:
dotnet new console
dotnet add package Azure.AI.Agents.Persistent
dotnet add package Azure.Identity
Use this code to build an agent that handles math with code interpretation:
csharp
using Azure.AI.Agents.Persistent;
using Azure.Identity;
var projectEndpoint = Environment.GetEnvironmentVariable("ProjectEndpoint");
var modelDeploymentName = Environment.GetEnvironmentVariable("ModelDeploymentName");
PersistentAgentsClient client = new(projectEndpoint, new DefaultAzureCredential());
PersistentAgent agent = client.Administration.CreateAgent(
model: modelDeploymentName,
name: "MathAgent",
instructions: "You politely help with math questions. Use the code interpreter tool when asked to visualize numbers.",
tools: [new CodeInterpreterToolDefinition()]
);
PersistentAgentThread thread = client.Threads.CreateThread();
client.Messages.CreateMessage(thread.Id, MessageRole.User, "Draw a graph for a line with slope 4 and y-intercept 9.");
ThreadRun run = client.Runs.CreateRun(thread.Id, agent.Id, additionalInstructions: "Address user as Jane Doe.");
// Poll for completion
do { Thread.Sleep(500); run = client.Runs.GetRun(thread.Id, run.Id); }
while (run.Status == RunStatus.Queued || run.Status == RunStatus.InProgress || run.Status == RunStatus.RequiresAction);
foreach (var msg in client.Messages.GetMessages(thread.Id, order: ListSortOrder.Ascending))
{
foreach (var content in msg.ContentItems)
{
if (content is MessageTextContent text) Console.WriteLine($"[{msg.Role}]: {text.Text}");
// Handle images from code interpreter
}
}

Join the conversation! Your thoughts help the community grow.