YAML 參考:Azure 容器執行個體
本文涵蓋 Azure 容器執行個體支援 YAML 檔案的語法和屬性,設定容器群組。 使用 YAML 檔案將群組設定輸入 Azure CLI 中的 az container create 命令。
若要設定可重現部署的容器群組,YAML 檔案是很方便的方式。 使用 Resource Manager 範本,或 Azure 容器執行個體 SDK 建立或更新容器群組是簡單的替代方案。
注意
此參考適用於 Azure 容器執行個體 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 object
名稱 |
類型 |
必要 |
值 |
NAME |
字串 |
Yes |
容器群組的名稱。 |
apiVersion |
列舉 |
Yes |
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 |
字串 |
No |
資源位置。 |
tags |
object |
No |
資源標籤。 |
身分識別 |
object |
No |
容器群組的身分識別 (如果已設定)。 - ContainerGroupIdentity object |
properties |
物件 |
是 |
ContainerGroupProperties object |
ContainerGroupIdentity object
名稱 |
類型 |
必要 |
值 |
類型 |
列舉 |
No |
容器群組使用的身分識別類型。 「SystemAssigned、UserAssigned」類型同時包含隱含建立的身分識別,和一組使用者指派的身分識別。 「None」類型會從容器群組移除任何身分識別。 - SystemAssigned、UserAssigned、SystemAssigned、UserAssigned、None |
userAssignedIdentities |
object |
No |
容器群組相關的使用者身分識別清單。 使用者識別字典索引碼參考,是以下格式的 Azure Resource Manager 資源識別碼:「/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}」。 |
ContainerGroupProperties object
容器物件
ImageRegistryCredential 物件
名稱 |
類型 |
必要 |
值 |
伺服器 |
字串 |
Yes |
Docker 映像登錄伺服器不具通訊協定 (例如「http」和「https」)。 |
username |
字串 |
No |
私人登錄的使用者名稱。 |
密碼 |
字串 |
No |
私人登錄的密碼。 |
身分識別 |
字串 |
No |
驗證使用的使用者或系統指派的受控識別資源識別碼。 |
identityUrl |
字串 |
No |
私人登錄的身分識別 URL。 |
IpAddress 物件
名稱 |
類型 |
必要 |
值 |
連接埠 |
array |
Yes |
容器群組上公開的連接埠清單。 - Port 物件 |
類型 |
列舉 |
Yes |
如果 IP 公開至公用網際網路或私人 VNET 時指定。 - 公用或私人 |
ip |
字串 |
No |
公開至公用網際網路的 IP。 |
dnsNameLabel |
字串 |
No |
IP 的 DNS 名稱標籤。 |
Volume 物件
ContainerGroupDiagnostics object
ContainerGroupSubnetIds object
名稱 |
類型 |
必要 |
值 |
id |
string |
Yes |
子網路的識別碼。 |
NAME |
字串 |
No |
子網路的名稱。 |
DnsConfiguration 物件
名稱 |
類型 |
必要 |
值 |
nameServers |
array |
Yes |
容器群組的 DNS 伺服器。 - 字串 |
searchDomains |
字串 |
No |
容器群組中適用於主機名稱查詢的 DNS 搜尋網域。 |
選項 |
字串 |
No |
容器群組的 DNS 選項。 |
EncryptionProperties 物件
名稱 |
類型 |
必要 |
值 |
vaultBaseUrl |
字串 |
Yes |
Keyvault 基底 URL。 |
keyName |
字串 |
Yes |
加密金鑰名稱。 |
keyVersion |
字串 |
Yes |
加密金鑰版本。 |
InitContainerDefinition object
ContainerProperties 物件
Port 物件
名稱 |
類型 |
必要 |
值 |
protocol |
列舉 |
No |
連接埠相關的通訊協定。 - TCP 或 UDP |
連接埠 |
整數 |
Yes |
連接埠號碼。 |
AzureFileVolume object
名稱 |
類型 |
必要 |
值 |
shareName |
字串 |
Yes |
作為磁碟區裝載的 Azure 檔案共用名稱。 |
readOnly |
boolean |
No |
此旗標指出作為磁碟區裝載的 Azure 檔案共用是否為唯讀。 |
storageAccountName |
字串 |
Yes |
包含 Azure 檔案共用的儲存體帳戶名稱。 |
storageAccountKey |
字串 |
No |
存取 Azure 檔案共用使用的儲存體帳戶存取金鑰。 |
GitRepoVolume 物件
名稱 |
類型 |
必要 |
值 |
directory |
字串 |
No |
目標目錄名稱。 不能包含「..」或以「..」為開頭。 如果提供「.」,磁片區目錄即為 git 存放庫。 此外,若有指定,磁片區會包含在指定名稱子目錄中的 git 存放庫。 |
repository |
字串 |
Yes |
存放庫 URL |
revision |
字串 |
No |
認可指定修訂的雜湊。 |
LogAnalytics object
名稱 |
類型 |
必要 |
值 |
workspaceId |
字串 |
Yes |
記錄分析的工作區識別碼 |
workspaceKey |
字串 |
Yes |
記錄分析的工作區金鑰 |
workspaceResourceId |
字串 |
No |
記錄分析的工作區資源識別碼 |
logType |
列舉 |
No |
要使用的記錄類型。 - ContainerInsights or ContainerInstanceLogs |
中繼資料 |
object |
No |
記錄分析的中繼資料。 |
InitContainerPropertiesDefinition object
名稱 |
類型 |
必要 |
值 |
image |
字串 |
No |
Init 容器的映像。 |
命令 |
array |
No |
Init 容器中以 exec 格式執行的命令。 - 字串 |
environmentVariables |
array |
No |
Init 容器中設定的環境變數。 - EnvironmentVariable 物件 |
volumeMounts |
array |
No |
Init 容器可用的磁碟區裝載。 - VolumeMount 物件 |
ContainerPort 物件
名稱 |
類型 |
必要 |
值 |
protocol |
列舉 |
No |
連接埠相關的通訊協定。 - TCP 或 UDP |
連接埠 |
整數 |
Yes |
容器群組中公開的連接埠號碼。 |
EnvironmentVariable 物件
名稱 |
類型 |
必要 |
值 |
NAME |
字串 |
Yes |
環境變數的名稱。 |
value |
字串 |
No |
環境變數的值。 |
secureValue |
字串 |
No |
安全環境變數的值。 |
ResourceRequirements 物件
VolumeMount 物件
名稱 |
類型 |
必要 |
值 |
NAME |
字串 |
Yes |
磁碟區裝載的名稱。 |
mountPath |
字串 |
Yes |
容器中磁碟區的裝載路徑。 不得包含冒號 (:)。 |
readOnly |
boolean |
No |
此旗標指出磁碟區裝載是否為唯讀。 |
ContainerProbe 物件
名稱 |
類型 |
必要 |
值 |
exec |
object |
No |
探查的執行命令 - ContainerExec 物件 |
httpGet |
object |
No |
探查的 Http Get 設定 - ContainerHttpGet 物件 |
initialDelaySeconds |
整數 |
No |
初始延遲秒數。 |
periodSeconds |
整數 |
No |
期間長度秒數。 |
failureThreshold |
整數 |
No |
失敗閾值。 |
successThreshold |
整數 |
No |
成功閾值。 |
timeoutSeconds |
整數 |
No |
逾時秒數。 |
ResourceRequests object
名稱 |
類型 |
必要 |
值 |
memoryInGB |
數字 |
Yes |
此容器執行個體的記憶體要求 GB。 |
cpu |
數字 |
Yes |
此容器執行個體的 CPU 要求。 |
gpu |
object |
No |
此容器執行個體的 GPU 要求。 - GpuResource 物件 |
ResourceLimits object
名稱 |
類型 |
必要 |
值 |
memoryInGB |
數字 |
No |
此容器執行個體的記憶體限制 GB。 |
cpu |
數字 |
No |
此容器執行個體的 CPU 限制。 |
gpu |
object |
No |
此容器執行個體的 GPU 限制。 - GpuResource 物件 |
ContainerExec 物件
名稱 |
類型 |
必要 |
值 |
命令 |
array |
No |
容器中執行的命令。 - 字串 |
ContainerHttpGet object
名稱 |
類型 |
必要 |
值 |
path |
字串 |
No |
探查的路徑。 |
連接埠 |
整數 |
Yes |
探查的連接埠號碼。 |
scheme |
列舉 |
No |
配置。 - http 或 https |
httpHeaders |
object |
No |
探查中包含的 HTTP 標頭。 - HttpHeaders object |
名稱 |
類型 |
必要 |
值 |
NAME |
字串 |
No |
標頭的名稱。 |
value |
字串 |
No |
標頭的值。 |
重要
K80 和 P100 GPU SKU 將于 2023 年 8 月 31 日淘汰。 這是因為已使用的基礎 VM 淘汰:NC 系列和NCv2 系列雖然 V100 SKU 可供使用,但會改為使用 Azure Kubernetes Service。 GPU 資源不受完全支援,不應用於生產工作負載。 使用下列資源立即移轉至 AKS:如何移轉至 AKS。
GpuResource 物件
名稱 |
類型 |
必要 |
值 |
count |
整數 |
Yes |
GPU 資源的計數。 |
sku |
列舉 |
Yes |
GPU 資源的 SKU。 - V100 |
下一步
請參閱教學課程「使用 YAML 檔案部署多容器群組」。
請參閱虛擬網路或裝載外部磁碟區中「使用 YAML 檔案部署容器群組」的範例。