YAML リファレンス: Azure Container Instances

この記事では、コンテナー グループを構成するために Azure Container Instances によってサポートされている YAML ファイルの構文とプロパティについて説明します。 Azure CLI の az container create コマンドにグループ構成を入力するには、YAML ファイルを使用します。

YAML ファイルは、再現可能なデプロイのためにコンテナー グループを構成する便利な方法です。 これは、Resource Manager テンプレート または Azure Container Instances SDK を使用したコンテナー グループの作成または更新に対する簡便な代替手段です。

Note

このリファレンスは、Azure Container Instances REST API バージョン 2021-10-01 用の YAML ファイルに適用されます。

スキーマ

YAML ファイルのスキーマを次に示します。重要なプロパティはコメントで強調してあります。 このスキーマのプロパティの説明については、「プロパティ値」セクションを参照してください。

name: string  # Name of the container group
apiVersion: '2021-10-01'
location: string
tags: {}
identity: 
  type: string
  userAssignedIdentities: {}
properties: # Properties of container group
  containers: # Array of container instances in the group
  - name: string # Name of an instance
    properties: # Properties of an instance
      image: string # Container image used to create the instance
      command:
      - string
      ports: # External-facing ports exposed on the instance, must also be set in group ipAddress property 
      - protocol: string
        port: integer
      environmentVariables:
      - name: string
        value: string
        secureValue: string
      resources: # Resource requirements of the instance
        requests:
          memoryInGB: number
          cpu: number
          gpu:
            count: integer
            sku: string
        limits:
          memoryInGB: number
          cpu: number
          gpu:
            count: integer
            sku: string
      volumeMounts: # Array of volume mounts for the instance
      - name: string
        mountPath: string
        readOnly: boolean
      livenessProbe:
        exec:
          command:
          - string
        httpGet:
          httpHeaders:
          - name: string
            value: string
          path: string
          port: integer
          scheme: string
        initialDelaySeconds: integer
        periodSeconds: integer
        failureThreshold: integer
        successThreshold: integer
        timeoutSeconds: integer
      readinessProbe:
        exec:
          command:
          - string
        httpGet:
          httpHeaders:
          - name: string
            value: string
          path: string
          port: integer
          scheme: string
        initialDelaySeconds: integer
        periodSeconds: integer
        failureThreshold: integer
        successThreshold: integer
        timeoutSeconds: integer
  imageRegistryCredentials: # Credentials to pull a private image
  - server: string
    username: string
    password: string
    identity: string
    identityUrl: string
  restartPolicy: string
  ipAddress: # IP address configuration of container group
    ports:
    - protocol: string
      port: integer
    type: string
    ip: string
    dnsNameLabel: string
    dnsNameLabelReusePolicy: string
  osType: string
  volumes: # Array of volumes available to the instances
  - name: string
    azureFile:
      shareName: string
      readOnly: boolean
      storageAccountName: string
      storageAccountKey: string
    emptyDir: {}
    secret: {}
    gitRepo:
      directory: string
      repository: string
      revision: string
  diagnostics:
    logAnalytics:
      workspaceId: string
      workspaceKey: string
      workspaceResourceId: string
      logType: string
      metadata: {}
  subnetIds: # Subnet to deploy the container group into
    - id: string
      name: string
  dnsConfig: # DNS configuration for container group
    nameServers:
    - string
    searchDomains: string
    options: string
  sku: string # SKU for the container group
  encryptionProperties:
    vaultBaseUrl: string
    keyName: string
    keyVersion: string
  initContainers: # Array of init containers in the group
  - name: string
    properties:
      image: string
      command:
      - string
      environmentVariables:
      - name: string
        value: string
        secureValue: string
      volumeMounts:
      - name: string
        mountPath: string
        readOnly: boolean

プロパティ値

次の表では、スキーマに設定する必要がある値について説明します。

Microsoft.ContainerInstance/containerGroups オブジェクト

名前 Type 必須
name string はい コンテナー グループの名前。
apiVersion enum はい 2021-10-01 (最新)、2021-09-01、2021-07-01、2021-03-01、2020-11-01、2019-12-01、2018-10-01、2018-09-01、2018-07-01、2018-06-01、2018-04-01
location string いいえ リソースの場所。
tags object いいえ リソース タグ。
identity object いいえ コンテナー グループの ID (構成されている場合)。 - ContainerGroupIdentity オブジェクト
properties object はい ContainerGroupProperties オブジェクト

ContainerGroupIdentity オブジェクト

名前 Type 必須
type enum いいえ コンテナー グループに使用される ID の種類。 種類 "SystemAssigned、UserAssigned" には、暗黙的に作成された ID とユーザー割り当て ID のセットの両方が含まれます。 種類 "None" は、コンテナー グループから ID を削除します。 - SystemAssigned、UserAssigned、SystemAssigned、UserAssigned、None
userAssignedIdentities object いいえ コンテナー グループに関連付けられているユーザー ID のリスト。 ユーザー ID ディクショナリ キーの参照は、次の形式の Azure Resource Manager リソース ID になります: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}"。

ContainerGroupProperties オブジェクト

名前 Type 必須
containers array はい コンテナー グループ内のコンテナー。 - Container オブジェクト
imageRegistryCredentials array いいえ コンテナー グループの作成に使用されたイメージ レジストリの資格情報。 - ImageRegistryCredential オブジェクト
restartPolicy enum いいえ コンテナー グループ内のすべてのコンテナーの再起動ポリシー。 - Always 常に再起動する- OnFailure 障害時に再起動する- Never 再起動しない。 - Always、OnFailure、Never
ipAddress object いいえ コンテナー グループの IP アドレスの種類。 - IpAddress オブジェクト
osType enum はい コンテナー グループ内のコンテナーで必要なオペレーティング システムの種類。 - Windows または Linux
volumes array いいえ このコンテナー グループのコンテナーによってマウントできるボリュームのリスト。 - Volume オブジェクト
診断 object いいえ コンテナー グループの診断情報。 - ContainerGroupDiagnostics オブジェクト
subnetIds object いいえ コンテナー グループのサブネット情報。 - ContainerGroupSubnetIds オブジェクト
dnsConfig object いいえ コンテナー グループの DNS 構成情報。 - DnsConfiguration オブジェクト
sku enum いいえ コンテナー グループの SKU - Standard または Dedicated
encryptionProperties object いいえ コンテナー グループの暗号化プロパティ。 - EncryptionProperties オブジェクト
initContainers array いいえ コンテナー グループの init コンテナー。 - InitContainerDefinition オブジェクト

Container オブジェクト

名前 Type 必須
name string はい ユーザーが指定したコンテナー インスタンスの名前。
properties object はい コンテナー インスタンスのプロパティ。 - ContainerProperties オブジェクト

ImageRegistryCredential オブジェクト

名前 Type 必須
server string はい "http" や "https" などのプロトコルを除いた Docker イメージ レジストリ サーバー。
username string いいえ プライベート レジストリのユーザー名。
password string いいえ プライベート レジストリのパスワード。
identity string いいえ 認証に使用されるユーザーまたはシステム割り当てマネージド ID のリソース ID。
identityUrl string いいえ プライベート レジストリの ID URL。

IpAddress オブジェクト

名前 Type 必須
ports array はい コンテナー グループで公開されているポートのリスト。 - Port オブジェクト
type enum はい IP がパブリック インターネットまたはプライベート VNET に公開されているかどうかを指定します。 - Public または Private
ip string いいえ パブリック インターネットに公開されている IP。
dnsNameLabel string いいえ IP の DNS 名ラベル。

Volume オブジェクト

名前 Type 必須
name string はい ボリュームの名前。
azureFile object いいえ Azure File ボリューム。 - AzureFileVolume オブジェクト
emptyDir object いいえ 空のディレクトリ ボリューム。
secret object いいえ シークレット ボリューム。
gitRepo object いいえ Git リポジトリ ボリューム。 - GitRepoVolume オブジェクト

ContainerGroupDiagnostics オブジェクト

名前 Type 必須
logAnalytics object いいえ コンテナー グループの Log Analytics 情報。 - LogAnalytics オブジェクト

ContainerGroupSubnetIds オブジェクト

名前 Type 必須
id string はい サブネットの識別子。
name string いいえ サブネットの名前。

DnsConfiguration オブジェクト

名前 Type 必須
nameServers array はい コンテナー グループの DNS サーバー。 - string
searchDomains string いいえ コンテナー グループ内のホスト名参照用の DNS 検索ドメイン。
options string いいえ コンテナー グループの DNS オプション。

EncryptionProperties オブジェクト

名前 Type 必須
vaultBaseUrl string はい keyvault のベース url。
keyName string はい 暗号化キーの名前。
keyVersion string はい 暗号化キーのバージョン。

InitContainerDefinition オブジェクト

名前 Type 必須
name string はい init コンテナーの名前。
properties object はい init コンテナーのプロパティ。 - InitContainerPropertiesDefinition オブジェクト

ContainerProperties オブジェクト

名前 Type 必須
image string はい コンテナー インスタンスの作成に使用されるイメージの名前。
command array いいえ コンテナー インスタンス内で実行する exec 形式のコマンド。 - string
ports array いいえ コンテナー インスタンスで公開されているポート。 - ContainerPort オブジェクト
environmentVariables array いいえ コンテナー インスタンス内で設定する環境変数。 - EnvironmentVariable オブジェクト
resources object はい コンテナー インスタンスのリソース要件。 - ResourceRequirements オブジェクト
volumeMounts array いいえ コンテナー インスタンスで使用可能なボリューム マウント。 - VolumeMount オブジェクト
livenessProbe object いいえ liveness probe。 - ContainerProbe オブジェクト
readinessProbe object いいえ readiness probe。 - ContainerProbe オブジェクト

Port オブジェクト

名前 Type 必須
protocol enum いいえ ポートに関連付けられているプロトコル。 - TCP または UDP
port 整数 (integer) はい ポート番号。

AzureFileVolume オブジェクト

名前 Type 必須
shareName string はい ボリュームとしてマウントされる Azure ファイル共有の名前。
readOnly boolean いいえ ボリュームとしてマウントされている Azure ファイル共有が読み取り専用かどうかを示すフラグ。
storageAccountName string はい Azure ファイル共有が含まれているストレージ アカウントの名前。
storageAccountKey string いいえ Azure ファイル共有にアクセスするために使用されるストレージ アカウント アクセス キー。

GitRepoVolume オブジェクト

名前 Type 必須
directory string いいえ ターゲット ディレクトリの名前。 ".." が含まれていたり、".." で始まっていたりすることはできません。 "." を指定した場合、ボリューム ディレクトリは Git リポジトリになります。 それ以外の場合、指定すると、ボリュームの指定された名前のサブディレクトリに Git リポジトリが含まれます。
repository string はい リポジトリの URL
revision string いいえ 指定されたリビジョンのコミット ハッシュ。

LogAnalytics オブジェクト

名前 Type 必須
workspaceId string はい Log Analytics のワークスペース ID
workspaceKey string はい Log Analytics のワークスペース キー
workspaceResourceId string いいえ Log Analytics のワークスペース リソース ID
logType enum いいえ 使用するログの種類。 - ContainerInsights または ContainerInstanceLogs
metadata object いいえ Log Analytics のメタデータ。

InitContainerPropertiesDefinition オブジェクト

名前 Type 必須
image string No init コンテナーのイメージ。
command array いいえ init コンテナー内で実行する exec 形式のコマンド。 - string
environmentVariables array いいえ Init コンテナーで設定する環境変数。 - EnvironmentVariable オブジェクト
volumeMounts array いいえ ボリューム マウントは、init コンテナーで使用できます。 - VolumeMount オブジェクト

ContainerPort オブジェクト

名前 Type 必須
protocol enum いいえ ポートに関連付けられているプロトコル。 - TCP または UDP
port 整数 (integer) はい コンテナー グループ内で公開されているポート番号。

EnvironmentVariable オブジェクト

名前 Type 必須
name string はい 環境変数の名前。
value string いいえ 環境変数の値。
secureValue string いいえ セキュリティで保護された環境変数の値。

ResourceRequirements オブジェクト

名前 Type 必須
requests object はい このコンテナー インスタンスのリソース要求。 - ResourceRequests オブジェクト
制限 object いいえ このコンテナー インスタンスのリソース制限。 - ResourceLimits オブジェクト

VolumeMount オブジェクト

名前 Type 必須
name string はい ボリューム マウントの名前。
mountPath string はい ボリュームをマウントする必要があるコンテナー内のパス。 コロン (:) を含めることはできません。
readOnly boolean いいえ ボリューム マウントが読み取り専用かどうかを示すフラグ。

ContainerProbe オブジェクト

名前 Type 必須
exec object いいえ プローブする実行コマンド - ContainerExec オブジェクト
httpGet object いいえ プローブする Http Get の設定 - ContainerHttpGet オブジェクト
initialDelaySeconds 整数 (integer) いいえ 初期遅延秒数。
periodSeconds 整数 (integer) いいえ 期間の秒数。
failureThreshold 整数 (integer) いいえ 失敗のしきい値。
successThreshold 整数 (integer) いいえ 成功のしきい値。
timeoutSeconds 整数 (integer) いいえ タイムアウト秒数。

ResourceRequests オブジェクト

名前 Type 必須
memoryInGB number はい このコンテナー インスタンスのメモリ要求 (GB 単位)。
cpu number はい このコンテナー インスタンスの CPU 要求。
gpu object いいえ このコンテナー インスタンスの GPU 要求。 - GpuResource オブジェクト

ResourceLimits オブジェクト

名前 Type 必須
memoryInGB number いいえ このコンテナー インスタンスのメモリ制限 (GB 単位)。
cpu number いいえ このコンテナー インスタンスの CPU 制限。
gpu object いいえ このコンテナー インスタンスの GPU 制限。 - GpuResource オブジェクト

ContainerExec オブジェクト

名前 Type 必須
command array いいえ コンテナー内で実行するコマンド。 - string

ContainerHttpGet オブジェクト

名前 Type 必須
path string いいえ プローブするパス。
port 整数 (integer) はい プローブするポート番号。
scheme enum いいえ スキーム。 - http または https
httpHeaders object いいえ プローブに含まれる HTTP ヘッダー。 - HttpHeaders オブジェクト

HttpHeaders オブジェクト

名前 Type 必須
name string いいえ ヘッダーの名前。
value string いいえ ヘッダーの値。

重要

K80 GPU SKU および P100 GPU SKU は 2023 年 8 月 31 日で提供を終了します。 これは、基盤として使われている VM (NC シリーズNCv2 シリーズ) の提供停止によるものです。V100 SKU は使用可能ですが、代替として Azure Kubernetes Service を使用することをお勧めします。 GPU リソースは完全にはサポートされていないため、運用ワークロードには使用しないでください。 今すぐ AKS に移行するには、次のリソースを使用します: AKS へ移行する方法

GpuResource オブジェクト

名前 Type 必須
count 整数 (integer) はい GPU リソースの数。
sku enum はい GPU リソースの SKU。 - V100

次のステップ

チュートリアル「YAML ファイルを使用して複数コンテナー グループをデプロイする」を参照してください。

仮想ネットワーク内のコンテナー グループ、または外部ボリュームをマウントするコンテナー グループをデプロイするための YAML ファイルの使用例を参照してください。