Token导航 LogoToken导航TokenDH.com
Azure AI Deployment Manager MCP logo
运维云端stdio官方级别未说明来源级核验

Azure AI Deployment Manager MCP

MCP Server

Azure AI Model Deployment Manager是一个用于管理Azure AI模型部署、监控端点并聚合Azure AI Foundry资源能力的综合解决方案。

工具数

5

提示词数

0

GitHub Stars

0

资源数

0
Python模型管理云端部署

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

1aifanatic

提供方

1aifanatic

最后核验

2026/5/17 20:19

运行时

Python

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

python -m venv venv

详细介绍

Azure AI模型部署管理器-MCP服务器

模型上下文协议(MCP)服务器,用于管理Azure AI模型部署、监控端点和聚合Azure AI Foundry资源中的功能。

概述

Azure AI模型部署管理器为以下方面提供了一个全面的解决方案:

  • 部署模型:使用可配置的SKU和实例计数将AI模型部署到Azure AI Foundry
  • 列表部署:通过按资源组、项目或状态进行筛选来查询所有模型部署
  • 监控端点:实时检查端点运行状况和性能指标
  • 聚合能力:跨多个Azure AI资源聚合和监控AI功能
  • 安全删除:删除具有内置审计跟踪和安全检查的部署

特性

1.模型部署(deploy_model)

  • 将AI模型部署到Azure AI Foundry
  • 配置计算SKU和实例计数
  • 自动生成端点
  • 实时部署跟踪

2.部署列表(list_deployments)

  • 列出跨资源组的所有部署
  • 按资源组、项目或状态筛选
  • 全面的部署细节,包括端点
  • 状态跟踪(运行、停止、失败)

3.端点监控(check_endpoint)

  • 实时端点健康状态
  • 性能指标(响应时间、延迟百分比)
  • 可用性跟踪
  • 请求速率监控

4.能力监控(monitor_capabilities)

  • 汇总各地区的可用模型
  • 监控计算资源(CPU、GPU、内存)
  • 跟踪区域可用性
  • 确定部署机会

5.安全部署删除(delete_deployment)

  • 安全部署删除
  • 审计跟踪日志记录
  • 原因跟踪
  • 防止意外删除

项目结构

azure-ai-deployment-manager/
├── src/
│   ├── __init__.py
│   ├── server.py                 # MCP server implementation
│   ├── tools.py                  # Core deployment management tools
│   ├── config.py                 # Configuration management
│   └── logging_config.py         # Logging setup
├── tests/
│   ├── __init__.py
│   ├── test_tools.py             # Unit tests for tools
│   └── test_server.py            # Unit tests for server
├── logs/                         # Application logs
├── requirements.txt              # Python dependencies
├── host.json                     # Azure Functions configuration
├── local.settings.json           # Local environment configuration
├── .env.example                  # Example environment variables
├── .gitignore
└── README.md                     # This file

先决条件

系统要求

  • Python 3.11或更高版本
  • pip包管理器
  • Git(用于版本控制)

Azure要求

  • Azure 订阅
  • Azure AI Foundry项目
  • 适当的Azure RBAC权限:

- Microsoft.MachineLearning/workspaces/read - Microsoft.MachineLearning/workspaces/write - Microsoft.Authorization/roleAssignments/read

环境设置

确保配置了以下环境变量:

AZURE_SUBSCRIPTION_ID=your-subscription-id
AZURE_RESOURCE_GROUP=your-resource-group
AZURE_PROJECT_NAME=your-ai-project
AZURE_TENANT_ID=your-tenant-id
AZURE_CLIENT_ID=your-service-principal-id
AZURE_CLIENT_SECRET=your-service-principal-secret
AZURE_AI_FOUNDRY_ENDPOINT=https://your-region.inference.ml.azure.com
AZURE_OPENAI_API_KEY=your-api-key

安装

1.克隆存储库

git clone https://github.com/your-org/azure-ai-deployment-manager.git
cd azure-ai-deployment-manager

2.创建虚拟环境

python -m venv venv

# On Windows
venv\Scripts\activate

# On macOS/Linux
source venv/bin/activate

3.安装依赖项

pip install -r requirements.txt

4.配置环境

复制并更新配置文件:

cp local.settings.json.example local.settings.json
# Edit local.settings.json with your Azure credentials

或者创建一个 .env 文件:

cp .env.example .env
# Edit .env with your configuration

本地测试

运行单元测试

# Run all tests
pytest

# Run with coverage
pytest --cov=src tests/

# Run specific test file
pytest tests/test_tools.py -v

# Run specific test
pytest tests/test_tools.py::TestDeploymentManager::test_deploy_model_success -v

测试输出示例

tests/test_tools.py::TestDeploymentManager::test_deploy_model_success PASSED
tests/test_tools.py::TestDeploymentManager::test_list_deployments_all PASSED
tests/test_tools.py::TestDeploymentManager::test_check_endpoint_health PASSED
tests/test_tools.py::TestDeploymentManager::test_delete_deployment PASSED
tests/test_tools.py::TestCapabilityAggregator::test_aggregate_capabilities PASSED

====== 12 passed in 2.34s ======

使用Python进行手动测试

import asyncio
from src.server import MCPServer

async def test_deployment():
    server = MCPServer()
    
    # Deploy a model
    result = await server.handle_tool_call(
        "deploy_model",
        {
            "subscription_id": "test-sub",
            "resource_group": "test-rg",
            "project_name": "test-proj",
            "model_name": "gpt-4",
            "deployment_name": "test-deployment",
            "model_version": "2024-01-01",
            "sku_name": "Standard_DS2_v2",
            "instance_count": 2,
        }
    )
    print(result)

asyncio.run(test_deployment())

使用cURL进行测试

# Start the MCP server
python -m src.server

# In another terminal, send requests
curl -X POST http://localhost:8000/tool_call \
  -H "Content-Type: application/json" \
  -d '{
    "tool": "deploy_model",
    "input": {
      "subscription_id": "test-sub",
      "resource_group": "test-rg",
      "project_name": "test-proj",
      "model_name": "gpt-4",
      "deployment_name": "test-deployment",
      "model_version": "2024-01-01",
      "sku_name": "Standard_DS2_v2"
    }
  }'

用法示例

部署模型

from src.server import MCPServer
import asyncio

async def deploy_example():
    server = MCPServer()
    
    result = await server.handle_tool_call(
        "deploy_model",
        {
            "subscription_id": "abc123def456",
            "resource_group": "my-ai-rg",
            "project_name": "ml-project",
            "model_name": "gpt-4",
            "deployment_name": "gpt4-prod",
            "model_version": "2024-01-15",
            "sku_name": "Standard_DS2_v2",
            "instance_count": 3,
        }
    )
    
    print(f"Deployment Status: {result['deployment']['status']}")
    print(f"Endpoint: {result['deployment']['endpoint']}")

asyncio.run(deploy_example())

列出所有部署

async def list_example():
    server = MCPServer()
    
    result = await server.handle_tool_call(
        "list_deployments",
        {
            "subscription_id": "abc123def456",
            "status_filter": "Running",
        }
    )
    
    print(f"Found {result['count']} running deployments")
    for dep in result['deployments']:
        print(f"  - {dep['name']}: {dep['status']}")

asyncio.run(list_example())

检查端点运行状况

async def health_check_example():
    server = MCPServer()
    
    result = await server.handle_tool_call(
        "check_endpoint",
        {
            "subscription_id": "abc123def456",
            "resource_group": "my-ai-rg",
            "endpoint_name": "gpt4-prod",
            "include_metrics": True,
        }
    )
    
    print(f"Endpoint: {result['endpoint']}")
    print(f"Status: {result['health_status']}")
    print(f"Response Time: {result['details']['response_time_ms']}ms")

asyncio.run(health_check_example())

监控功能

async def capabilities_example():
    server = MCPServer()
    
    result = await server.handle_tool_call(
        "monitor_capabilities",
        {
            "subscription_id": "abc123def456",
            "resource_groups": ["rg1", "rg2", "rg3"],
            "capability_filter": "chat",
        }
    )
    
    caps = result['aggregated_capabilities']
    print(f"Available Models: {len(caps['available_models'])}")
    print(f"Supported Regions: {len(caps['regional_availability'])}")

asyncio.run(capabilities_example())

删除部署

async def delete_example():
    server = MCPServer()
    
    result = await server.handle_tool_call(
        "delete_deployment",
        {
            "subscription_id": "abc123def456",
            "resource_group": "my-ai-rg",
            "project_name": "ml-project",
            "deployment_name": "gpt4-prod",
            "reason": "Cost optimization - consolidating to fewer deployments",
        }
    )
    
    print(f"Deployment deleted")
    print(f"Audit ID: {result['audit_trail']['audit_id']}")
    print(f"Deleted at: {result['audit_trail']['deleted_at']}")

asyncio.run(delete_example())

Azure部署

先决条件

  • 已安装并配置Azure CLI
  • 已安装Azure功能核心工具
  • 适当的Azure权限

部署步骤

  1. 创建功能应用程序
# Create resource group
az group create \
  --name azure-ai-deployment-rg \
  --location eastus

# Create storage account
az storage account create \
  --name storageaccountname \
  --resource-group azure-ai-deployment-rg \
  --location eastus

# Create Function App
az functionapp create \
  --resource-group azure-ai-deployment-rg \
  --consumption-plan-location eastus \
  --runtime python \
  --runtime-version 3.11 \
  --functions-version 4 \
  --name azure-ai-deployment-func \
  --storage-account storageaccountname
  1. 部署代码
# Install Azure Functions Core Tools
npm install -g azure-functions-core-tools@4 --unsafe-perm true

# Deploy
func azure functionapp publish azure-ai-deployment-func --build remote
  1. 配置应用程序设置
az functionapp config appsettings set \
  --name azure-ai-deployment-func \
  --resource-group azure-ai-deployment-rg \
  --settings \
    AZURE_SUBSCRIPTION_ID="your-subscription-id" \
    AZURE_RESOURCE_GROUP="your-resource-group" \
    AZURE_PROJECT_NAME="your-project" \
    AZURE_TENANT_ID="your-tenant-id" \
    AZURE_CLIENT_ID="your-client-id" \
    AZURE_CLIENT_SECRET="your-client-secret"

安全注意事项

身份验证和授权

  1. 服务主体:使用Azure服务主体进行自动化部署
  2. 管理身份:在Azure上运行时利用Azure托管身份
  3. 基于角色的访问控制:实现最小权限访问控制
# Create service principal
az ad sp create-for-rbac --name azure-ai-deployment-manager

秘密管理

  1. Azure密钥库:将敏感凭据存储在密钥库中
  2. 环境变量:使用托管身份而不是存储机密
  3. 旋转:实施定期凭证轮换
# Store secret in Key Vault
az keyvault secret set \
  --vault-name my-keyvault \
  --name api-key \
  --value your-secret-value

网络安全

  1. 虚拟网络:在ViewModel中部署以实现网络隔离
  2. 防火墙规则:配置防火墙限制
  3. 专用端点:为Azure服务使用私有终结点

审计与合规

  1. 审计日志:已登录的所有操作 logs/audit.log
  2. 保留:维护合规期日志
  3. 监控:设置Azure Monitor警报

审核日志条目示例:

2024-01-20 10:30:45,123 - AUDIT - DEPLOYMENT_DELETED: id=abc-123, name=old-deployment, reason=Cost optimization, deleted_by=user@example.com

日志记录

日志级别

该应用程序支持标准日志记录级别:

  • DEBUG:详细的诊断信息
  • INFO:一般信息性消息
  • WARNING:警告信息
  • ERROR:错误消息

日志文件

  • logs/azure_ai_deployment.log:主应用程序日志
  • logs/errors.log:仅错误
  • logs/audit.log:重要业务的审计跟踪

更改日志级别

更新 LOG_LEVEL 在环境配置中:

# In local.settings.json
{
  "Values": {
    "LOG_LEVEL": "DEBUG"
  }
}

故障排除

常见问题

1.身份验证失败

Error: AADSTS700016: Application with identifier 'xxx' was not found in the directory

解决方案:验证Azure凭据和服务主体配置

az ad sp show --id your-client-id

2.超出配额

Error: Quota exceeded for SKU Standard_DS2_v2

解决方案:请求增加配额或使用不同的SKU

# Check current quotas
az vm list-skus --location eastus --output table

3.网络连接

Error: Connection timeout to Azure AI Foundry endpoint

解决方案:检查网络连接和防火墙规则

curl -I https://your-region.inference.ml.azure.com

调试模式

启用调试日志以进行故障排除:

import logging
logging.basicConfig(level=logging.DEBUG)

贡献

欢迎投稿!请遵循以下指南:

  1. 创建要素分支
  2. 添加新功能的测试
  3. 确保所有测试通过
  4. 提交拉取请求

许可证

此项目根据MIT许可证获得许可-有关详细信息,请参阅许可证文件。

支持

对于问题、疑问或贡献:

  • GitHub问题:https://github.com/your-org/azure-ai-deployment-manager/issues
  • 文档:https://docs.microsoft.com/en-us/azure/ai-services/
  • Azure支持:https://azure.microsoft.com/en-us/support/

更新日志

版本1.0.0(2024-01-20)

  • 初始版本
  • 实施了5个核心工具
  • 增加了全面的测试
  • 创建文档
  • 设置GitHub存储库

相关资源

目录标签

目录标签

Python模型管理云端部署AI模型部署本地部署端点监控资源聚合AzureAI

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Python

工具数量(toolCount,工具数)

5

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP