tokens&
For enterprises
Submit
Sign in
tokens&

Build better AI stacks, claim useful opportunities, and give AI infrastructure companies a source-labeled adoption readout they can trust.

For buildersFor enterprises

Product

  • For builders
  • Category rankings
  • Startup credits and perks
  • Agent Skills
  • Platform
  • Submit project, tool, product, or perk

Enterprise

  • Start free company workspace

Community

  • Community
  • Newsletter
  • Events
Xin

© 2026 tokensand, LLC. All rights reserved.

  • Terms
  • Privacy
  • Security
  • Data Processing
  • Status
Agent Skills/Azure hosted agents for Python
MicrosoftAgentsSKILL.mdVerified source

Agent Skill

Azure hosted agents for Python

Build persistent Azure AI Foundry agents with hosted tools, MCP integrations, streaming, and structured outputs.

Install this skillView repository

Vendor-authored source · MIT license.

Raw SKILL.mdInstall the Tokens& Agent Pack

Tokens& curated build recipe

An Azure agent with a bounded tool

Use Microsoft's Azure hosted-agents skill to build a Python agent with one read-only tool over public sample data. Set a request budget and verify thread state, tool failures, and resource cleanup.

  1. 1. Check the startup application

    Microsoft for Startups Azure credits

    Microsoft reviews startup eligibility and business verification before granting applicable benefits. Azure credits cover eligible services; the advertised maximum is not an automatic allocation to every applicant.

    Read Microsoft Azure terms
  2. 2. Use the vendor skill

    Azure hosted agents for Python

    Review the source and install instructions below, then use the skill in your own project.

    See install instructions
  3. 3. Build and show the result

    Save the Build Packet, then attach a repository and a recorded run showing a successful tool result, a handled tool failure, and cleanup of test resources.

    Start this Build Packet

Public resources selected by Tokens&. Terms reviewed 2026-09-05; the provider decides eligibility and current limits. This recipe is a suggested project, not a vendor partnership or a completed build.

Skill specification

Declared by Microsoft in the package front matter. Trigger conditions are what the coding agent matches on before it loads the skill.

View package fields
Azure hosted agents for Python SKILL.md front matter fields
Skill nameagent-framework-azure-ai-py
Trigger conditionsBuild 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.
Declared licenseMIT
Version1.0.0
AuthorMicrosoft
Packageagent-framework-azure-ai

Install agent-framework-azure-ai-py

In a terminal with Node.js, npm and Git, run the command for your agent. The Skills CLI installs the complete package directory, including referenced files within it. Review its install prompt, then start a new agent session. A skill package does not set up an MCP server connection.

Claude Code

.claude/skills/agent-framework-azure-ai-py/SKILL.md

Project skills are committed with the repo. Use the user directory for a personal install across every project.

Project install

npx skills add 'https://github.com/microsoft/skills/tree/main/.github/plugins/azure-sdk-python/skills/agent-framework-azure-ai-py' --skill 'agent-framework-azure-ai-py' --agent 'claude-code'
Install for all projects instead

Personal install

npx skills add 'https://github.com/microsoft/skills/tree/main/.github/plugins/azure-sdk-python/skills/agent-framework-azure-ai-py' --skill 'agent-framework-azure-ai-py' --agent 'claude-code' --global

Codex

.agents/skills/agent-framework-azure-ai-py/SKILL.md

Codex reads `.agents/skills/` as its primary location, which is also the cross-platform default other clients honour.

Project install

npx skills add 'https://github.com/microsoft/skills/tree/main/.github/plugins/azure-sdk-python/skills/agent-framework-azure-ai-py' --skill 'agent-framework-azure-ai-py' --agent 'codex'
Install for all projects instead

Personal install

npx skills add 'https://github.com/microsoft/skills/tree/main/.github/plugins/azure-sdk-python/skills/agent-framework-azure-ai-py' --skill 'agent-framework-azure-ai-py' --agent 'codex' --global

Cursor

.agents/skills/agent-framework-azure-ai-py/SKILL.md

Cursor also loads `.agents/skills/`, `.claude/skills/`, and `.codex/skills/`, so one committed copy can serve several clients.

Project install

npx skills add 'https://github.com/microsoft/skills/tree/main/.github/plugins/azure-sdk-python/skills/agent-framework-azure-ai-py' --skill 'agent-framework-azure-ai-py' --agent 'cursor'
Install for all projects instead

Personal install

npx skills add 'https://github.com/microsoft/skills/tree/main/.github/plugins/azure-sdk-python/skills/agent-framework-azure-ai-py' --skill 'agent-framework-azure-ai-py' --agent 'cursor' --global

Gemini CLI

.agents/skills/agent-framework-azure-ai-py/SKILL.md

Gemini CLI reads `.agents/skills/` first when both directories exist.

Project install

npx skills add 'https://github.com/microsoft/skills/tree/main/.github/plugins/azure-sdk-python/skills/agent-framework-azure-ai-py' --skill 'agent-framework-azure-ai-py' --agent 'gemini-cli'
Install for all projects instead

Personal install

npx skills add 'https://github.com/microsoft/skills/tree/main/.github/plugins/azure-sdk-python/skills/agent-framework-azure-ai-py' --skill 'agent-framework-azure-ai-py' --agent 'gemini-cli' --global

GitHub Copilot

.agents/skills/agent-framework-azure-ai-py/SKILL.md

The Skills CLI uses the shared `.agents/skills/` directory for Copilot project installs.

Project install

npx skills add 'https://github.com/microsoft/skills/tree/main/.github/plugins/azure-sdk-python/skills/agent-framework-azure-ai-py' --skill 'agent-framework-azure-ai-py' --agent 'github-copilot'
Install for all projects instead

Personal install

npx skills add 'https://github.com/microsoft/skills/tree/main/.github/plugins/azure-sdk-python/skills/agent-framework-azure-ai-py' --skill 'agent-framework-azure-ai-py' --agent 'github-copilot' --global

SKILL.md

View raw source

Published by Microsoft under MIT. Rendered from the package in github.com/microsoft/skills/tree/main/.github/plugins/azure-sdk-python/skills/agent-framework-azure-ai-py.

Read full skill instructions

Agent Framework Azure Hosted Agents

Build persistent agents on Azure AI Foundry using the Microsoft Agent Framework Python SDK.

Architecture

User Query → AzureAIAgentsProvider → Azure AI Agent Service (Persistent)
                    ↓
              Agent.run() / Agent.run_stream()
                    ↓
              Tools: Functions | Hosted (Code/Search/Web) | MCP
                    ↓
              AgentThread (conversation persistence)

Installation

# Full framework (recommended)
pip install agent-framework --pre

# Or Azure-specific package only
pip install agent-framework-azure-ai --pre

Environment Variables

export AZURE_AI_PROJECT_ENDPOINT="https://<project>.services.ai.azure.com/api/projects/<project-id>"  # Required for all auth methods
export AZURE_AI_MODEL_DEPLOYMENT_NAME="gpt-4o-mini"  # Required for all auth methods
export BING_CONNECTION_ID="your-bing-connection-id"  # For web search
export AZURE_TOKEN_CREDENTIALS=prod # Required only if DefaultAzureCredential is used in production

Authentication & Lifecycle

🔑 Two rules apply to every code sample below: 1. Prefer `DefaultAzureCredential`. It works locally (Azure CLI / VS Code / Developer CLI) and in Azure (managed identity, workload identity) with no code change. Avoid connection strings, account/API keys — they bypass Entra audit and rotation. - Local dev: DefaultAzureCredential works as-is. - Production: set AZURE_TOKEN_CREDENTIALS=prod (or AZURE_TOKEN_CREDENTIALS=<specific_credential>) to constrain the credential chain to production-safe credentials. 2. Wrap every client in a context manager so HTTP transports, sockets, and token caches are released deterministically: - Sync: with <Client>(...) as client: - Async: async with <Client>(...) as client: and async with DefaultAzureCredential() as credential: (from azure.identity.aio) Snippets may abbreviate this setup, but production code should always follow both rules.
from azure.identity.aio import AzureCliCredential, DefaultAzureCredential, ManagedIdentityCredential

# Development
credential = AzureCliCredential()

# Production
# Local dev: DefaultAzureCredential. Production: set AZURE_TOKEN_CREDENTIALS=prod or AZURE_TOKEN_CREDENTIALS=<specific_credential>
credential = DefaultAzureCredential(require_envvar=True)
# Or use a specific credential directly in production:
# See https://learn.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python#credential-classes
# credential = ManagedIdentityCredential()

Core Workflow

Basic Agent

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())

Agent with Function Tools

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)

Agent with Hosted Tools

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)

Streaming Responses

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()

Conversation Threads

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}")

Structured Outputs

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}")

Provider Methods

MethodDescription
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)

Hosted Tools Quick Reference

ToolImportPurpose
HostedCodeInterpreterToolfrom agent_framework import HostedCodeInterpreterToolExecute Python code
HostedFileSearchToolfrom agent_framework import HostedFileSearchToolSearch vector stores
HostedWebSearchToolfrom agent_framework import HostedWebSearchToolBing web search
HostedMCPToolfrom agent_framework import HostedMCPToolService-managed MCP
MCPStreamableHTTPToolfrom agent_framework import MCPStreamableHTTPToolClient-managed MCP

Complete Example

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"


class AnalysisResult(BaseModel):
    summary: str
    key_findings: list[str]
    confidence: float


async def main():
    async with (
        AzureCliCredential() as credential,
        MCPStreamableHTTPTool(
            name="Docs MCP",
            url="https://learn.microsoft.com/api/mcp",
        ) as mcp_tool,
        AzureAIAgentsProvider(credential=credential) as provider,
    ):
        agent = await provider.create_agent(
            name="ResearchAssistant",
            instructions="You are a research assistant with multiple capabilities.",
            tools=[
                get_weather,
                HostedCodeInterpreterTool(),
                HostedWebSearchTool(name="Bing"),
                mcp_tool,
            ],
        )
        
        thread = agent.get_new_thread()
        
        # Non-streaming
        result = await agent.run(
            "Search for Python best practices and summarize",
            thread=thread,
        )
        print(f"Response: {result.text}")
        
        # Streaming
        print("\nStreaming: ", end="")
        async for chunk in agent.run_stream("Continue with examples", thread=thread):
            if chunk.text:
                print(chunk.text, end="", flush=True)
        print()
        
        # Structured output
        result = await agent.run(
            "Analyze findings",
            thread=thread,
            response_format=AnalysisResult,
        )
        analysis = AnalysisResult.model_validate_json(result.text)
        print(f"\nConfidence: {analysis.confidence}")


if __name__ == "__main__":
    asyncio.run(main())

Conventions

  • Always use async context managers: async with provider:
  • Pass functions directly to tools= parameter (auto-converted to AIFunction)
  • Use Annotated[type, Field(description=...)] for function parameters
  • Use get_new_thread() for multi-turn conversations
  • Prefer HostedMCPTool for service-managed MCP, MCPStreamableHTTPTool for client-managed

Best Practices

  1. This SDK is async-first — use `async def` handlers and `async with` throughout.
  2. Always use context managers for clients and async credentials. Wrap every client in with Client(...) as client: (sync) or async with Client(...) as client: (async). For async DefaultAzureCredential from azure.identity.aio, also use async with credential: so tokens and transports are cleaned up.

Reference Files

  • references/tools.md: Detailed hosted tool patterns
  • references/mcp.md: MCP integration (hosted + local)
  • references/threads.md: Thread and conversation management
  • references/advanced.md: OpenAPI, citations, structured outputs

More Microsoft Agent Skills

All Agent Skills

Application Insights web instrumentation

Instrument browser apps for RUM, dependencies, exceptions, custom events, and correlated agent traces.

Frontend

Azure AI content safety for Python

Detect harmful text and image content with severity-aware moderation workflows in Python.

Models

Azure AI Projects for TypeScript

Build Foundry applications with project clients, agents, deployments, datasets, indexes, and evaluations.

Agents

Azure AI Search for TypeScript

Build vector, hybrid, semantic, and agentic retrieval workflows with the Azure AI Search SDK.

Backend

Azure cloud solution architect

Design and review Azure systems against architecture patterns and Well-Architected Framework tradeoffs.

Backend

Azure Cosmos DB for TypeScript

Implement Cosmos DB document CRUD, queries, partitioning, bulk operations, and container management.

Backend