分享方式:


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 string YAML 結構描述。 如果您使用 Azure Machine Learning VS Code 擴充功能來撰寫 YAML 檔案,在檔案頂端包含 $schema 可讓您叫用結構描述和資源完成。
name string 必要。 環境的名稱。
version 字串 環境的版本。 如果省略,Azure 機器學習 會自動產生版本。
description 字串 環境的描述。
tags object 環境的標籤典。
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 object 要用於環境的 Docker 建置內容組態。 其中一個 imagebuild 是必要的。
build.path 字串 要作為建置內容之目錄的本機路徑。
build.dockerfile_path 字串 組建內容中 Dockerfile 的相對路徑。 Dockerfile
os_type 字串 作業系統的類型。 linux, windows linux
inference_config object 推斷容器組態。 只有在環境用來建置在線部署的服務容器時才適用。 請參閱索引鍵的屬性inference_config

索引鍵的屬性inference_config

機碼 類型 描述
liveness_route object 服務容器的活躍度路由。
liveness_route.path 字串 路由傳送活躍度要求的路徑。
liveness_route.port 整數 要路由傳送活躍度要求的埠。
readiness_route object 服務容器的整備路由。
readiness_route.path 字串 路由傳送整備要求的路徑。
readiness_route.port 整數 要路由傳送整備要求的埠。
scoring_route object 服務容器的評分路由。
scoring_route.path 字串 將評分要求路由傳送至的路徑。
scoring_route.port 整數 要路由評分要求的埠。

備註

az ml environment命令可用於管理 Azure 機器學習 環境。

範例

範例 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.

下一步