AZD-for-beginners / chapter-02-ai-development
AGENTS.md190 starsChanged 5 months agoMITView on GitHub
Chapter Navigation: - π Course Home: AZD For Beginners - π Current Chapter: Chapter 2 - AI-First Development - β¬ οΈ Previous: Microsoft Foundry Integration - β‘οΈ Next: AI Model Deployment - π Advanced: Multi-Agent Solutions AI agents na autonomous programs we fit sense their environment, make decisions, an take actions to achieve specific goals. Unlike simple chatbots wey dey only respond to prompts, agents fit: Dis guide go show you how to deploy AI agents to Azure using Azure Developerβ¦
- Installs packages
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository55 other files it gives its agents.
- docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/ar/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/bg/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/bn/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/cs/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/da/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/de/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/el/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/en/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/es/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/et/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/fa/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/fi/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/fr/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/he/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/hi/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/hr/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/hu/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/id/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/it/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/ja/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/km/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/kn/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/ko/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/lt/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/ml/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/mr/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/ms/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/my/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/ne/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/nl/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/no/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/pa/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/pl/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/pt-BR/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/pt-PT/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/ro/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/ru/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/sk/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/sl/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/sr/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/sv/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/sw/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/ta/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/te/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/th/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/tl/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/tr/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/uk/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/ur/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/vi/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/zh-CN/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/zh-HK/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/zh-MO/docs/chapter-02-ai-development/agents.mdAGENTS.md
- translations/zh-TW/docs/chapter-02-ai-development/agents.mdAGENTS.md
The file
We split this agents.md into the rules it gives an agent
8 rules. About 0 are common, 6 are distinctive, and 2 are very specific to this project.
β0
Common Β· estimate
Many files like this have a rule of this kind.
β6
Distinctive Β· estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 16
Use tools: - Call APIs, search databases, execute code
- Distinctive: line 27
When you finish dis guide, you go:
- Distinctive: line 36
When you finish am, you go fit:
- Very specific: line 124
If you get agent manifest file, you fit use azd ai command to scaffold Foundry Agent Service project directly.
- Very specific: line 152
After azd up, the same extension go carry you through rest of the agent lifecycle: azd ai agent invoke to test, azd ai agent eval generate β¦
- Distinctive: line 192
Document Q&A systems
- Distinctive: line 272
All AZD agent templates get Application Insights inside for monitoring:
- Distinctive: line 503
Create new tool function for your agent code:
β βCommonβ is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. βVery specificβ is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AI Agents wit Azure Developer CLI
Chapter Navigation:
- π Course Home: AZD For Beginners
- π Current Chapter: Chapter 2 - AI-First Development
- β¬ οΈ Previous: Microsoft Foundry Integration
- β‘οΈ Next: AI Model Deployment
- π Advanced: Multi-Agent Solutions
Introduction
AI agents na autonomous programs we fit sense their environment, make decisions, an take actions to achieve specific goals. Unlike simple chatbots wey dey only respond to prompts, agents fit:
- Use tools - Call APIs, search databases, execute code
- Plan and reason - Break complex tasks into steps
- Learn from context - Maintain memory and adapt behavior
- Collaborate - Work wit oda agents (multi-agent systems)
Dis guide go show you how to deploy AI agents to Azure using Azure Developer CLI (azd).
Validation note (2026-07-13): Dis guide don check for
azd1.27.1anazure.ai.agents1.0.0-beta.5. Theazd aiexperience still be preview, so check extension help if your installed flags different.
Learning Goals
When you finish dis guide, you go:
- Understand wetin AI agents be and how dem differ from chatbots
- Deploy pre-built AI agent templates using AZD
- Configure Foundry Agents for custom agents
- Implement basic agent patterns (tool use, RAG, multi-agent)
- Monitor and debug deployed agents
Learning Outcomes
When you finish am, you go fit:
- Deploy AI agent applications to Azure with one command
- Configure agent tools and capabilities
- Implement retrieval-augmented generation (RAG) wit agents
- Design multi-agent architectures for complex workflows
- Troubleshoot common agent deployment issues
π€ Wetin Make Agent Different From Chatbot?
| Feature | Chatbot | AI Agent |
| Behavior | Responds to prompts | Takes autonomous actions |
| Tools | None | Fit call APIs, search, execute code |
| Memory | Session-based only | Persistent memory across sessions |
| Planning | Single response | Multi-step reasoning |
| Collaboration | Single entity | Fit work wit oda agents |
Simple Analogy
- Chatbot = Person wey dey help answer questions for information desk
- AI Agent = Personal assistant wey fit make calls, book appointments, and complete tasks for you
π Quick Start: Deploy Your First Agent
Option 1: Foundry Agents Template (Recommended)
# Set up di AI agents template
azd init --template get-started-with-ai-agents
# Put am for Azure
azd upWetin go deploy:
- β Foundry Agents
- β Microsoft Foundry Models (gpt-4.1)
- β Azure AI Search (for RAG)
- β Azure Container Apps (web interface)
- β Application Insights (monitoring)
Time: ~15-20 minutes Cost: ~$100-150/month (development)
Option 2: OpenAI Agent with Prompty
# Start di Prompty-based agent template
azd init --template agent-openai-python-prompty
# Put am for Azure
azd upWetin go deploy:
- β Azure Functions (serverless agent execution)
- β Microsoft Foundry Models
- β Prompty configuration files
- β Sample agent implementation
Time: ~10-15 minutes Cost: ~$50-100/month (development)
Option 3: RAG Chat Agent
# Start RAG chat template
azd init --template azure-search-openai-demo
# Put am for Azure
azd upWetin go deploy:
- β Microsoft Foundry Models
- β Azure AI Search wit sample data
- β Document processing pipeline
- β Chat interface wit citations
Time: ~15-25 minutes Cost: ~$80-150/month (development)
Option 4: AZD AI Agent Init (Manifest- or Template-Based Preview)
If you get agent manifest file, you fit use azd ai command to scaffold Foundry Agent Service project directly. Recent preview releases add template-based initialization support, so exact prompt flow fit small different based on your installed extension version.
# Make you install di AI agents extension
azd extension install azure.ai.agents
# Optional: make you confirm di preview version wey you don install
azd extension show azure.ai.agents
# Start from an agent manifest
azd ai agent init -m agent-manifest.yaml
# Deploy am for Azure
azd up
# Test di agent wey you don deploy (e go show latency + time-to-first-byte)
azd ai agent invokeWhen to use azd ai agent init vs azd init --template:
| Approach | Best For | How E Dey Work |
azd init --template | Starting from working sample app | Clones full template repo wit code + infra |
azd ai agent init -m | Building from your own agent manifest | Scaffolds project structure from your agent definition |
Tip: Use
azd init --templatewhen you dey learn (Options 1-3 above). Useazd ai agent initwhen you dey build production agents with your own manifests.
After azd up, the same extension go carry you through rest of the agent lifecycle: azd ai agent invoke to test, azd ai agent eval generate and azd ai agent optimize to measure and improve quality, and azd ai agent delete to clean up. See AZD AI CLI Commands for full reference.
ποΈ Agent Architecture Patterns
Pattern 1: Single Agent wit Tools
Di simplest agent pattern - one agent wey fit use multiple tools.
graph TD
UI[User Interface] --> Agent[AI Agent<br/>gpt-4.1]
Agent --> Search[Search Tool]
Agent --> Database[Database Tool]
Agent --> API[API Tool]Best for:
- Customer support bots
- Research assistants
- Data analysis agents
AZD Template: azure-search-openai-demo
Pattern 2: RAG Agent (Retrieval-Augmented Generation)
Agent wey go find relevant documents before e go generate responses.
graph TD
Query[User Query] --> RAG[RAG Agent]
RAG --> Vector[Vector Search]
RAG --> LLM[LLM<br/>gpt-4.1]
Vector -- Documents --> LLM
LLM --> Response[Response wit Citations]Best for:
- Enterprise knowledge bases
- Document Q&A systems
- Compliance and legal research
AZD Template: azure-search-openai-demo
Pattern 3: Multi-Agent System
Multiple specialized agents dey work together on complex tasks.
graph TD
Orchestrator[Orchestrator Agent] --> Research[Research Agent<br/>gpt-4.1]
Orchestrator --> Writer[Writer Agent<br/>gpt-4.1-mini]
Orchestrator --> Reviewer[Reviewer Agent<br/>gpt-4.1]Best for:
- Complex content generation
- Multi-step workflows
- Tasks wey need different expertise
Learn More: Multi-Agent Coordination Patterns
βοΈ Configuring Agent Tools
Agents dey powerful when dem fit use tools. Na so we go configure common tools:
Tool Configuration in Foundry Agents
# agent_config.py
from azure.ai.projects import AIProjectClient
from azure.ai.projects.models import FunctionTool, CodeInterpreterTool
# Define custom tools
search_tool = FunctionTool(
name="search_knowledge_base",
description="Search the company knowledge base for relevant documents",
parameters={
"type": "object",
"properties": {
"query": {
"type": "string",
"description": "The search query"
}
},
"required": ["query"]
}
)
# Create agent wit tools
agent = project_client.agents.create_agent(
model="gpt-4.1",
name="Support Agent",
instructions="You are a helpful support agent. Use the search tool to find relevant information.",
tools=[search_tool, CodeInterpreterTool()]
)Environment Configuration
# Arrange environment variables wey dey for agent only
azd env set AZURE_OPENAI_MODEL "gpt-4.1"
azd env set AGENT_INSTRUCTIONS "You are a helpful assistant..."
azd env set ENABLE_CODE_INTERPRETER "true"
azd env set ENABLE_FILE_SEARCH "true"
# Carry deploy wit updated configuration
azd deployπ Monitoring Agents
Application Insights Integration
All AZD agent templates get Application Insights inside for monitoring:
# Open moni-tor moni-dashboard
azd monitor --overview
# See live logs
azd monitor --logs
# See live metrics
azd monitor --liveKey Metrics to Track
| Metric | Description | Target |
| Response Latency | Time wey e take to generate response | < 5 seconds |
| Token Usage | Tokens per request | Monitor for cost |
| Tool Call Success Rate | % of successful tool executions | > 95% |
| Error Rate | Failed agent requests | < 1% |
| User Satisfaction | Feedback scores | > 4.0/5.0 |
Custom Logging for Agents
import os
from azure.monitor.opentelemetry import configure_azure_monitor
from opentelemetry import trace
# Set up Azure Monitor wit OpenTelemetry
configure_azure_monitor(
connection_string=os.environ["APPLICATIONINSIGHTS_CONNECTION_STRING"]
)
tracer = trace.get_tracer(__name__)
def log_agent_interaction(user_query, agent_response, tools_used, latency_ms):
with tracer.start_as_current_span("agent_interaction") as span:
span.set_attributes({
"user_query": user_query,
"response_length": len(agent_response),
"tools_used": tools_used,
"latency_ms": latency_ms
})Note: Install na di packages wey dem require:
pip install azure-monitor-opentelemetry opentelemetry
π° Cost Considerations
Estimated Monthly Costs by Pattern
| Pattern | Dev Environment | Production |
| Single Agent | $50-100 | $200-500 |
| RAG Agent | $80-150 | $300-800 |
| Multi-Agent (2-3 agents) | $150-300 | $500-1,500 |
| Enterprise Multi-Agent | $300-500 | $1,500-5,000+ |
Cost Optimization Tips
- Use gpt-4.1-mini for simple tasks
azd env set AZURE_OPENAI_MODEL "gpt-4.1-mini" - Implement caching for repeated queries
from functools import lru_cache @lru_cache(maxsize=1000) def get_cached_response(query_hash): return agent.run(query_hash) - Set token limits per run
# Set max_completion_tokens wen you dey run the agent, no be when you dey create am run = project_client.agents.create_run( thread_id=thread.id, agent_id=agent.id, max_completion_tokens=1000 # Make response length no too long ) - Scale to zero when not in use
# Container Apps go automatically scale reach zero azd env set MIN_REPLICAS "0"
π§ Troubleshooting Agents
Common Issues and Solutions
<details>
<summary><strong>β Agent no dey respond to tool calls</strong></summary># Make sure say di tools don register well well
azd show
# Confirm OpenAI deployment
az cognitiveservices account deployment list \
--name $AZURE_OPENAI_NAME \
--resource-group $RG_NAME
# Check di agent logs
azd monitor --logsCommon causes:
- Tool function signature no match
- Missing required permissions
- API endpoint no dey accessible
</details><details>
<summary><strong>β High latency in agent responses</strong></summary># Check Application Insights for bottlenecks
azd monitor --live
# Consider using a faster model
azd env set AZURE_OPENAI_MODEL "gpt-4.1-mini"
azd deployOptimization tips:
- Use streaming responses
- Implement response caching
- Reduce context window size
</details><details>
<summary><strong>β Agent dey return wrong or hallucinated info</strong></summary># Make am beta wit beta system prompts
instructions = """
You are a helpful assistant. IMPORTANT:
- Only answer based on provided context
- If you don't know, say "I don't know"
- Always cite your sources
- Never make up information
"""
# Add retrieval for grounding
agent = project_client.agents.create_agent(
model="gpt-4.1",
instructions=instructions,
tools=[FileSearchTool()] # Ground responses for documents
)</details><details>
<summary><strong>β Token limit exceeded errors</strong></summary># Make sure say you dey manage context window well well
def truncate_context(messages, max_tokens=8000, model="gpt-4.1"):
"""Keep only recent messages within token limit."""
import tiktoken
encoding = tiktoken.encoding_for_model(model)
total_tokens = 0
truncated = []
for msg in reversed(messages):
msg_tokens = len(encoding.encode(msg.content))
if total_tokens + msg_tokens > max_tokens:
break
truncated.insert(0, msg)
total_tokens += msg_tokens
return truncated</details>π Hands-On Exercises
Exercise 1: Deploy Basic Agent (20 minutes)
Goal: Deploy your first AI agent using AZD
# Step 1: Make template ready
azd init --template get-started-with-ai-agents
# Step 2: Login to Azure
azd auth login
# If you dey work across tenants, add --tenant-id <tenant-id>
# Step 3: Deploy am
azd up
# Step 4: Try test the agent
# Wetin you suppose see after deployment be say:
# Deployment don finish!
# Endpoint: https://<app-name>.<region>.azurecontainerapps.io
# Open di URL wey show for output and try ask question
# Step 5: Check di monitoring
azd monitor --overview
# Step 6: Clear everything up
azd down --force --purgeSuccess Criteria:
- Agent respond to questions
- Fit access monitoring dashboard via
azd monitor - Resources clean up well
Exercise 2: Add Custom Tool (30 minutes)
Goal: Extend agent wit custom tool
- Deploy agent template:
azd init --template get-started-with-ai-agents azd up - Create new tool function for your agent code:
def get_weather(location: str) -> str: """Get current weather for a location.""" # API call go di weather service return f"Weather in {location}: Sunny, 72Β°F" - Register the tool wit the agent:
from azure.ai.projects.models import FunctionTool weather_tool = FunctionTool( name="get_weather", description="Get current weather for a location", parameters={ "type": "object", "properties": { "location": {"type": "string", "description": "City name"} }, "required": ["location"] } ) agent = project_client.agents.create_agent( model="gpt-4.1", name="Weather Agent", tools=[weather_tool] ) - Redeploy an test:
azd deploy # Ask: "How di weather be for Seattle?" # Expected: Agent go call get_weather("Seattle") and return weather info
Success Criteria:
- Agent sabi weather-related queries
- Tool dey call well
- Response get weather info
Exercise 3: Build RAG Agent (45 minutes)
Goal: Build agent wey answer questions from your documents
# Step 1: Make RAG template ready
azd init --template azure-search-openai-demo
azd up
# Step 2: Upload your documents
# Put PDF/TXT files for data/ folder, den run:
python scripts/prepdocs.py
# Step 3: Try am wit questions wey concern di domain
# Open di web app URL wey come from azd up output
# Ask any question wey concern your uploaded documents
# Di answers suppose get citation like [doc.pdf] inside amSuccess Criteria:
- Agent dey answer from uploaded documents
- Responses get citations
- No hallucination for out-of-scope questions
π Next Steps
Now wey you don understand AI agents, try these advanced topics:
| Topic | Description | Link |
| Multi-Agent Systems | Build systems wit multiple collaborating agents | Retail Multi-Agent Example |
| Coordination Patterns | Learn orchestration and communication patterns | Coordination Patterns |
| Production Deployment | Enterprise-ready agent deployment | Production AI Practices |
| Agent Evaluation | Test an evaluate agent performance | AI Troubleshooting |
| AI Workshop Lab | Hands-on: Make your AI solution AZD-ready | AI Workshop Lab |
π Additional Resources
Official Documentation
- Microsoft Foundry Agent Service
- Microsoft Foundry Agent Service Quickstart
- Semantic Kernel Agent Framework
AZD Templates for Agents
Community Resources
Agent Skills for Your Editor
- Microsoft Azure Agent Skills - Install reusable AI agent skills for Azure development in GitHub Copilot, Cursor, or any supported agent. Includes skills for Azure AI, Microsoft Foundry, deployment, and diagnostics:
npx skills add microsoft/github-copilot-for-azure
Navigation
- Previous Lesson: Microsoft Foundry Integration
- Next Lesson: AI Model Deployment
<!-- CO-OP TRANSLATOR DISCLAIMER START -->Disclaimer: Dis document don translate wit AI translation service Co-op Translator. Even tho we dey try make am correct, abeg make you know say automated translation fit get errors or mistakes. Di original document for dia own language na im be di correct source. For important info, make person wey sabi human translation do am. We no go responsible for any misunderstanding or wrong understanding wey fit happen because of dis translation.
<!-- CO-OP TRANSLATOR DISCLAIMER END -->Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

