fix(lesson-02): replace deprecated AzureAIProjectAgentProvider and add missing semantic-kernel install#576
Conversation
… and add semantic-kernel install
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 agentic framework notebooks to be easier to run and align with the newer Foundry-based client, while also improving notebook metadata/formatting and adding an installation step for Semantic Kernel.
Changes:
- Add a
%pip install semantic-kernelcell to the Semantic Kernel notebooks. - Migrate the Python Agent Framework notebooks from
agent_framework.azureprovider usage toagent_framework.foundry(FoundryChatClient) with env-var configuration loading. - Normalize notebook disclaimer formatting and update kernelspec metadata/version fields.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| translations/es/02-explore-agentic-frameworks/code_samples/02-semantic-kernel.ipynb | Adds SK install cell; adjusts disclaimer formatting and kernelspec metadata. |
| translations/es/02-explore-agentic-frameworks/code_samples/02-python-agent-framework.ipynb | Switches to Foundry client + dotenv-based env loading; updates disclaimer and kernelspec metadata. |
| 02-explore-agentic-frameworks/code_samples/02-semantic-kernel.ipynb | Adds SK install cell, but also commits executed outputs and execution counts. |
| 02-explore-agentic-frameworks/code_samples/02-python-agent-framework.ipynb | Switches to Foundry client + dotenv-based env loading. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| { | ||
| "cell_type": "code", | ||
| "execution_count": 1, | ||
| "metadata": {}, | ||
| "outputs": [ | ||
| { | ||
| "name": "stdout", | ||
| "output_type": "stream", | ||
| "text": [ | ||
| "\n", | ||
| "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m25.0.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m26.1.2\u001b[0m\n", | ||
| "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n", | ||
| "Note: you may need to restart the kernel to use updated packages.\n" | ||
| ] | ||
| } | ||
| ], | ||
| "source": [ | ||
| "%pip install semantic-kernel -q" | ||
| ] | ||
| }, |
There was a problem hiding this comment.
Applied in the latest commit. Cleared all cell outputs and reset execution counts. Also pinned semantic-kernel to a specific version for reproducibility.
| "import logging\n", | ||
| "logging.getLogger(\"agent_framework.azure\").setLevel(logging.ERROR)\n", | ||
| "logging.getLogger(\"agent_framework.foundry\").setLevel(logging.ERROR)\n", | ||
| "\n", | ||
| "import os\n", | ||
| "import asyncio\n", | ||
| "import dotenv\n", | ||
| "from typing import Annotated\n", | ||
| "\n", | ||
| "from agent_framework import tool\n", | ||
| "from agent_framework.azure import AzureAIProjectAgentProvider\n", | ||
| "from azure.identity import AzureCliCredential" | ||
| "from agent_framework.foundry import FoundryChatClient\n", | ||
| "from azure.identity import AzureCliCredential\n", | ||
| "\n", | ||
| "dotenv.load_dotenv(dotenv.find_dotenv())" |
There was a problem hiding this comment.
Applied in the latest commit. Added %pip install python-dotenv -q to the install cell in both the English and Spanish notebooks.
| "import logging\n", | ||
| "logging.getLogger(\"agent_framework.azure\").setLevel(logging.ERROR)\n", | ||
| "logging.getLogger(\"agent_framework.foundry\").setLevel(logging.ERROR)\n", | ||
| "\n", | ||
| "import os\n", | ||
| "import asyncio\n", | ||
| "import dotenv\n", | ||
| "from typing import Annotated\n", | ||
| "\n", | ||
| "from agent_framework import tool\n", | ||
| "from agent_framework.azure import AzureAIProjectAgentProvider\n", | ||
| "from azure.identity import AzureCliCredential" | ||
| "from agent_framework.foundry import FoundryChatClient\n", | ||
| "from azure.identity import AzureCliCredential\n", | ||
| "\n", | ||
| "dotenv.load_dotenv(dotenv.find_dotenv())" |
There was a problem hiding this comment.
Applied in the latest commit. Added %pip install python-dotenv -q to the install cell in both the English and Spanish notebooks.
| "endpoint = os.getenv(\"AZURE_AI_PROJECT_ENDPOINT\")\n", | ||
| "model = os.getenv(\"AZURE_AI_MODEL_DEPLOYMENT_NAME\")\n", | ||
| "\n", | ||
| "if not endpoint or not model:\n", | ||
| " raise ValueError(\n", | ||
| " \"Missing required environment variables. \"\n", | ||
| " \"Please set AZURE_AI_PROJECT_ENDPOINT and AZURE_AI_MODEL_DEPLOYMENT_NAME in your .env file.\"\n", | ||
| " )\n", |
There was a problem hiding this comment.
Applied in the latest commit. Updated the error message to mention both .env file and shell environment variables as valid options.
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "%pip install semantic-kernel -q" |
There was a problem hiding this comment.
Applied in the latest commit. Cleared all cell outputs and reset execution counts. Also pinned semantic-kernel to a specific version for reproducibility.
|
👋 Thanks for contributing @jorgedoiany! We will review the pull request and get back to you soon. |
…improve error message, pin semantic-kernel version and clear outputs
|
@copilot resolve the merge conflicts in this pull request |
Description
Updates lesson 02 notebooks to fix two issues found when running in GitHub Codespaces with the latest dependencies from requirements.txt.
Problem
Issue 1 - 02-python-agent-framework.ipynb:
AzureAIProjectAgentProviderwas removed inagent-frameworkv1.8.x and is no longer available underagent_framework.azure.Issue 2 - 02-semantic-kernel.ipynb:
The notebook uses
semantic_kernelbut it is not listed inrequirements.txtand is not pre-installed in the Codespace environment.Root Cause
Issue 1: 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
Issue 2:
semantic-kernelis a required dependency for this notebook but is missing fromrequirements.txt.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=...)%pip install semantic-kernel -qat the top of02-semantic-kernel.ipynbtranslations/es) notebooksTesting
Verified working in GitHub Codespaces with:
Related
Type of Change