How to Use AI Agents for Beginners for Practical AI Applications: A Complete Guide
Use the Microsoft AI Agents for Beginners repository to build production-ready AI agents through hands-on lessons covering tool use, RAG, memory, planning, and multi-agent coordination.
The microsoft/ai-agents-for-beginners repository provides a structured, lesson-driven curriculum for building practical AI applications. This guide shows you how to move from installation to deployment using the Microsoft Agent Framework (MAF) and Azure AI Foundry Agent Service V2.
What You'll Build: Course Architecture
The repository organizes learning into stacked layers that progress from concepts to production deployment:
| Layer | Purpose | Key Locations |
|---|---|---|
| Course Core | 16 sequential lessons (00-15) introducing agent design patterns | 00-course-setup/, 01-intro-to-ai-agents/, 15-browser-use/ |
| Agent Framework | Decorators (@tool, @memory) and AzureAIProjectAgentProvider for model calls and state management |
04-tool-use/README.md |
| Azure AI Services | Managed LLM, vector search, and secure execution via Azure AI Foundry | 04-tool-use/README.md |
| Design Patterns | Implementations of Tool Use, RAG, Planning, Memory, Trustworthy Agents, Multi-Agent | Lesson READMEs in 05-agentic-rag/, 06-building-trustworthy-agents/, 08-multi-agent/ |
| Code Samples | Runnable Jupyter notebooks and Python scripts | code_samples/ folders across lessons |
| Deployment Helpers | Environment templates, CI workflows, and contribution guidelines | .env.example, .github/workflows/ |
Installation and Setup
Clone with Sparse Checkout (Skip Translations)
git clone --filter=blob:none --sparse https://github.com/microsoft/ai-agents-for-beginners.git
cd ai-agents-for-beginners
git sparse-checkout set --no-cone '/*' '!translations' '!translated_images'
Create Environment and Install Dependencies
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
The requirements.txt includes agent-framework, azure-ai-*, and azure-identity.
Configure Azure Credentials
Copy the template and fill in your values:
cp .env.example .env
Required variables in .env:
AZURE_AI_PROJECT_ENDPOINT=
AZURE_OPENAI_API_KEY=
PROJECT_CONNECTION_STRING=
Building Your First Practical AI Application
Step 1: Tool-Use Agent with @tool Decorator
The @tool decorator in agent_framework automatically generates JSON schemas from Python type hints.
import os
import json
import datetime
from zoneinfo import ZoneInfo
from agent_framework import tool
from agent_framework.azure import AzureAIProjectAgentProvider
from azure.identity import AzureCliCredential
@tool
def get_current_time(location: str) -> str:
"""Return the current local time for a supported city."""
TIMEZONE_DATA = {
"san francisco": "America/Los_Angeles",
"new york": "America/New_York",
"london": "Europe/London",
"tokyo": "Asia/Tokyo",
}
tz = TIMEZONE_DATA.get(location.lower())
if not tz:
return json.dumps({"location": location, "error": "unknown city"})
now = datetime.datetime.now(ZoneInfo(tz)).strftime("%I:%M %p")
return json.dumps({"location": location, "current_time": now})
# Create provider and agent
provider = AzureAIProjectAgentProvider(credential=AzureCliCredential())
agent = provider.create_agent(
name="TimeAgent",
instructions="Use available tools to answer user questions about time.",
tools=[get_current_time],
)
# Execute
response = agent.run("What time is it in Tokyo?")
print(response) # → "The current time in Tokyo is 02:15 PM."
Key implementation details from 04-tool-use/code_samples/04-python-agent-framework.ipynb:
AzureAIProjectAgentProviderhandles model calls, tool schema generation, and state management- The framework automatically detects tool calls, invokes Python implementations, and feeds results back to the LLM
Step 2: Retrieval-Augmented Generation (RAG) with Azure AI Search
Lesson 05-agentic-rag shows how to integrate vector search as a tool.
from agent_framework.azure import AzureAIProjectAgentProvider
from azure.identity import DefaultAzureCredential
from azure.ai.projects import AIProjectClient
import os
# Azure AI Search connection from .env
client = AIProjectClient.from_connection_string(
credential=DefaultAzureCredential(),
conn_str=os.getenv("PROJECT_CONNECTION_STRING"),
)
def search_documents(query: str) -> str:
"""Run vector search and return top-3 document chunks."""
results = client.search(query, top=3)
return "\n".join([r["content"] for r in results])
# Register as tool
provider = AzureAIProjectAgentProvider(credential=DefaultAzureCredential())
agent = provider.create_agent(
name="RAGAgent",
instructions="Answer user questions using the search_documents tool when needed.",
tools=[search_documents],
)
print(agent.run("Give me a summary of Azure AI Foundry pricing."))
This pattern from 05-agentic-rag/code_samples/05-python-agent-framework.ipynb demonstrates how external knowledge bases become first-class tools in your agent architecture.
Step 3: Multi-Agent Coordination from Lesson 08
For complex workflows, agents can delegate to specialized sub-agents:
from agent_framework.azure import AzureAIProjectAgentProvider
from azure.identity import AzureCliCredential
provider = AzureAIProjectAgentProvider(credential=AzureCliCredential())
def delegate_to_sales_agent(query: str) -> str:
"""Hand off sales-related queries to a specialist agent."""
sales_agent = provider.create_agent(
name="SalesAgent",
instructions="Answer questions about sales data only.",
tools=[], # Add sales-specific tools here
)
return sales_agent.run(query)
# Primary router agent
primary_agent = provider.create_agent(
name="RouterAgent",
instructions="Route user queries: if sales-related, call delegate_to_sales_agent; otherwise answer directly.",
tools=[delegate_to_sales_agent],
)
print(primary_agent.run("What were the Q2 sales numbers for product X?"))
This implementation from 08-multi-agent/ shows how to scale agent complexity through composition rather than monolithic growth.
Production Deployment Path
Add Persistence with @memory Decorator
Lesson 13 demonstrates session persistence:
from agent_framework import memory
@memory
def persist_context(user_id: str, context: dict) -> str:
"""Store and retrieve user-specific context across sessions."""
return f"Stored context for {user_id}"
Deploy to Azure AI Foundry Agent Service
Once your prototype runs locally, migrate to the managed service:
- Package your tools as Azure Functions or containerized endpoints
- Register your agent in Azure AI Foundry
- The service handles scaling, security, and thread-based state management automatically
Reference the Azure Agent Service section in 04-tool-use/README.md for migration steps.
Key Files Reference
| File | Purpose | Location |
|---|---|---|
README.md |
Course overview and getting started | Root |
04-tool-use/README.md |
Tool-use pattern and @tool decorator |
04-tool-use/ |
04-python-agent-framework.ipynb |
Runnable time-tool example | 04-tool-use/code_samples/ |
05-agentic-rag/README.md |
RAG implementation guide | 05-agentic-rag/ |
05-python-agent-framework.ipynb |
Azure AI Search integration | 05-agentic-rag/code_samples/ |
hotel_booking_workflow_sample.py |
End-to-end workflow with memory | 14-microsoft-agent-framework/code-samples/ |
.env.example |
Environment variable template | Root |
requirements.txt |
Python dependencies | Root |
AGENTS.md |
Quick reference of all lessons | Root |
Summary
- AI Agents for Beginners provides 16 progressive lessons covering tool use, RAG, memory, planning, trustworthy agents, and multi-agent coordination
- The Microsoft Agent Framework (
@tool,@memorydecorators) abstracts LLM calls, schema generation, and state management - Azure AI Foundry Agent Service V2 provides the managed infrastructure for production deployment
- Start with
04-tool-use/code_samples/04-python-agent-framework.ipynb, then progress through RAG (05-agentic-rag/) and multi-agent (08-multi-agent/) patterns
Frequently Asked Questions
What prerequisites do I need to use AI Agents for Beginners?
You need Python 3.10+, an Azure account with Azure AI Foundry access, and basic familiarity with async/await patterns. The course provides requirements.txt with all Python dependencies including agent-framework, azure-ai-projects, and azure-identity.
How does the @tool decorator work in the Microsoft Agent Framework?
The @tool decorator introspects your Python function's signature and docstring to automatically generate a JSON Schema compatible with OpenAI's function-calling API. When the LLM requests a tool call, the framework executes your Python function and feeds the result back to the model—no manual parsing required.
Can I deploy my agent without using Azure?
Local development works with the Microsoft Agent Framework using any OpenAI-compatible endpoint. However, production deployment with managed scaling, security, and thread-based persistence requires Azure AI Foundry Agent Service V2, which is the recommended path for enterprise applications.
What is the difference between single-agent and multi-agent patterns in the course?
Single-agent patterns (lessons 01-07) use one agent with multiple tools to handle tasks. Multi-agent patterns (lesson 08+) introduce a router agent that delegates to specialized sub-agents, enabling modular teams where each agent has focused instructions and tools—critical for complex business workflows.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →