This guide walks you through setting up everything you need to run the examples in this repository. Follow the sections relevant to your preferred language (Python, .NET, or both).
agent-sdk-learning).East US 2, Sweden Central).💡 Tip: Choose a region that supports the model you plan to deploy (e.g.,
gpt-4o). Check model availability by region.
You need a deployed language model for your agents to use. We recommend gpt-4o for the best balance of capability and cost.
gpt-4o-mini for lower cost).gpt-4o (keep it simple — this becomes your MODEL_DEPLOYMENT_NAME).⚠️ Important: Note the exact deployment name — you’ll use it in your environment configuration.
https://your-project-name.services.ai.azure.com
PROJECT_ENDPOINT.📌 The project endpoint is different from individual model endpoints. The Agent SDK uses the project-level endpoint to manage agents, threads, and runs.
Your Azure identity needs the correct role to use the Agent Service.
# Get your current user's Object ID
az ad signed-in-user show --query id -o tsv
# Assign the "Azure AI User" role on your AI Foundry project
az role assignment create \
--role "Azure AI User" \
--assignee "<your-object-id>" \
--scope "/subscriptions/<sub-id>/resourceGroups/<rg-name>/providers/Microsoft.MachineLearningServices/workspaces/<project-name>"
Alternatively, assign the role in the Azure Portal:
💡 If you created the project, you likely already have Owner or Contributor — but the Azure AI User role is specifically needed for Agent Service operations.
Download and install Python 3.10 or later from python.org.
Verify your installation:
python --version # Should show 3.10 or later
pip --version # Should show pip is installed
cd "Azure AI Agent SDK/python"
# Create the virtual environment
python -m venv .venv
# Activate it
# Windows (PowerShell):
.venv\Scripts\Activate.ps1
# Windows (Command Prompt):
.venv\Scripts\activate.bat
# macOS / Linux:
# source .venv/bin/activate
pip install -r requirements.txt
This installs:
| Package | Purpose |
|———|———|
| azure-ai-projects | Azure AI Agent Service SDK (agents, threads, runs, tools) |
| azure-identity | Microsoft Entra ID authentication (DefaultAzureCredential) |
| azure-ai-inference | Model inference client (for direct model calls if needed) |
| azure-search-documents | Azure AI Search client (for RAG examples) |
| python-dotenv | Load environment variables from .env files |
| aiohttp | Async HTTP client (required for streaming examples) |
# Copy the sample environment file
cp .env.sample .env
# Edit .env with your values
# Windows:
notepad .env
# macOS / Linux:
# nano .env
Fill in your values:
PROJECT_ENDPOINT=https://your-project-name.services.ai.azure.com
MODEL_DEPLOYMENT_NAME=gpt-4o
The SDK uses DefaultAzureCredential, which picks up your Azure CLI login:
az login
💡 If you have multiple subscriptions, set the correct one:
az account set --subscription "<your-subscription-id>"
Download and install the .NET 8.0 SDK from dotnet.microsoft.com.
Verify your installation:
dotnet --version # Should show 8.0.x or later
cd "Azure AI Agent SDK/dotnet"
dotnet restore
You can configure environment variables using user-secrets (recommended for development) or a .env file.
dotnet user-secrets init
dotnet user-secrets set "PROJECT_ENDPOINT" "https://your-project-name.services.ai.azure.com"
dotnet user-secrets set "MODEL_DEPLOYMENT_NAME" "gpt-4o"
$env:PROJECT_ENDPOINT = "https://your-project-name.services.ai.azure.com"
$env:MODEL_DEPLOYMENT_NAME = "gpt-4o"
set PROJECT_ENDPOINT=https://your-project-name.services.ai.azure.com
set MODEL_DEPLOYMENT_NAME=gpt-4o
az login
All examples in this repository use the following environment variables:
| Variable | Description | Example |
|---|---|---|
PROJECT_ENDPOINT |
Your Azure AI Foundry project endpoint | https://my-project.services.ai.azure.com |
MODEL_DEPLOYMENT_NAME |
The name of your deployed model | gpt-4o |
| Variable | Description | Used In |
|---|---|---|
AZURE_SEARCH_ENDPOINT |
Azure AI Search service endpoint | RAG examples (Level 2, Example 02) |
AZURE_SEARCH_INDEX_NAME |
Name of your search index | RAG examples (Level 2, Example 02) |
🔒 Security: Never commit
.envfiles or secrets to source control. The.envfile is listed in.gitignore.
Run these commands to verify your setup is correct.
# Confirm you're logged in and see your subscription
az account show --query "{name:name, id:id, state:state}" -o table
cd "Azure AI Agent SDK/python"
# Activate the virtual environment
# Windows: .venv\Scripts\Activate.ps1
# macOS/Linux: source .venv/bin/activate
# Verify packages are installed
python -c "
from azure.ai.projects import AIProjectClient
from azure.identity import DefaultAzureCredential
print('✅ Python SDK installed successfully')
print(f' azure-ai-projects version: {__import__(\"importlib.metadata\", fromlist=[\"version\"]).version(\"azure-ai-projects\")}')
"
cd "Azure AI Agent SDK/dotnet"
# Verify the project builds
dotnet build --nologo --verbosity quiet
# If successful, you'll see:
# Build succeeded.
# Python — quick connectivity test
cd "Azure AI Agent SDK/python"
python -c "
import os
from dotenv import load_dotenv
from azure.ai.projects import AIProjectClient
from azure.identity import DefaultAzureCredential
load_dotenv()
endpoint = os.getenv('PROJECT_ENDPOINT')
if not endpoint:
print('❌ PROJECT_ENDPOINT not set in .env')
else:
client = AIProjectClient(endpoint=endpoint, credential=DefaultAzureCredential())
print(f'✅ Connected to: {endpoint}')
"
Once your setup is verified, head back to the README and start with Level 1: Beginner → 01 Hello Agent.
Happy building! 🚀