Skip to content

ownway22/azure-ai-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Azure AI Agent with MCP Tools

本案示範如何使用 Azure AI Agent 執行各種 AI 任務,包括基礎、中階、進階,以及與 MCP 整合的應用,並提供 Jupyter Notebook 及 Python 範例。

This repository demonstrates how to use Azure AI Agent for various AI tasks, including basic, intermediate, advanced, and MCP-integrated applications. It provides examples in both Jupyter Notebooks and Python scripts. Please see the user guide at the bottom.

1. 專案下載

下載本專案:

git clone https://github.com/ownway22/azure-ai-agent.git

進入專案資料夾:

cd azure-ai-agent

2. 環境建置

方法一:典型方式

  1. 建立虛擬環境:
    python -m venv .venv
  2. 啟用虛擬環境:
    • Windows PowerShell 指令:
      .venv\Scripts\Activate
    • CMD 指令:
      .venv\Scripts\activate.bat
    • macOS/Linux 指令:
      source .venv/bin/activate
  3. 安裝所需套件:
    pip install -r requirements.txt

方法二:使用 uv sync

  1. 快速建立與安裝虛擬環境:
    uv sync
  2. 啟用虛擬環境:
    • Windows PowerShell 指令:
      .venv\Scripts\Activate
    • CMD 指令:
      .venv\Scripts\activate.bat
    • macOS/Linux 指令:
      source .venv/bin/activate

3. 修改環境變數

請到 Azure AI Foundry Project 複製您 AI project 中相關的環境變數,並將其填入 .env 檔案中。

PROJECT_ENDPOINT="https://*****.services.ai.azure.com/api/projects/*****"
API_KEY="86CBilkUxBKM3s8VYa7blR40bgIkDGhYnDys*****"
MODEL_DEPLOYMENT_NAME="gpt-4o"

AZURE_OPENAI_ENDPOINT="https://openai-ai-workshop.openai.azure.com/"
AZURE_OPENAI_API_KEY="AYj128C1av4Y9MLl01p5k6tIRY6pYRWOPjH*****"
AZURE_OPENAI_CHAT_DEPLOYMENT_NAME="gpt-4o"
AZURE_OPENAI_API_VERSION="2025-01-01-preview"
AZURE_BING_CONNECTION_ID="*****"

4. Azure CLI 登入 (az login)

在執行範例前,請先安裝並登入 Azure CLI:

  1. 若尚未安裝 Azure CLI,請參考官方說明:如何安裝 Azure CLI
  2. 登入 Azure 帳號:
    • Windows (PowerShell 或 CMD):
      az login
    • macOS / Linux (Terminal):
      az login

執行後會自動開啟瀏覽器進行帳號驗證,登入成功即可繼續後續步驟。

5. 開始執行範例

依序執行以下檔案:

  1. 01_ai-agent-basic.ipynb
  2. 02_ai-agent-intermediate.py
  3. 03_ai-agent-advanced.py
  4. 04_ai-agent-mcp-basic.ipynb
  5. 05_ai-agent-mcp-intermediate.py
  6. 06_ai-agent-mcp-advanced.py

執行 Jupyter Notebook 範例:

pip install notebook
jupyter notebook

然後在瀏覽器中開啟上述的 .ipynb 檔案。

執行 Python 範例:

python 02_ai-agent-intermediate.py
python 03_ai-agent-advanced.py
python 05_ai-agent-mcp-intermediate.py
python 06_ai-agent-mcp-advanced.py

6. 完成後的結果

當所有程式碼執行完成後,您可以在 Azure AI Foundry portal 的 agent 清單中看到如下畫面:

complete

該畫面顯示已成功建立的 agent 清單,包含其名稱、ID、模型類型、建立時間等資訊。


The User Guide

This repository demonstrates how to use Azure AI Agent for various AI tasks, including basic, intermediate, advanced, and MCP-integrated applications. It provides examples in both Jupyter Notebooks and Python scripts.

1. Project Download

Download the repository:

git clone https://github.com/ownway22/azure-ai-agent.git

Navigate to the project folder:

cd azure-ai-agent

2. Environment Setup

Option 1: Typical Setup

  1. Create a virtual environment:
    python -m venv .venv
  2. Activate the virtual environment:
    • Windows PowerShell:
      .venv\Scripts\Activate
    • CMD:
      .venv\Scripts\activate.bat
    • macOS/Linux:
      source .venv/bin/activate
  3. Install required packages:
    pip install -r requirements.txt

Option 2: Using uv sync

  1. Quickly set up and install the virtual environment:
    uv sync
  2. Activate the virtual environment:
    • Windows PowerShell:
      .venv\Scripts\Activate
    • CMD:
      .venv\Scripts\activate.bat
    • macOS/Linux:
      source .venv/bin/activate

3. Modify Environment Variables

Go to the Azure AI Foundry Project to copy the relevant environment variables for your AI project and add them to the .env file:

PROJECT_ENDPOINT="https://*****.services.ai.azure.com/api/projects/*****"
API_KEY="86CBilkUxBKM3s8VYa7blR40bgIkDGhYnDys*****"
MODEL_DEPLOYMENT_NAME="gpt-4o"

AZURE_OPENAI_ENDPOINT="https://openai-ai-workshop.openai.azure.com/"
AZURE_OPENAI_API_KEY="AYj128C1av4Y9MLl01p5k6tIRY6pYRWOPjH*****"
AZURE_OPENAI_CHAT_DEPLOYMENT_NAME="gpt-4o"
AZURE_OPENAI_API_VERSION="2025-01-01-preview"
AZURE_BING_CONNECTION_ID="*****"

4. Azure CLI Login (az login)

Before running the examples, install and log in to the Azure CLI:

  1. If you haven't installed the Azure CLI yet, follow the official guide: Install the Azure CLI
  2. Log in to your Azure account:
    • Windows (PowerShell or CMD):
      az login
    • macOS / Linux (Terminal):
      az login

This will automatically open a browser for account verification. Once logged in, you can proceed to the next steps.

5. Run Examples

Execute the following files in order:

  1. 01_ai-agent-basic.ipynb
  2. 02_ai-agent-intermediate.py
  3. 03_ai-agent-advanced.py
  4. 04_ai-agent-mcp-basic.ipynb
  5. 05_ai-agent-mcp-intermediate.py
  6. 06_ai-agent-mcp-advanced.py

Run Jupyter Notebook examples:

pip install notebook
jupyter notebook

Then open the .ipynb files in your browser.

Run Python script examples:

python 02_ai-agent-intermediate.py
python 03_ai-agent-advanced.py
python 05_ai-agent-mcp-intermediate.py
python 06_ai-agent-mcp-advanced.py

6. Results After Completion

After executing all the code, you can see the agent list in the Azure AI Foundry portal as shown below:

complete

This screen displays the list of successfully created agents, including their names, IDs, model types, creation times, and other information.


Reference

01_ai-agent-basic.ipynb

  1. Quickstart - Create a new Azure AI Foundry Agent Service project (2025/07)
  2. Azure AI Projects client library for Python - version 1.0.0b12 (2025/06)
  3. Azure AI Agents client library for Python - version 1.0.2 (2025/07)

02_ai-agent-intermediate.py

  1. azure-sdk-for-python by dargilco (2025/06)

03_ai-agent-advanced.py

  1. Build your code-first agent with Azure AI Foundry

04_ai-agent-mcp-basic.ipynb

  1. Announcing Model Context Protocol Support (preview) in Azure AI Foundry Agent Service | Azure AI Foundry Blog (2025/06)
  2. Code Samples for the Model Context Protocol Tool (Preview) - Azure AI Foundry | Microsoft Learn (2025/07)
  3. Create a Remote MCP server for your GitHub repository

05_ai-agent-mcp-intermediate.py

  1. QuickStart to MCP Tools Development with Azure AI Foundry SDK (2025/07)
  2. AI-Foundry-Agent-MCP by Christian Coello (2025/07)

06_ai-agent-mcp-advanced.py

  1. Build a MCP client using Azure AI Foundry and OpenAI Agents SDK (2025/04)
  2. ai-foundry-agents-samples by Eitan Sela (2025/07)
  3. Office PowerPoint MCP server
  4. Excel Data Manager MCP server

More

  1. AI Repo of the Week: MCP for Beginners | Microsoft Community Hub (2025/05)
  2. 10 Microsoft MCP Servers to Accelerate Your Development Workflow - Microsoft for Developers (2025/07)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published