Communitygithub.com

SamuelChien/mega-skills-collection

Azure AI Foundry에서 사용자 정의 컨테이너 이미지를 기반으로 호스팅된 에이전트를 생성하는 방법을 설명합니다.

mega-skills-collection란 무엇인가요?

이 스킬은 Azure AI Foundry의 ImageBasedHostedAgentDefinition을 사용하여 컨테이너 기반 호스팅 에이전트를 만드는 방법을 설명합니다. Python SDK (azure-ai-projects >= 2.0.0b3)를 기반으로 하며, Azure Container Registry(ACR)에 저장된 사용자 정의 이미지를 사용하여 실행 환경을 완벽히 제어할 수 있습니다. 주요 기능으로는 에이전트 생성, 버전 관리, 삭제, CPU/메모리 할당, 코드 인터프리터나 MCP 서버 같은 도구 연결, 환경 변수 설정 등을 지원합니다. 비동기(async) 패턴도 포함되어 있어 대규모 워크로드에 유연하게 대응할 수 있습니다. 팀이 Azure AI Foundry에서 표준화된 에이전트 인프라를 구축할 때 특히 유용합니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/SamuelChien/mega-skills-collection/tree/HEAD/agents-v2-py

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

Azure AI 호스팅 에이전트 (Python)

ImageBasedHostedAgentDefinition을 사용하여 컨테이너 기반 호스팅 에이전트를 구축합니다.

설치

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

최소 SDK 버전: 호스팅 에이전트 지원을 위해 2.0.0b3 이상이 필요합니다.

환경 변수

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

사전 조건

호스팅 에이전트를 생성하기 전에 다음을 확인하세요:

  1. 컨테이너 이미지 - 빌드하여 Azure Container Registry (ACR)에 푸시
  2. ACR 풀 권한 - 프로젝트의 관리 ID에 ACR의 AcrPull 역할 부여
  3. Capability Host - enablePublicHostingEnvironment=true로 설정된 계정 수준의 Capability Host
  4. SDK 버전 - azure-ai-projects>=2.0.0b3 확인

인증

항상 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
)

핵심 워크플로우

1. 임포트

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

2. 호스팅 에이전트 생성

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="v1")
        ],
        cpu="1",
        memory="2Gi",
        image="myregistry.azurecr.io/my-agent:latest",
        tools=[{"type": "code_interpreter"}],
        environment_variables={
            "AZURE_AI_PROJECT_ENDPOINT": os.environ["AZURE_AI_PROJECT_ENDPOINT"],
            "MODEL_NAME": "gpt-4o-mini"
        }
    )
)

print(f"에이전트 생성 완료: {agent.name} (버전: {agent.version})")

3. 에이전트 버전 목록 보기

versions = client.agents.list_versions(agent_name="my-hosted-agent")
for version in versions:
    print(f"버전: {version.version}, 상태: {version.state}")

4. 에이전트 버전 삭제

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

ImageBasedHostedAgentDefinition 매개변수

매개변수타입필수설명
container_protocol_versionslist[ProtocolVersionRecord]예에이전트가 지원하는 프로토콜 버전
imagestr예전체 컨테이너 이미지 경로 (registry/image:tag)
cpustr아니요CPU 할당 (예: "1", "2")
memorystr아니요메모리 할당 (예: "2Gi", "4Gi")
toolslist[dict]아니요에이전트에 사용할 수 있는 도구
environment_variablesdict[str, str]아니요컨테이너를 위한 환경 변수

프로토콜 버전

container_protocol_versions 매개변수는 에이전트가 지원하는 프로토콜을 지정합니다:

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

# RESPONSES 프로토콜 - 표준 에이전트 응답
container_protocol_versions=[
    ProtocolVersionRecord(protocol=AgentProtocol.RESPONSES, version="v1")
]

사용 가능한 프로토콜:

프로토콜설명
AgentProtocol.RESPONSES에이전트 상호작용을 위한 표준 응답 프로토콜

리소스 할당

컨테이너에 CPU와 메모리를 지정합니다:

definition=ImageBasedHostedAgentDefinition(
    container_protocol_versions=[...],
    image="myregistry.azurecr.io/my-agent:latest",
    cpu="2",      # 2 CPU 코어
    memory="4Gi"  # 4 GiB 메모리
)

리소스 제한:

리소스최소최대기본값
CPU0.541
메모리1Gi8Gi2Gi

도구 구성

호스팅 에이전트에 도구를 추가합니다:

코드 인터프리터

tools=[{"type": "code_interpreter"}]

MCP 도구

tools=[
    {"type": "code_interpreter"},
    {
        "type": "mcp",
        "server_label": "my-mcp-server",
        "server_url": "https://my-mcp-server.example.com"
    }
]

여러 도구

tools=[
    {"type": "code_interpreter"},
    {"type": "file_search"},
    {
        "type": "mcp",
        "server_label": "custom-tool",
        "server_url": "https://custom-tool.example.com"
    }
]

환경 변수

컨테이너에 구성을 전달합니다:

environment_variables={
    "AZURE_AI_PROJECT_ENDPOINT": os.environ["AZURE_AI_PROJECT_ENDPOINT"],
    "MODEL_NAME": "gpt-4o-mini",
    "LOG_LEVEL": "INFO",
    "CUSTOM_CONFIG": "value"
}

모범 사례: 비밀을 하드코딩하지 마세요. 환경 변수나 Azure Key Vault를 사용하세요.

전체 예제

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():
    """사용자 정의 컨테이너 이미지로 호스팅 에이전트를 생성합니다."""
    
    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"호스팅 에이전트 생성 완료: {agent.name}")
    print(f"버전: {agent.version}")
    print(f"상태: {agent.state}")
    
    return agent

if __name__ == "__main__":
    create_hosted_agent()

비동기 패턴

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():
    """비동기적으로 호스팅 에이전트를 생성합니다."""
    
    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

일반적인 오류

오류원인해결 방법
ImagePullBackOffACR 풀 권한 거부됨프로젝트의 관리 ID에 AcrPull 역할 부여
InvalidContainerImage이미지를 찾을 수 없음이미지 경로와 태그가 ACR에 있는지 확인
CapabilityHostNotFoundCapability Host가 구성되지 않음계정 수준의 Capability Host 생성
ProtocolVersionNotSupported유효하지 않은 프로토콜 버전AgentProtocol.RESPONSES와 버전 "v1" 사용

모범 사례

  1. 이미지 버전 관리 - 프로덕션에서는 latest 대신 특정 태그 사용
  2. 최소 리소스 - 최소 CPU/메모리로 시작하고 필요에 따라 확장
  3. 환경 변수 - 모든 구성에 사용하고 절대 하드코딩하지 않음
  4. 오류 처리 - 에이전트 생성을 try/except 블록으로 감싸기
  5. 정리 - 사용하지 않는 에이전트 버전을 삭제하여 리소스 확보

참고 링크

사용 시기

이 스킬은 개요에 설명된 워크플로우 또는 작업을 실행할 때 적용됩니다.

제한 사항

  • 이 스킬은 작업이 위에서 설명한 범위와 명확하게 일치하는 경우에만 사용하십시오.
  • 출력물을 환경별 검증, 테스트 또는 전문가 검토의 대체 수단으로 취급하지 마십시오.
  • 필요한 입력, 권한, 안전 경계 또는 성공 기준이 누락된 경우 중단하고 명확히 요청하십시오.

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

SamuelChien/mega-skills-collection

Security audit, hardening, threat modeling (STRIDE/PASTA), Red/Blue Team, OWASP checks, code review, incident response, and infrastructure security for any project.

SamuelChien/mega-skills-collection

Arquitecto de Soluciones Principal y Consultor Tecnológico de Andru.ia. Diagnostica y traza la hoja de ruta óptima para proyectos de IA en español.

SamuelChien/mega-skills-collection

Ingeniero de Sistemas de Andru.ia. Diseña, redacta y despliega nuevas habilidades (skills) dentro del repositorio siguiendo el Estándar de Diamante.

SamuelChien/mega-skills-collection

Estratega de Inteligencia de Dominio de Andru.ia. Analiza el nicho específico de un proyecto para inyectar conocimientos, regulaciones y estándares únicos del sector. Actívalo tras definir el nicho.

SamuelChien/mega-skills-collection

2D game development principles. Sprites, tilemaps, physics, camera.

SamuelChien/mega-skills-collection

3D game development principles. Rendering, shaders, physics, cameras.

SamuelChien/mega-skills-collection

Expert in building 3D experiences for the web - Three.js, React Three Fiber, Spline, WebGL, and interactive 3D scenes. Covers product configurators, 3D portfolios, immersive websites, and bringing depth to web experiences.

SamuelChien/mega-skills-collection

Accessibility audit skill for scanning, fixing, and verifying WCAG 2.2 Level A and AA compliance across React, Next.js, Vue, Angular, Svelte, and plain HTML codebases. Use when auditing accessibility, fixing a11y violations, checking color contrast, generating compliance reports, or integrating accessibility checks into CI/CD pipelines.

SamuelChien/mega-skills-collection

Ab Test Analyzer - Auto-activating skill for Data Analytics. Triggers on: ab test analyzer, ab test analyzer Part of the Data Analytics skill category.

SamuelChien/mega-skills-collection

A B Test Config Creator - Auto-activating skill for ML Deployment. Triggers on: a b test config creator, a b test config creator Part of the ML Deployment skill category.

SamuelChien/mega-skills-collection

When the user wants to plan, design, or implement an A/B test or experiment. Also use when the user mentions "A/B test," "split test," "experiment," "test this change," "variant copy," "multivariate test," "hypothesis," "conversion experiment," "statistical significance," or "test this." For tracking implementation, see analytics-tracking.

SamuelChien/mega-skills-collection

Acceptance Criteria Creator - Auto-activating skill for Enterprise Workflows. Triggers on: acceptance criteria creator, acceptance criteria creator Part of the Enterprise Workflows skill category.

SamuelChien/mega-skills-collection

Use when a coding task should be driven end-to-end from issue intake through implementation, review, deployment, and acceptance verification with minimal human re-intervention.

SamuelChien/mega-skills-collection

Accessibility Audit Runner - Auto-activating skill for Frontend Development. Triggers on: accessibility audit runner, accessibility audit runner Part of the Frontend Development skill category.

SamuelChien/mega-skills-collection

You are an accessibility expert specializing in WCAG compliance, inclusive design, and assistive technology compatibility. Conduct audits, identify barriers, and provide remediation guidance.

SamuelChien/mega-skills-collection

Web accessibility patterns for WCAG 2.2 compliance including ARIA, keyboard navigation, screen readers, and testing

SamuelChien/mega-skills-collection

Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed, or change policy for the Discord channel.

SamuelChien/mega-skills-collection

Create unified specification packages across Business, Development, and Design teams. Staged elaboration (L0 Vision → L1 Requirements → L2 Team Detail → L3 Acceptance Criteria) to build shared understanding. Does not write code.

SamuelChien/mega-skills-collection

Research a company or person and get actionable sales intel. Works standalone with web search, supercharged when you connect enrichment tools or your CRM. Trigger with "research [company]", "look up [person]", "intel on [prospect]", "who is [name] at [company]", or "tell me about [company]".

SamuelChien/mega-skills-collection

Validate messaging consistency across website, GitHub repos, and local documentation generating read-only discrepancy reports. Use when checking content alignment or finding mixed messaging. Trigger with phrases like "check consistency", "validate documentation", or "audit messaging".

관련 스킬