Skip to content
Skillpedia
Deploy & cloud (DevOps)48k · #3213

hosted-agents-v2-py

Helps your agent build hosted agents using the Azure AI Projects SDK. Useful for creating container-based agents in Azure AI Foundry.

What it does

This tool lets you create custom 'agents' that run in containers on Azure's cloud. Think of them as programs you can configure to perform specific tasks.

When to use it

  • ✓When you need a program to run in an isolated environment (container).
  • ✓When setting up an agent to interact with other Azure services.
  • ✓To create an AI assistant that can execute code or use specific tools.

Example of what to ask your AI

“Create an agent using a specific container image, with 2 CPU cores and 4GB of memory.”

Want more? Open the sections below.

How to use

The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.

Skill link

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/hosted-agents-v2-py/SKILL.md

Ready-to-paste message

Use this skill to help me: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/hosted-agents-v2-py/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
How it works

You use special code (SDK) to define the agent's setup, its resource needs (CPU, memory), and the tools it can use. Azure then handles running this agent for you.

Installation

Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.

In the terminal (Claude Code, Codex, Cursor), in your project folder:

npx skills add sickn33/agentic-awesome-skills --skill hosted-agents-v2-py

Or download just the file:

curl -L https://raw.githubusercontent.com/sickn33/agentic-awesome-skills/main/plugins/agentic-awesome-skills-claude/skills/hosted-agents-v2-py/SKILL.md -o SKILL.md
Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

Compatibility and maintenance

Primary editorial path for this compatibility group. The instruction-only procedure remains local; no executable support files are bundled so existing installations continue to work offline. This is one shared procedure, not an additional capability. Preserve the callable ID when an existing manifest or client configuration uses it. Modified in AAS on 2026-09-05; original metadata and license notices are retained.

Azure AI Hosted Agents (Python)

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

Installation

pip install 'azure-ai-projects==2.3.0' azure-identity

These are SDK 2.3.0 instruction fragments aligned with the current Microsoft hosted-agent guide. Validate the installed schema and service support before provisioning; documentation inspection is not a cloud integration test.

Environment Variables

export 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 the project identity the registry role supported by its permission mode; current hosted-agent guidance uses Container Registry Repository Reader
  3. Capability Host - Confirm current project/region hosted-agent availability and the application's network policy; do not enable public hosting automatically
  4. SDK Version - Ensure azure-ai-projects==2.3.0

Authentication

Use the approved Azure credential flow for the intended tenant/subscription; this sketch uses DefaultAzureCredential:

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

import os

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

Core Workflow

1. Imports

import os
from azure.identity import DefaultAzureCredential
from azure.ai.projects import AIProjectClient
from azure.ai.projects.models import (
    HostedAgentDefinition,
    ContainerConfiguration,
    ProtocolVersionRecord,
    AgentEndpointProtocol,
)

2. Create Hosted Agent

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

agent = client.agents.create_version(
    agent_name="my-hosted-agent",
    definition=HostedAgentDefinition(
        protocol_versions=[
            ProtocolVersionRecord(protocol=AgentEndpointProtocol.RESPONSES, version="2.0.0")
        ],
        cpu="1",
        memory="2Gi",
        container_configuration=ContainerConfiguration(image=os.environ["REVIEWED_CONTAINER_IMAGE"]),
        environment_variables={
            "AZURE_AI_PROJECT_ENDPOINT": os.environ["AZURE_AI_PROJECT_ENDPOINT"],
            "MODEL_NAME": os.environ["MODEL_DEPLOYMENT_NAME"]
        }
    )
)

print(f"Created agent: {agent.name} (version: {agent.version})")

3. List Agent Versions

versions = client.agents.list_versions(agent_name="my-hosted-agent")
for version in versions:
    print(f"Version: {version.version}")  # Inspect supported status fields via get_version

Inspect the exact returned model for supported fields; a created version is not proof a running container is healthy. Close synchronous client/credential resources through their supported context managers or close() methods.

4. Delete Agent Version

client.agents.delete_version(
    agent_name="my-hosted-agent",
    agent_version=agent.version
)

HostedAgentDefinition Parameters

Parameter Type Required Description
protocol_versions list[ProtocolVersionRecord] Yes Protocol versions the agent supports
container_configuration ContainerConfiguration Yes for an image deployment Reviewed registry image reference
cpu str No CPU allocation (e.g., "1", "2")
memory str No Memory allocation (e.g., "2Gi", "4Gi")
environment_variables dict[str, str] No Environment variables for the container

Protocol Versions

The protocol_versions parameter specifies which protocols your agent supports:

from azure.ai.projects.models import ProtocolVersionRecord, AgentEndpointProtocol

# RESPONSES protocol - standard agent responses

…
FAQ

What is a 'hosted agent'?

It's a program you create that Azure runs for you in a container environment, ready to perform tasks.

Do I need to know how to code to use this?

Yes, you need to write some Python code to set up the agent, but the tool simplifies the process of getting it running on Azure.

Can I make the agent use tools like a code interpreter?

Yes, you can configure the agent to use tools like a code interpreter or other Azure-specific tools.

Details

Original description by the author

Build hosted agents using Azure AI Projects SDK with HostedAgentDefinition. Use when creating container-based agents in Azure AI Foundry.

repo: sickn33/agentic-awesome-skills

Popularity

GitHub stars
48k
Ranking position
#3213
License
MIT
Updated
10/15/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills