Skip to main content 홈 크리에이터 beko2210 firstbrain agents-v2-py
agents-v2-py Build container-based Foundry Agents with Azure AI Projects SDK (ImageBasedHostedAgentDefinition). Use when creating hosted agents with custom container images in Azure AI Foundry.
설치로 이동 Skills Marketplace 커뮤니티가 만든 AI 스킬을 발견하고 탐색하세요.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/BEKO2210/Firstbrain --skill agents-v2-py명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
Zip 다운로드 다운로드 중... 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. type skill created 2026-02-27T00:00:00.000Z domain productivity category developer-experience risk unknown source community tags ["skill","productivity","developer-experience","agents"]
Azure AI Hosted Agents (Python)
Build container-based hosted agents using ImageBasedHostedAgentDefinition from the Azure AI Projects SDK.
Installation
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
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 your project's managed identity AcrPull role on the ACR
Capability Host - Account-level capability host with enablePublicHostingEnvironment=true
SDK Version - Ensure azure-ai-projects>=2.0.0b3
Authentication
Always use DefaultAzureCredential:
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
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
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_versions=[
ProtocolVersionRecord(protocol=AgentProtocol.RESPONSES, version= )
],
cpu= ,
memory= ,
image= ,
tools=[{ : }],
environment_variables={
: os.environ[ ],
:
}
)
)
( )
"v1"
"1"
"2Gi"
"myregistry.azurecr.io/my-agent:latest"
"type"
"code_interpreter"
"AZURE_AI_PROJECT_ENDPOINT"
"AZURE_AI_PROJECT_ENDPOINT"
"MODEL_NAME"
"gpt-4o-mini"
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} , State: {version.state} " )
4. Delete Agent Version client.agents.delete_version(
agent_name="my-hosted-agent" ,
version=agent.version
)
ImageBasedHostedAgentDefinition Parameters Parameter Type Required Description container_protocol_versionslist[ProtocolVersionRecord]Yes Protocol versions the agent supports imagestrYes Full container image path (registry/image:tag) cpustrNo CPU allocation (e.g., "1", "2") memorystrNo Memory allocation (e.g., "2Gi", "4Gi") toolslist[dict]No Tools available to the agent environment_variablesdict[str, str]No Environment variables for the container
Protocol Versions The container_protocol_versions parameter specifies which protocols your agent supports:
from azure.ai.projects.models import ProtocolVersionRecord, AgentProtocol
container_protocol_versions=[
ProtocolVersionRecord(protocol=AgentProtocol.RESPONSES, version="v1" )
]
Protocol Description AgentProtocol.RESPONSESStandard response protocol for agent interactions
Resource Allocation Specify CPU and memory for your container:
definition=ImageBasedHostedAgentDefinition(
container_protocol_versions=[...],
image="myregistry.azurecr.io/my-agent:latest" ,
cpu="2" ,
memory="4Gi"
)
Resource Min Max Default CPU 0.5 4 1 Memory 1Gi 8Gi 2Gi
Tools Configuration Add tools to your hosted agent:
Code Interpreter tools=[{"type" : "code_interpreter" }]
MCP Tools tools=[
{"type" : "code_interpreter" },
{
"type" : "mcp" ,
"server_label" : "my-mcp-server" ,
"server_url" : "https://my-mcp-server.example.com"
}
]
Multiple Tools tools=[
{"type" : "code_interpreter" },
{"type" : "file_search" },
{
"type" : "mcp" ,
"server_label" : "custom-tool" ,
"server_url" : "https://custom-tool.example.com"
}
]
Environment Variables Pass configuration to your container:
environment_variables={
"AZURE_AI_PROJECT_ENDPOINT" : os.environ["AZURE_AI_PROJECT_ENDPOINT" ],
"MODEL_NAME" : "gpt-4o-mini" ,
"LOG_LEVEL" : "INFO" ,
"CUSTOM_CONFIG" : "value"
}
Best Practice: Never hardcode secrets. Use environment variables or Azure Key Vault.
Complete Example import os
from azure.identity import DefaultAzureCredential
from azure.ai.projects import AIProjectClient
from azure.ai.projects.models import (
ImageBasedHostedAgentDefinition,
ProtocolVersionRecord,
AgentProtocol,
)
def create_hosted_agent ():
"""Create a hosted agent with custom container image."""
client = AIProjectClient(
endpoint=os.environ["AZURE_AI_PROJECT_ENDPOINT" ],
credential=DefaultAzureCredential()
)
agent = client.agents.create_version(
agent_name="data-processor-agent" ,
definition=ImageBasedHostedAgentDefinition(
container_protocol_versions=[
ProtocolVersionRecord(
protocol=AgentProtocol.RESPONSES,
version="v1"
)
],
image="myregistry.azurecr.io/data-processor:v1.0" ,
cpu="2" ,
memory="4Gi" ,
tools=[
{"type" : "code_interpreter" },
{"type" : "file_search" }
],
environment_variables={
"AZURE_AI_PROJECT_ENDPOINT" : os.environ["AZURE_AI_PROJECT_ENDPOINT" ],
"MODEL_NAME" : "gpt-4o-mini" ,
"MAX_RETRIES" : "3"
}
)
)
print (f"Created hosted agent: {agent.name} " )
print (f"Version: {agent.version} " )
print (f"State: {agent.state} " )
return agent
if __name__ == "__main__" :
create_hosted_agent()
Async Pattern import os
from azure.identity.aio import DefaultAzureCredential
from azure.ai.projects.aio import AIProjectClient
from azure.ai.projects.models import (
ImageBasedHostedAgentDefinition,
ProtocolVersionRecord,
AgentProtocol,
)
async def create_hosted_agent_async ():
"""Create a hosted agent asynchronously."""
async with DefaultAzureCredential() as credential:
async with AIProjectClient(
endpoint=os.environ["AZURE_AI_PROJECT_ENDPOINT" ],
credential=credential
) as client:
agent = await client.agents.create_version(
agent_name="async-agent" ,
definition=ImageBasedHostedAgentDefinition(
container_protocol_versions=[
ProtocolVersionRecord(
protocol=AgentProtocol.RESPONSES,
version="v1"
)
],
image="myregistry.azurecr.io/async-agent:latest" ,
cpu="1" ,
memory="2Gi"
)
)
return agent
Common Errors Error Cause Solution ImagePullBackOffACR pull permission denied Grant AcrPull role to project's managed identity InvalidContainerImageImage not found Verify image path and tag exist in ACR CapabilityHostNotFoundNo capability host configured Create account-level capability host ProtocolVersionNotSupportedInvalid protocol version Use AgentProtocol.RESPONSES with version "v1"
Best Practices
Version Your Images - Use specific tags, not latest in production
Minimal Resources - Start with minimum CPU/memory, scale up as needed
Environment Variables - Use for all configuration, never hardcode
Error Handling - Wrap agent creation in try/except blocks
Cleanup - Delete unused agent versions to free resources
Reference Links
When to Use This skill is applicable to execute the workflow or actions described in the overview.
Connections
Domain: [[Produktivitaet & Werkzeuge]]
Kategorie: [[Developer Experience]]
Navigation: [[Skills Uebersicht]], [[Home]]