Skip to content

fix(lesson-09): replace deprecated AzureAIProjectAgentProvider with FoundryChatClient#597

Open
jorgedoiany wants to merge 1 commit into
microsoft:mainfrom
jorgedoiany:fix/lesson-09-metacognition
Open

fix(lesson-09): replace deprecated AzureAIProjectAgentProvider with FoundryChatClient#597
jorgedoiany wants to merge 1 commit into
microsoft:mainfrom
jorgedoiany:fix/lesson-09-metacognition

Conversation

@jorgedoiany

Copy link
Copy Markdown

Description

Updates lesson 09 notebook to use the current Microsoft Agent Framework API. AzureAIProjectAgentProvider was removed in agent-framework v1.8.x and is no longer available under agent_framework.azure.

Problem

Running the notebook fails immediately with:

ImportError: cannot import name 'AzureAIProjectAgentProvider' from 'agent_framework.azure'

Root Cause

The agent-framework library underwent a breaking change where Foundry-related clients were moved from agent_framework.azure to agent_framework.foundry.

Reference: https://learn.microsoft.com/en-us/agent-framework/support/upgrade/python-2026-significant-changes

Changes

Before After
from agent_framework.azure import AzureAIProjectAgentProvider from agent_framework.foundry import FoundryChatClient
AzureAIProjectAgentProvider(credential=AzureCliCredential()) FoundryChatClient(project_endpoint=..., model=..., credential=DefaultAzureCredential())
provider.create_agent(name=..., instructions=..., tools=...) client.as_agent(name=..., instructions=..., tools=...)
  • Renamed provider to client for clarity
  • Replaced AzureCliCredential with DefaultAzureCredential for better portability
  • Used %pip install instead of ! pip install
  • Added python-dotenv to install cell
  • Added environment variable validation with actionable error message
  • Applied all fixes to both English and Spanish (translations/es) notebooks

Testing

Verified working in GitHub Codespaces with:

  • agent-framework: 1.8.1
  • Python: 3.12.13
  • azure-identity: 1.25.3
  • azure-ai-projects: 2.2.0

Related

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactor

Copilot AI review requested due to automatic review settings June 17, 2026 15:19
@github-actions

Copy link
Copy Markdown
Contributor

👋 Thanks for contributing @jorgedoiany! We will review the pull request and get back to you soon.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates the Azure agent sample notebooks to use the Azure AI Foundry client and more flexible credential/env-var configuration.

Changes:

  • Switched from AzureAIProjectAgentProvider/AzureCliCredential to FoundryChatClient/DefaultAzureCredential
  • Added .env support via python-dotenv and validated required environment variables
  • Reformatted the Spanish translation disclaimer markdown cell

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
translations/es/09-metacognition/code_samples/09-python-agent-framework.ipynb Migrates the Spanish notebook to Foundry client + dotenv config, and adjusts markdown formatting.
09-metacognition/code_samples/09-python-agent-framework.ipynb Migrates the main notebook to Foundry client + dotenv config and updates runtime metadata.
Comments suppressed due to low confidence (1)

translations/es/09-metacognition/code_samples/09-python-agent-framework.ipynb:1

  • This is the Spanish translation notebook, but the newly added runtime error message is in English. To keep the translated content consistent and user-friendly, translate this message to Spanish (keeping the env var keys unchanged), or reference a shared bilingual message pattern used elsewhere in the translated materials.
{

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

"source": [
"\n",
"provider = AzureAIProjectAgentProvider(credential=AzureCliCredential())"
"# Create the Azure AI Foundry client\n",

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following standard industry practice and Microsoft's own convention in this repository, code comments and error messages are intentionally kept in English even in translated notebooks. Translating runtime messages and code comments would be inconsistent with the rest of the codebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants