关于 azure-ml-foundry-workspace
面向 Azure Machine Learning Workspace 和 Azure AI Foundry 工程师及管理员的详细参考,涵盖工作区架构、网络、计算、部署、身份管理、命令行与 PowerShell、Terraform 和故障排查。
主要功能
- 01工作区架构与网络
- 02计算选项和终结点部署
- 03身份、存储与容器注册表指导
- 04az ml 命令行与 PowerShell 参考
- 05Terraform 资源配置指导
- 06日志与故障排查
适用场景
- 01规划工作区的专用网络
- 02为训练或推理选择计算资源
- 03部署在线或批量模型终结点
- 04使用 Terraform 自动配置工作区基础设施
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ josiahsiegel/ claude-plugin-marketplace --skill azure-ml-foundry-workspace安装后在 Claude Code 中输入/azure-ml-foundry-workspace确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
references/cli-powershell.mdcompute.mdendpoints.mdidentities-acr-storage.mdnetworking.mdterraform.mdtroubleshooting.md详细介绍
Azure Machine Learning Workspace / Azure AI Foundry - 完整深度参考
有关 Azure Machine Learning Workspace(Azure AI Foundry)各方面的权威参考,包括架构、网络、专用终结点、计算群集、终结点部署、托管标识、ACR 集成、存储帐户、所有 CLI 和 PowerShell 命令、日志读取、调试以及 Terraform 集成。
1. 架构和核心概念
Workspace 资源层级
Azure Subscription
└── Resource Group
├── Azure ML Workspace (Microsoft.MachineLearningServices/workspaces)
│ ├── Dependent Resources (auto-created or BYO)
│ │ ├── Azure Storage Account (default datastore)
│ │ ├── Azure Key Vault (secrets, connection strings)
│ │ ├── Azure Application Insights (telemetry)
│ │ └── Azure Container Registry (Docker images for environments)
│ ├── Compute Targets
│ │ ├── Compute Instances (dev/test VMs)
│ │ ├── Compute Clusters (AmlCompute - training)
│ │ ├── Serverless Compute (on-demand)
│ │ ├── Kubernetes Compute (AKS / Arc-enabled)
│ │ └── Attached Compute (Databricks, HDInsight, VMs)
│ ├── Data Assets (versioned references to data)
│ ├── Datastores (connections to storage)
│ ├── Environments (Docker + conda specs)
│ ├── Models (registered trained models)
│ ├── Endpoints
│ │ ├── Managed Online Endpoints (real-time)
│ │ ├── Kubernetes Online Endpoints (BYO infra)
│ │ ├── Batch Endpoints (large-scale scoring)
│ │ └── Serverless Endpoints (MaaS - pay-per-token)
│ ├── Jobs (training runs, pipelines, sweeps)
│ ├── Components (reusable pipeline steps)
│ ├── Schedules (recurring job triggers)
│ └── Registries (cross-workspace sharing)
└── AI Foundry Hub (kind=hub) + Projects (kind=project)
AI Foundry 中心/项目与经典 Workspace
| 功能 | 经典 Workspace(kind=Default) | AI Foundry 中心 + 项目 |
|---|---|---|
| 门户 | ml.azure.com | ai.azure.com |
| 范围 | 单个 Workspace | 中心在多个项目间共享基础架构 |
| 网络 | 按 Workspace 配置 | 中心级别(在多个项目间共享) |
| 标识 | 按 Workspace 配置 | 中心级别标识,项目继承 |
| 模型目录 | 是 | 是,另含更多 Foundry 模型 |
| 提示流 | 是 | 是 |
| AI Agent | 有限 | 完整的 AI Agent Service |
| 使用场景 | 经典机器学习、自定义训练 | 生成式 AI、大模型应用、AI Agent |
创建 Workspace 的所有方法
CLI:
# Install/upgrade ML extension
az extension add --name ml --upgrade
# Create resource group
az group create --name ml-rg --location eastus
# Create workspace with all dependencies auto-created
az ml workspace create \
--name my-ml-workspace \
--resource-group ml-rg \
--location eastus
# Create workspace with explicit dependencies
az ml workspace create \
--name my-ml-workspace \
--resource-group ml-rg \
--location eastus \
--storage-account /subscriptions/<sub>/resourceGroups/ml-rg/providers/Microsoft.Storage/storageAccounts/mlstorage \
--key-vault /subscriptions/<sub>/resourceGroups/ml-rg/providers/Microsoft.KeyVault/vaults/mlkeyvault \
--app-insights /subscriptions/<sub>/resourceGroups/ml-rg/providers/Microsoft.Insights/components/mlinsights \
--container-registry /subscriptions/<sub>/resourceGroups/ml-rg/providers/Microsoft.ContainerRegistry/registries/mlacr \
--public-network-access Disabled \
--managed-network AllowInternetOutbound \
--image-build-compute cpu-build-cluster \
--enable-data-isolation true \
--tags Environment=Production Team=DataScience
# Create AI Foundry Hub
az ml workspace create \
--name my-ai-hub \
--resource-group ml-rg \
--location eastus \
--kind hub \
--storage-account aihubstorage \
--key-vault aihubkeyvault
# Create AI Foundry Project within Hub
az ml workspace create \
--name my-ai-project \
--resource-group ml-rg \
--location eastus \
--kind project \
--hub-id /subscriptions/<sub>/resourceGroups/ml-rg/providers/Microsoft.MachineLearningServices/workspaces/my-ai-hub
# Show workspace details
az ml workspace show \
--name my-ml-workspace \
--resource-group ml-rg
# List all workspaces
az ml workspace list \
--resource-group ml-rg \
--output table
# Update workspace
az ml workspace update \
--name my-ml-workspace \
--resource-group ml-rg \
--description "Updated workspace" \
--public-network-access Disabled
# Delete workspace
az ml workspace delete \
--name my-ml-workspace \
--resource-group ml-rg \
--permanently-delete --all-resources
# Diagnose workspace configuration
az ml workspace diagnose \
--name my-ml-workspace \
--resource-group ml-rg
PowerShell(Az.MachineLearningServices):
# Install the module
Install-Module -Name Az.MachineLearningServices -Scope CurrentUser -Repository PSGallery -Force
# Create workspace
New-AzMLWorkspace `
-Name "my-ml-workspace" `
-ResourceGroupName "ml-rg" `
-Location "eastus" `
-StorageAccountId "/subscriptions/<sub>/resourceGroups/ml-rg/providers/Microsoft.Storage/storageAccounts/mlstorage" `
-KeyVaultId "/subscriptions/<sub>/resourceGroups/ml-rg/providers/Microsoft.KeyVault/vaults/mlkeyvault" `
-ApplicationInsightId "/subscriptions/<sub>/resourceGroups/ml-rg/providers/Microsoft.Insights/components/mlinsights" `
-IdentityType "SystemAssigned" `
-PublicNetworkAccess "Disabled"
# Get workspace
Get-AzMLWorkspace -Name "my-ml-workspace" -ResourceGroupName "ml-rg"
# List workspaces
Get-AzMLWorkspace -ResourceGroupName "ml-rg"
# Update workspace
Update-AzMLWorkspace `
-Name "my-ml-workspace" `
-ResourceGroupName "ml-rg" `
-Description "Updated workspace" `
-Tag @{Environment="Production"}
# Remove workspace
Remove-AzMLWorkspace -Name "my-ml-workspace" -ResourceGroupName "ml-rg"
# Diagnose workspace
Invoke-AzMLWorkspaceDiagnose -Name "my-ml-workspace" -ResourceGroupName "ml-rg"
2. 网络
Azure ML 支持三种托管网络隔离模式(Disabled、AllowInternetOutbound、AllowOnlyApprovedOutbound),建议在生产环境中使用托管 VNet 方案。专用终结点提供入站连接,出站规则则控制计算资源的流量出口。
关键 DNS 区域
| 服务 | 专用 DNS 区域 |
|---|---|
| ML Workspace API | privatelink.api.azureml.ms |
| ML Notebooks | privatelink.notebooks.azure.net |
| Storage Blob | privatelink.blob.core.windows.net |
| Storage File | privatelink.file.core.windows.net |
| Key Vault | privatelink.vaultcore.azure.net |
| Container Registry | privatelink.azurecr.io |
| Application Insights | privatelink.monitor.azure.com |
关键服务标记
| 服务标记 | 用途 |
|---|---|
| AzureMachineLearning | ML Workspace 管理(入站 44224,出站 443) |
| BatchNodeManagement | 计算群集管理(入站 29876-29877) |
| Storage | 访问 Azure Storage(出站 443) |
| AzureActiveDirectory | 身份验证(出站 443) |
有关完整的 VNet 配置、专用终结点设置、NSG 规则和出站规则管理,请参阅 references/networking.md。
3. 计算
Azure ML 提供多种计算目标:用于开发/测试的计算实例、用于可扩展训练的 AmlCompute 群集、无需管理群集即可按需运行作业的无服务器计算,以及适用于 BYO 基础架构场景的 Kubernetes 计算。
GPU VM SKU 快速参考
| VM 系列 | GPU | GPU 内存 | 使用场景 |
|---|---|---|---|
| Standard_NC24ads_A100_v4 | 1x A100 | 80 GB | 训练、微调 |
| Standard_ND96amsr_A100_v4 | 8x A100 80GB | 640 GB | 大模型训练 |
| Standard_ND_H100_v5 | 8x H100 | 640 GB | 生成式 AI、大模型训练 |
| Standard_ND_H200_v5 | 8x H200 | 1120 GB | 最新型号:性能是 H100 的 2 倍 |
| Standard_NCads_H100_v5 | 1x H100 NVL | 94 GB | 推理、微调 |
| Standard_NC4as_T4_v3 | 1x T4 | 16 GB | 经济型推理 |
有关完整的 GPU SKU 表、计算实例/群集 CLI 参考、无服务器计算、Kubernetes 附加和调试命令,请参阅 references/compute.md。
4. 终结点部署
Azure ML 支持四种终结点类型:托管联机终结点(推荐用于支持蓝绿部署的实时推理)、批处理终结点(在计算群集上进行大规模评分)、Kubernetes 联机终结点(使用自带的 AKS/Arc 基础架构),以及无服务器终结点(按令牌计费的模型即服务)。
终结点类型快速参考
| 类型 | 用例 | 身份验证模式 | 扩展 |
|---|---|---|---|
| 托管在线 | 实时推理 | key, aml_token | 按部署实例数扩展 |
| 批处理 | 大规模评分 | 托管标识 | 计算群集自动扩展 |
| Kubernetes 在线 | BYO 基础设施实时处理 | key, aml_token | K8s Pod 扩展 |
| 无服务器(MaaS) | 按 Token 付费的大模型 | key | 自动 |
有关完整的终结点创建、部署、流量拆分、日志检索和批量调用命令,请参阅 references/endpoints.md。
5-7. 标识、ACR 和存储
托管标识(系统分配或用户分配)用于控制工作区、计算资源、终结点和依赖资源之间的访问。ACR 用于存储环境和模型服务的 Docker 镜像。使用专用终结点需要 Premium SKU;如果位于 VNet 后方,还需要镜像生成计算群集。存储帐户作为 Blob、文件共享、作业输出和 MLflow 工件的默认数据存储。
标识类型
| 标识类型 | 用例 |
|---|---|
| 系统分配(工作区) | 默认工作区操作、自动生命周期管理 |
| 用户分配(工作区) | CMK 加密、跨资源共享 |
| 系统分配(计算资源) | 按群集配置的存储/ACR 访问 |
| 用户分配(计算资源) | 精细化、可重复使用的访问控制 |
关键 RBAC 角色
| 角色 | 说明 |
|---|---|
| AzureML Data Scientist | 运行作业、管理计算资源、部署模型 |
| AzureML Compute Operator | 创建/管理计算资源 |
| Azure AI Developer | AI Foundry 项目开发 |
| Azure AI Inference Deployment Operator | 将模型部署到终结点 |
有关完整的标识配置、角色分配命令、ACR 集成、专用 ACR 设置、数据存储注册和存储帐户详情,请参阅 references/identities-acr-storage.md。
8-9. CLI 和 POWERSHELL
az ml CLI 扩展通过 20 多个命令组提供全面的工作区管理功能,涵盖工作区、计算资源、作业、模型、终结点、环境、数据、数据存储、组件、计划、注册表和连接。Az.MachineLearningServices PowerShell 模块为 Windows 原生自动化提供同等功能。
关键 az ml 命令组
| 命令组 | 用途 |
|---|---|
az ml workspace | 管理工作区(创建、诊断、provision-network、outbound-rule) |
az ml compute | 管理计算资源(创建、启动、停止、connect-ssh、附加) |
az ml job | 管理作业(创建、流式传输、取消、下载) |
az ml online-endpoint | 管理在线终结点(创建、调用、get-credentials) |
az ml online-deployment | 管理部署(创建、get-logs、traffic) |
az ml batch-endpoint | 管理批处理终结点(创建、调用、list-jobs) |
az ml serverless-endpoint | 管理无服务器终结点(创建、get-credentials) |
有关完整的命令参考、作业管理深入介绍、计划管理和完整的 PowerShell cmdlet 参考,请参阅 references/cli-powershell.md。
10. TERRAFORM 集成
可以使用 azurerm 提供程序通过 Terraform 全面预配 Azure ML 工作区。生产环境设置包括工作区、VNet/子网、NSG、存储帐户、Key Vault、ACR、Application Insights、专用终结点、DNS 区域、计算群集和 RBAC 角色分配。
关键 Terraform 资源
| 资源 | 用途 |
|---|---|
azurerm_machine_learning_workspace | ML 工作区(Default、Hub、Project) |
azurerm_machine_learning_compute_cluster | AmlCompute 训练群集 |
azurerm_machine_learning_compute_instance | 开发/测试计算实例 |
azurerm_machine_learning_workspace_network_outbound_rule_* | 托管网络出站规则 |
完整的、可用于生产环境的 Terraform 配置(提供程序、网络、存储、密钥保管库、ACR、工作区、计算、角色分配和输出)请参阅 references/terraform.md。
11. 故障排除与调试
Azure ML 提供多种调试方式:实时作业日志流、部署容器日志(推理服务器和存储初始化程序)、用于系统级诊断的计算实例 SSH 访问、用于历史分析的 Log Analytics 查询,以及用于配置验证的 az ml workspace diagnose 命令。
常见错误类别
| 类别 | 常见错误 |
|---|---|
| 计算 | QuotaExceeded、AllocationFailed、磁盘已满、未检测到 GPU |
| 终结点 | ScoringError、HealthCheckFailure、ImageBuildFailed、429/503 错误 |
| 网络 | DNS 解析失败、连接超时、存储/ACR 访问被拒绝 |
| 作业 | EnvironmentBuildError、OutOfMemoryError、NCCL 超时、未找到 blob |
完整的错误参考表、日志位置、Log Analytics 查询、终结点指标监控、工作区诊断和安全工作区设置检查清单,请参阅 references/troubleshooting.md。
其他资源
各主题的详细参考文件:
- references/networking.md -- VNet、专用终结点、DNS 区域、NSG 规则、服务标记
- references/compute.md -- GPU SKU、计算实例、群集、无服务器、Kubernetes
- references/endpoints.md -- 托管在线、批处理、Kubernetes 和无服务器终结点
- references/identities-acr-storage.md -- 托管标识、ACR 集成、存储帐户
- references/cli-powershell.md -- 完整的 az ml CLI 和 PowerShell 命令参考
- references/terraform.md -- 完整的、可用于生产环境的 Terraform 配置
- references/troubleshooting.md -- 日志读取、调试、错误表、设置检查清单