技能 hosted-agents-v2-py
🔧

hosted-agents-v2-py

低风险 ⚙️ 外部命令🌐 网络访问🔑 环境变量

使用 Python 部署 Azure AI 托管代理

使用官方 Projects SDK 简化 Azure 上基于容器的 AI 代理部署。自动化自定义代理环境的配置、扩展和管理,无需手动进行基础设施配置。

支持: Claude Codex Code(CC)
📊 71 充足
1

下载技能 ZIP

2

在 Claude 中上传

前往 设置 → 功能 → 技能 → 上传技能

3

开启并开始使用

测试它

正在使用“hosted-agents-v2-py”。 创建托管代理,使用镜像 'myacr.azurecr.io/processor:v2'、2 个 CPU、4GiB 内存和代码解释器工具

预期结果:

  • 已创建代理:data-processor-agent
  • 版本:3
  • 状态:成功
  • 代理 ID:agent_abc123xyz

正在使用“hosted-agents-v2-py”。 列出代理 'my-hosted-agent' 的所有版本

预期结果:

  • 版本:1,状态:成功,创建时间:2025-01-15T10:30:00Z
  • 版本:2,状态:失败,创建时间:2025-01-16T14:22:00Z
  • 版本:3,状态:成功,创建时间:2025-01-17T09:15:00Z

正在使用“hosted-agents-v2-py”。 删除代理 'my-hosted-agent' 的版本 2

预期结果:

  • 正在删除代理版本...
  • 已成功删除 my-hosted-agent 的版本 2

安全审计

低风险
v1 • 2/25/2026

Static analysis detected 79 potential issues across documentation code examples. After evaluation, all findings are FALSE POSITIVES. The file SKILL.md contains documentation with code examples showing shell commands (pip install, bash scripts) and environment variable access patterns typical for legitimate Azure AI development tutorials. No executable code is present. The 'weak cryptography' findings are false positives from detecting the word 'version' in context. No malicious intent or security risks identified.

1
已扫描文件
327
分析行数
7
发现项
1
审计总数
中风险问题 (2)
Documentation Contains Shell Command Examples
Static analysis detected backtick expressions and shell commands in SKILL.md. These are legitimate documentation examples showing installation commands (pip install) and bash scripts for Azure AI setup. Not executable code, only markdown-formatted tutorials.
Environment Variable Access in Examples
Documentation code examples show os.environ access for Azure endpoint configuration. This is standard practice for Azure SDK authentication patterns. No evidence of credential exfiltration or malicious access.
低风险问题 (2)
Hardcoded URLs in Documentation
Documentation contains legitimate Azure service URLs (services.ai.azure.com, pypi.org, learn.microsoft.com). These are reference links and example endpoints, not malicious network destinations.
False Positive Cryptography Detection
Static analyzer flagged 'weak cryptographic algorithm' at lines mentioning 'version' and 'protocol'. These are false positives from version parameters (e.g., 'v1') and protocol names in documentation text.
审计者: claude

质量评分

38
架构
100
可维护性
87
内容
50
社区
76
安全
100
规范符合性

你能构建什么

数据处理管道代理

部署一个容器化代理,使用代码解释器工具处理大型数据集,并根据工作负载需求自动扩展。

自定义工具集成代理

创建连接到自定义 MCP 服务器和外部 API 的代理,使 Azure AI 基础设施内的专门业务流程自动化成为可能。

开发环境代理

配置具有预配置工具和隔离的开发环境,用于团队协作和快速原型开发。

试试这些提示

基础代理创建
使用 Azure AI Projects SDK 创建托管代理。代理应使用容器镜像 'myregistry.azurecr.io/my-agent:v1.0',需要 2 个 CPU 核心和 4GiB 内存,支持代码解释器工具,并将 MODEL_NAME 环境变量设置为 'gpt-4o-mini'。
多工具代理配置
构建一个同时启用代码解释器和文件搜索工具的代理。连接到标签为 'custom-tools'、位于 'https://tools.example.com' 的 MCP 服务器。分配 1 个 CPU 核心和 2GiB 内存。将 AZURE_AI_PROJECT_ENDPOINT 从您的环境传递给代理。
异步代理部署
使用 azure.ai.projects.aio 中的 AIProjectClient 实现异步代理创建工作流。创建名为 'async-processor' 的代理,使用最小资源(0.5 CPU,1GiB 内存)。使用异步上下文管理器进行适当的资源清理。
生产级部署
创建包含错误处理的生产代理部署脚本。为 ImagePullBackOff 和 InvalidContainerImage 错误包含 try/except 块。创建后记录代理状态。实现清理逻辑以删除超过 30 天的未使用代理版本。

最佳实践

  • 使用特定镜像标签而不是 'latest' 以实现可重现的部署
  • 从最小资源分配开始,根据监控指标进行扩展
  • 将敏感配置存储在 Azure Key Vault 中,通过环境变量引用
  • 为 ImagePullBackOff 等常见故障实施全面的错误处理
  • 定期清理未使用的代理版本以优化资源利用

避免

  • 将密钥或 API 密钥直接硬编码在 environment_variables 字典中
  • 在生产部署中使用 'latest' 镜像标签会导致不可预测的行为
  • 不测试实际使用模式就分配最大资源会导致浪费
  • 跳过 AcrPull 角色权限设置会导致身份验证失败
  • 创建代理版本时没有删除策略会导致未使用资源积累

常见问题

托管代理所需的最低 SDK 版本是什么?
您必须使用 azure-ai-projects 2.0.0b3 或更高版本。早期版本不支持 ImageBasedHostedAgentDefinition 或托管代理 API。
如何向我的代理授予 ACR 拉取权限?
在 Azure 门户中导航到 Azure 容器注册表,转到访问控制 (IAM),并为 AI 项目的托管标识添加 'AcrPull' 角色。
我可以使用来自 Docker Hub 或其他注册表的容器吗?
不可以,托管代理当前需要来自 Azure 容器注册表 (ACR) 的镜像。您必须在创建代理之前将容器镜像构建并推送到 ACR。
如果我的代理超出 CPU 或内存限制会怎样?
如果代理超出分配的资源,将被限制或终止。监控代理的资源使用情况,并使用 cpu 和内存参数相应调整限制。
同步客户端还是异步客户端更适合代理操作?
为简单脚本和一次性操作使用同步客户端。为需要多个并发代理操作的高吞吐量场景使用异步客户端 (azure.ai.projects.aio)。

开发者详情

文件结构

📄 SKILL.md