Skip to main content

Build your first agent

This guide will help you create and run your first AI agent using Microsoft Agent Framework. You’ll have a working agent in just a few minutes.

Prerequisites

Before you begin, make sure you have:
1

Python 3.10+ or .NET 10.0+

2

Azure CLI installed and logged in

Install from Azure CLI docs and run:
3

Azure AI Foundry project

Create a project at ai.azure.com with an OpenAI deployment (e.g., gpt-4o)

Set up your environment

1

Install the package

The --pre flag is required during the preview period.
2

Set environment variables

Create your first agent

Create a simple agent that can answer questions:

Run your agent

You should see a response like:

Add streaming support

Get real-time responses as the agent generates them:

Add tools to your agent

Give your agent capabilities by adding function tools:
In production, use approval_mode="always_require" (Python) to get user confirmation before executing tools.

Multi-turn conversations

Maintain conversation context across multiple interactions:

Next steps

Now that you have a working agent, explore more capabilities:

Installation Guide

Detailed setup instructions and configuration options

Core Concepts

Learn about agents, tools, sessions, and workflows

Add Memory

Give your agent long-term memory with context providers

Build Workflows

Chain multiple agents and executors together
Production consideration: DefaultAzureCredential (in .NET) is convenient for development but may cause latency in production. Consider using ManagedIdentityCredential or a specific credential type for production deployments.