CLI (v2) 環境 YAML 結構描述

適用於:Azure CLI ml 延伸模組 v2 (目前)

您可以在 https://azuremlschemas.azureedge.net/latest/environment.schema.json 中找到來源 JSON 結構描述。

注意

此文件中詳述的 YAML 語法是以最新版 ML CLI v2 延伸模組的 JSON 結構描述為基礎。 此語法只保證能與最新版的 ML CLI v2 延伸模組搭配使用。 您可以在 https://azuremlschemasprod.azureedge.net/ 找到舊版延伸模組的結構描述。

YAML 語法

索引鍵 類型 描述 允許的值 預設值
$schema 字串 YAML 結構描述。 如果您使用 Azure Machine Learning VS Code 擴充功能來撰寫 YAML 檔案,在檔案頂端包含 $schema 可讓您叫用結構描述和資源完成。
name 字串 必要。 環境的名稱。
version 字串 環境的版本。 如果省略,Azure Machine Learning 會自動產生版本。
description 字串 環境的描述。
tags 物件 環境的標記字典。
image 字串 要用於環境的 Docker 映像。 需要 imagebuild 其中一個。
conda_file 字串或物件 Conda 環境相依性的標準 conda YAML 設定檔。 請參閱 https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#creating-an-environment-file-manually

如果有指定,也必須指定 image。 Azure Machine Learning 會在提供的 Docker 映射之上建置 conda 環境。
build 物件 要用於環境的 Docker 組建內容設定。 需要 imagebuild 其中一個。
build.path 字串 要用作組建內容的目錄的本機路徑。
build.dockerfile_path 字串 組建內容內 Dockerfile 的相對路徑。 Dockerfile
os_type 字串 作業系統的類型。 linux, windows linux
inference_config 物件 推斷容器設定。 僅適用於環境用來建置線上部署的服務容器時。 請參閱 inference_config 索引鍵的屬性

inference_config 索引鍵的屬性

索引鍵 類型 描述
liveness_route 物件 服務容器的活躍度路由。
liveness_route.path 字串 路由活躍度要求的路徑。
liveness_route.port 整數 路由活躍度要求的連接埠。
readiness_route 物件 服務容器的整備度路由。
readiness_route.path 字串 路由整備度要求的路徑。
readiness_route.port 整數 路由整備度要求的連接埠。
scoring_route 物件 服務容器的評分路由。
scoring_route.path 字串 路由評分要求的路徑。
scoring_route.port 整數 路由評分要求的連接埠。

備註

az ml environment 命令可用於管理 Azure Machine Learning 環境。

範例

範例 GitHub 存放庫中有範例可用。 以下顯示其中幾個。

YAML:本機 Docker 組建內容

$schema: https://azuremlschemas.azureedge.net/latest/environment.schema.json
name: docker-context-example
build:
  path: docker-contexts/python-and-pip

YAML:Docker 映像

$schema: https://azuremlschemas.azureedge.net/latest/environment.schema.json
name: docker-image-example
image: pytorch/pytorch:latest
description: Environment created from a Docker image.

YAML:Docker 映像加上 conda 檔案

$schema: https://azuremlschemas.azureedge.net/latest/environment.schema.json
name: docker-image-plus-conda-example
image: mcr.microsoft.com/azureml/openmpi4.1.0-ubuntu20.04
conda_file: conda-yamls/pydata.yml
description: Environment created from a Docker image plus Conda environment.

後續步驟