使用 Microsoft 代理框架 Python SDK (agent-framework-azure-ai) 构建 Azure AI Foundry 代理。在使用 AzureAIAgentsProvider 创建持久代理、使用托管工具(代码解释器、文件搜索、Web 搜索)、集成 MCP 服务器、管理对话线程或实施时使用
数据来源:ClawHub。 在 ClawSkills 查看
选择你使用的 Agent
方法一:命令行安装(推荐)
推荐(无需提前安装 clawhub)
npx clawhub@latest --dir ~/.claude/skills install agent-framework-azure-ai-py或使用 clawhub CLI(需提前安装)
clawhub --dir ~/.claude/skills install agent-framework-azure-ai-py⚠️ 需要 Node.js 18+,没有 Node?请使用下方方法二直接下载 ZIP。 安装 Node.js →
方法二:手动下载安装(无需 Node)
下载 ZIP,解压后将文件夹放到以下路径,重启 Agent 即可:
安装路径
~/.claude/skills/agent-framework-azure-ai-py/💡解压后将文件夹放到上方路径,重启 Agent 即可生效
--- name: agent-framework-azure-ai-py description: Build Azure AI Foundry agents using the Microsoft Agent Framework Python SDK (agent-framework-azure-ai). Use when creating persistent agents with AzureAIAgentsProvider, using hosted tools (code interpreter, file search, web search), integrating MCP servers, managing conversation threads, or implementing streaming responses. Covers function tools, structured outputs, and multi-tool agents. package: agent-framework-azure-ai ---
Build persistent agents on Azure AI Foundry using the Microsoft Agent Framework Python SDK.
User Query → AzureAIAgentsProvider → Azure AI Agent Service (Persistent)
↓
Agent.run() / Agent.run_stream()
↓
Tools: Functions | Hosted (Code/Search/Web) | MCP
↓
AgentThread (conversation persistence)
# Full framework (recommended)
pip install agent-framework --pre
# Or Azure-specific package only
pip install agent-framework-azure-ai --pre
export AZURE_AI_PROJECT_ENDPOINT="https://<project>.services.ai.azure.com/api/projects/<project-id>"
export AZURE_AI_MODEL_DEPLOYMENT_NAME="gpt-4o-mini"
export BING_CONNECTION_ID="your-bing-connection-id" # For web search
from azure.identity.aio import AzureCliCredential, DefaultAzureCredential
# Development
credential = AzureCliCredential()
# Production
credential = DefaultAzureCredential()
import asyncio
from agent_framework.azure import AzureAIAgentsProvider
from azure.identity.aio import AzureCliCredential
async def main():
async with (
AzureCliCredential() as credential,
AzureAIAgentsProvider(credential=credential) as provider,
):
agent = await provider.create_agent(
name="MyAgent",
instructions="You are a helpful assistant.",
)
result = await agent.run("Hello!")
print(result.text)
asyncio.run(main())
from typing import Annotated
from pydantic import Field
from agent_framework.azure import AzureAIAgentsProvider
from azure.identity.aio import AzureCliCredential
def get_weather(
location: Annotated[str, Field(description="City name to get weather for")],
) -> str:
"""Get the current weather for a location."""
return f"Weather in {location}: 72°F, sunny"
def get_current_time() -> str:
"""Get the current UTC time."""
from datetime import datetime, timezone
return datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S UTC")
async def main():
async with (
AzureCliCredential() as credential,
AzureAIAgentsProvider(credential=credential) as provider,
):
agent = await provider.create_agent(
name="WeatherAgent",
instructions="You help with weather and time queries.",
tools=[get_weather, get_current_time], # Pass functions directly
)
result = await agent.run("What's the weather in Seattle?")
print(result.text)
from agent_framework import (
HostedCodeInterpreterTool,
HostedFileSearchTool,
HostedWebSearchTool,
)
from agent_framework.azure import AzureAIAgentsProvider
from azure.identity.aio import AzureCliCredential
async def main():
async with (
AzureCliCredential() as credential,
AzureAIAgentsProvider(credential=credential) as provider,
):
agent = await provider.create_agent(
name="MultiToolAgent",
instructions="You can execute code, search files, and search the web.",
tools=[
HostedCodeInterpreterTool(),
HostedWebSearchTool(name="Bing"),
],
)
result = await agent.run("Calculate the factorial of 20 in Python")
print(result.text)
async def main():
async with (
AzureCliCredential() as credential,
AzureAIAgentsProvider(credential=credential) as provider,
):
agent = await provider.create_agent(
name="StreamingAgent",
instructions="You are a helpful assistant.",
)
print("Agent: ", end="", flush=True)
async for chunk in agent.run_stream("Tell me a short story"):
if chunk.text:
print(chunk.text, end="", flush=True)
print()
from agent_framework.azure import AzureAIAgentsProvider
from azure.identity.aio import AzureCliCredential
async def main():
async with (
AzureCliCredential() as credential,
AzureAIAgentsProvider(credential=credential) as provider,
):
agent = await provider.create_agent(
name="ChatAgent",
instructions="You are a helpful assistant.",
tools=[get_weather],
)
# Create thread for conversation persistence
thread = agent.get_new_thread()
# First turn
result1 = await agent.run("What's the weather in Seattle?", thread=thread)
print(f"Agent: {result1.text}")
# Second turn - context is maintained
result2 = await agent.run("What about Portland?", thread=thread)
print(f"Agent: {result2.text}")
# Save thread ID for later resumption
print(f"Conversation ID: {thread.conversation_id}")
from pydantic import BaseModel, ConfigDict
from agent_framework.azure import AzureAIAgentsProvider
from azure.identity.aio import AzureCliCredential
class WeatherResponse(BaseModel):
model_config = ConfigDict(extra="forbid")
location: str
temperature: float
unit: str
conditions: str
async def main():
async with (
AzureCliCredential() as credential,
AzureAIAgentsProvider(credential=credential) as provider,
):
agent = await provider.create_agent(
name="StructuredAgent",
instructions="Provide weather information in structured format.",
response_format=WeatherResponse,
)
result = await agent.run("Weather in Seattle?")
weather = WeatherResponse.model_validate_json(result.text)
print(f"{weather.location}: {weather.temperature}°{weather.unit}")
| Method | Description | |--------|-------------| | create_agent() | Create new agent on Azure AI service | | get_agent(agent_id) | Retrieve existing agent by ID | | as_agent(sdk_agent) | Wrap SDK Agent object (no HTTP call) |
| Tool | Import | Purpose | |------|--------|---------| | HostedCodeInterpreterTool | from agent_framework import HostedCodeInterpreterTool | Execute Python code | | HostedFileSearchTool | from agent_framework import HostedFileSearchTool | Search vector stores | | HostedWebSearchTool | from agent_framework import HostedWebSearchTool | Bing web search | | HostedMCPTool | from agent_framework import HostedMCPTool | Service-managed MCP | | MCPStreamableHTTPTool | from agent_framework import MCPStreamableHTTPTool | Client-managed MCP |
import asyncio
from typing import Annotated
from pydantic import BaseModel, Field
from agent_framework import (
HostedCodeInterpreterTool,
HostedWebSearchTool,
MCPStreamableHTTPTool,
)
from agent_framework.azure import AzureAIAgentsProvider
from azure.identity.aio import AzureCliCredential
def get_weather(
location: Annotated[str, Field(description="City name")],
) -> str:
"""Get weather for a location."""
return f"Weather in {location}: 72°F, sunny"
...安装 代理框架 Azure Ai Py 后,可以对 AI 说这些话来触发它
Help me get started with Agent Framework Azure Ai Py
Explains what Agent Framework Azure Ai Py does, walks through the setup, and runs a quick demo based on your current project
Use Agent Framework Azure Ai Py to build Azure AI Foundry agents using the Microsoft Agent Framework P...
Invokes Agent Framework Azure Ai Py with the right parameters and returns the result directly in the conversation
What can I do with Agent Framework Azure Ai Py in my developer & devops workflow?
Lists the top use cases for Agent Framework Azure Ai Py, with example commands for each scenario
将技能文件夹放到 ~/.claude/skills/agent-framework-azure-ai-py/ 目录(个人级,所有项目可用),或 .claude/skills/agent-framework-azure-ai-py/(项目级)。重启 AI 客户端后,用 /agent-framework-azure-ai-py 主动调用,或让 AI 根据上下文自动发现并使用。
代理框架 Azure Ai Py 支持 Claude、Cursor、OpenClaw,可与这些 AI 平台无缝集成,扩展其能力。
代理框架 Azure Ai Py 可免费安装使用。请查阅仓库了解许可证信息。
使用 Microsoft 代理框架 Python SDK (agent-framework-azure-ai) 构建 Azure AI Foundry 代理。在使用 AzureAIAgentsProvider 创建持久代理、使用托管工具(代码解释器、文件搜索、Web 搜索)、集成 MCP 服务器、管理对话线程或实施时使用
代理框架 Azure Ai Py 属于「Developer & DevOps」分类,该分类的技能帮助 AI 智能体在此领域执行专业任务。
Automate my developer & devops tasks using Agent Framework Azure Ai Py
Identifies repetitive steps in your workflow and sets up Agent Framework Azure Ai Py to handle them automatically