agents-v2-py
Helps build container-based AI agents in Azure AI Foundry. Useful for creating hosted agents with custom container images.
What it does
This tool lets you create AI 'agents' that run inside containers, using specific Python code. It's for those who want more control over how the agent works internally.
When to use it
- ✓When you have agent code ready in a container.
- ✓When you need to set resources like CPU and memory for the agent.
- ✓To manage different versions of your AI agent.
Example of what to ask your AI
“How do I create a hosted AI agent with my container image?”
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
Ready-to-paste message
How it works
You use Python code with the 'azure-ai-projects' library to define the agent. This includes specifying the container image, resources (CPU/memory), and necessary environment variables for the agent to run.
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 agents-v2-pyOr download just the file:
curl -L https://raw.githubusercontent.com/sickn33/agentic-awesome-skills/main/plugins/agentic-awesome-skills-claude/skills/agents-v2-py/SKILL.md -o SKILL.mdTechnical content (original SKILL.md)
Original text by the author, straight from GitHub.
Compatibility and maintenance
Compatibility alias of hosted-agents-v2-py; use that ID for new references when no existing contract requires this one. The instruction-only procedure remains local; no executable support files are bundled so existing installations
continue to work offline. This compatibility guide documents the hosted-agent procedure, not an additional capability; older copies may use retired preview names.
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:
- Container Image - Build and push to Azure Container Registry (ACR)
- ACR Pull Permissions - Grant the project identity the registry role supported by its permission mode; current hosted-agent guidance uses Container Registry Repository Reader
- Capability Host - Confirm current project/region hosted-agent availability and the application's network policy; do not enable public hosting automatically
- 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
…
FAQ
What is a 'hosted agent'?
It's an AI program that runs in an isolated environment (a container) in the cloud, ready to receive instructions.
Do I need to know Python to use this?
Yes, this process involves writing and running Python code to set up the agent.
What is a 'container'?
Think of a container as a package that holds everything a program needs to run, ensuring it works the same way everywhere.
Details
Original description by the author
Build container-based Foundry Agents with Azure AI Projects SDK (HostedAgentDefinition). Use when creating hosted agents with custom container images in Azure AI Foundry.
Popularity
- GitHub stars
- 48k
- Ranking position
- #2077
- License
- MIT
- Updated
- 10/15/2026
Comments
- …
More skills from this repository
00-andruia-consultant
Helps your agent start or improve AI projects. It analyzes code, suggests tools, and creates action plans in Spanish.
sickn33/agentic-awesome-skills
007
Lets your agent perform security audits and threat modeling. It's useful for protecting projects against attacks and vulnerabilities.
sickn33/agentic-awesome-skills
10-andruia-skill-smith
Helps your agent create or improve AI tools. It defines how tools work, writes documentation, and validates the structure.
sickn33/agentic-awesome-skills
20-andruia-niche-intelligence
Lets your agent create a summary about a specific industry. It's useful for understanding the context, rules, usage patterns, and risks of a project, using reliable sources.
sickn33/agentic-awesome-skills
Similar skills
agent-architecture-audit
Makes your agent check if everything is working correctly. It finds and fixes problems in AI systems, ensuring they perform as expected.
affaan-m/ECC
agent-eval
Helps your agent compare different AI coding tools. It measures which one is faster, cheaper, and more reliable for specific tasks.
affaan-m/ECC
agent-harness-construction
Makes your agent better understand how to perform tasks. It optimizes the tools and instructions the agent uses to increase its chances of success.
affaan-m/ECC