Azure AI Hosted Agents (Python) Skill · Data Ai

Build Container-Based Hosted Agents with Azure AI

Build container-based hosted agents using ImageBasedHostedAgentDefinition from Azure AI Projects SDK v2.0.0b3.

Deploy custom AI agents with ACR integration. Get started now.

  • Azure AI
  • Container Agents
  • Python SDK
  • ACR
  • Hosted Agents
  • AI Foundry

About This Skill

This skill covers building container-based hosted agents using ImageBasedHostedAgentDefinition from the Azure AI Projects SDK (v2.0.0b3+). It includes 4 core steps: installation, authentication, container setup, and agent creation.

Quick Start

  1. 1Install azure-ai-projects>=2.0.0b3 and azure-identity
  2. 2Set AZURE_AI_PROJECT_ENDPOINT environment variable
  3. 3Create agent using ImageBasedHostedAgentDefinition
Example Command
pip install azure-ai-projects>=2.0.0b3 azure-identity

Core Capabilities

Installation & SDK Setup

Install the Azure AI Projects SDK with minimum version 2.0.0b3 and configure environment variables for your project endpoint.

Authentication & Permissions

Use DefaultAzureCredential for secure authentication and grant AcrPull role to your project's managed identity for container access.

Container Image & ACR Integration

Build and push container images to Azure Container Registry with proper pull permissions and capability host configuration.

Hosted Agent Creation

Create hosted agents using ImageBasedHostedAgentDefinition with container protocol version records and agent protocol settings.

Usage Examples

Before

Manual agent setup without container hosting, limited scalability.

After

Automated hosted agent deployment with ACR-based container images, enabling scalable and secure AI agent execution.

Input

Authenticate to Azure AI Project using DefaultAzureCredential.

Output

AIProjectClient initialized with endpoint and credential, ready for agent operations.

Input

Set up environment variable AZURE_AI_PROJECT_ENDPOINT for project connection.

Output

Client connects to the specified Azure AI project endpoint for all subsequent API calls.

SKILL.md

---
name: agents-v2-py
description: "Build container-based Foundry Agents with Azure AI Projects SDK (ImageBasedHostedAgentDefinition). Use when creating hosted agents with custom container images in Azure AI Foundry."
risk: unknown
source: community
date_added: "2026-02-27"
---

# Azure AI Hosted Agents (Python)

Build container-based hosted agents using `ImageBasedHostedAgentDefinition` from the Azure AI Projects SDK.

## Installation

```bash
pip install azure-ai-projects>=2.0.0b3 azure-identity
```

**Minimum SDK Version:** `2.0.0b3` or later required for hosted agent support.

## Environment Variables

```bash
AZURE_AI_PROJECT_ENDPOINT=https://<resource>.services.ai.azure.com/api/projects/<project>
```

## Prerequisites

Before creating hosted agents:

1. **Container Image** - Build and push to Azure Container Registry (ACR)
2. **ACR Pull Permissions** - Grant your project's managed identity `AcrPull` role on the ACR
3. **Capability Host** - Account-level capability host with `enablePublicHostingEnvironment=true`
4. **SDK Version** - Ensure `azure-ai-projects>=2.0.0b3`

## Authentication

Always use `DefaultAzureCredential`:

```python
from azure.identity import DefaultAzureCredential
from azure.ai.projects import AIProjectClient

credential = DefaultAzureCredential()
client = AIProjectClient(
    endpoint=os.environ["AZURE_AI_PROJECT_ENDPOINT"],
    credential=credential
)
```

## Core Workflow

### 1. Imports

```python
import os
from azure.identity import DefaultAzureCredential
from azure.ai.projects import AIProjectClient
from azure.ai.projects.models import (
    ImageBasedHostedAgentDefinition,
    ProtocolVersionRecord,
    AgentProtocol,
)
```

### 2. Create Hosted Agent

```python
client = AIProjectClient(
    endpoint=os.environ["AZURE_AI_PROJECT_ENDPOINT"],
    credential=DefaultAzureCredential()
)

agent = client.agents.create_version(
    agent_name="my-hosted-agent",
    definition=ImageBasedHostedAgentDefinition(
        container_protocol_versio

Frequently Asked Questions

FAQ

What SDK version is required for hosted agents?
You need azure-ai-projects version 2.0.0b3 or later. Earlier versions do not support ImageBasedHostedAgentDefinition.
Who is this skill for?
This skill is for Python developers and AI engineers who want to build and deploy container-based AI agents using Azure AI Foundry and Azure Container Registry.
How is this different from standard Azure AI agents?
Hosted agents use custom container images (ImageBasedHostedAgentDefinition) instead of built-in models, giving you full control over the agent runtime, dependencies, and execution environment.
What programming languages are supported?
This skill focuses on Python using the Azure AI Projects SDK. The container image can include any language or framework you need.
What results can I expect after completing this skill?
You will be able to create, configure, and deploy a container-based hosted agent in Azure AI Foundry, with proper authentication, ACR integration, and agent lifecycle management.

Discussion

Discussion

0 comments
U

Trigger Phrases

Use these phrases to activate this skill in your AI coding assistant:

create hosted agentcontainer-based AI agentAzure AI hosted agentImageBasedHostedAgentDefinitionAzure AI Projects SDK agentdeploy AI agent container
Azure AI Hosted Agents for Developers: Build Container-Based Agents