Skip to content

fix(lesson-01): replace deprecated AzureAIProjectAgentProvider with FoundryChatClient#573

Open
jorgedoiany wants to merge 2 commits into
microsoft:mainfrom
jorgedoiany:fix/lesson-01-azure-agent-provider
Open

fix(lesson-01): replace deprecated AzureAIProjectAgentProvider with FoundryChatClient#573
jorgedoiany wants to merge 2 commits into
microsoft:mainfrom
jorgedoiany:fix/lesson-01-azure-agent-provider

Conversation

@jorgedoiany

@jorgedoiany jorgedoiany commented Jun 11, 2026

Copy link
Copy Markdown

Description

Updates the lesson 01 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 in GitHub Codespaces with the latest dependencies from requirements.txt 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=...) FoundryChatClient(project_endpoint=..., model=..., credential=...)
provider.create_agent(name=..., instructions=..., tools=...) provider.as_agent(name=..., instructions=..., tools=...)
  • Added missing from agent_framework import tool import
  • Applied fix 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 11, 2026 03:52

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 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 .env file via dotenv.
  • 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.

Comment on lines +69 to +70
" project_endpoint=os.environ[\"AZURE_AI_PROJECT_ENDPOINT\"],\n",
" model=os.environ[\"AZURE_AI_MODEL_DEPLOYMENT_NAME\"],\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.

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",

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.

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",

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.

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.

@github-actions

Copy link
Copy Markdown
Contributor

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

@jorgedoiany

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

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.

bug(lesson-01): AzureAIProjectAgentProvider removed from agent-framework

3 participants