fix(lesson-01): replace deprecated AzureAIProjectAgentProvider with FoundryChatClient#573
fix(lesson-01): replace deprecated AzureAIProjectAgentProvider with FoundryChatClient#573jorgedoiany wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates the Python agent framework notebooks to use the Foundry-based client/provider setup and refreshes notebook metadata/disclaimer formatting.
Changes:
- Switch provider initialization from the Azure project agent provider to
FoundryChatClient. - Load configuration from a
.envfile viadotenv. - Update agent creation to use
provider.as_agent(...)and refresh notebook metadata.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| translations/es/01-intro-to-ai-agents/code_samples/01-python-agent-framework.ipynb | Mirrors the provider/agent refactor in the Spanish translation and reformats the disclaimer cell + metadata. |
| 01-intro-to-ai-agents/code_samples/01-python-agent-framework.ipynb | Refactors the sample to use FoundryChatClient, loads env vars via dotenv, and updates notebook kernel/language metadata. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| " project_endpoint=os.environ[\"AZURE_AI_PROJECT_ENDPOINT\"],\n", | ||
| " model=os.environ[\"AZURE_AI_MODEL_DEPLOYMENT_NAME\"],\n", |
There was a problem hiding this comment.
Applied in the latest commit. Replaced os.environ[] with os.getenv() and added an explicit ValueError with a clear message explaining which variables to set. Same change applied to the Spanish notebook.
| "from agent_framework import tool\n", | ||
| "\n", | ||
| "provider = AzureAIProjectAgentProvider(credential=AzureCliCredential())" | ||
| "dotenv.load_dotenv(dotenv.find_dotenv(), override=True)\n", |
There was a problem hiding this comment.
Applied in the latest commit. Removed override=True from load_dotenv() so existing shell/session environment variables are not overwritten. Same change applied to the Spanish notebook.
| "\n", | ||
| "from agent_framework import tool\n", | ||
| "from agent_framework.azure import AzureAIProjectAgentProvider\n", | ||
| "import dotenv\n", |
There was a problem hiding this comment.
python-dotenv is already included in the repository's requirements.txt file, so no additional changes are needed. Both the English and Spanish notebooks rely on the same requirements.txt for their dependencies.
|
👋 Thanks for contributing @jorgedoiany! We will review the pull request and get back to you soon. |
|
@microsoft-github-policy-service agree |
Description
Updates the lesson 01 notebook to use the current Microsoft Agent Framework API.
AzureAIProjectAgentProviderwas removed inagent-frameworkv1.8.x and is no longer available underagent_framework.azure.Problem
Running the notebook in GitHub Codespaces with the latest dependencies from
requirements.txtfails immediately with:Root Cause
The
agent-frameworklibrary underwent a breaking change where Foundry-related clients were moved fromagent_framework.azuretoagent_framework.foundry.Reference: https://learn.microsoft.com/en-us/agent-framework/support/upgrade/python-2026-significant-changes
Changes
from agent_framework.azure import AzureAIProjectAgentProviderfrom agent_framework.foundry import FoundryChatClientAzureAIProjectAgentProvider(credential=...)FoundryChatClient(project_endpoint=..., model=..., credential=...)provider.create_agent(name=..., instructions=..., tools=...)provider.as_agent(name=..., instructions=..., tools=...)from agent_framework import toolimporttranslations/es) notebooksTesting
Verified working in GitHub Codespaces with:
agent-framework: 1.8.1Python: 3.12.13azure-identity: 1.25.3azure-ai-projects: 2.2.0Related
Type of Change