environment.yaml 中的參數和資料類型
ADE 環境定義是基礎結構即程式碼 (IaC),以 Bicep 或 Terraform 撰寫,儲存在存放庫中。 環境定義可根據您的特定需求修改和調整,然後可用來在 Azure 上建立部署環境。 environment.yaml 結構描述會定義並描述環境定義中包含的 Azure 資源類型。
什麼是 environment.yaml?
environment.yaml 檔案如同資訊清單,會描述所使用的資源,以及環境定義的範本位置。
environment.yaml 範例
以下指令碼是環境定義所需的 environment.yaml 一般範例。
name: WebApp
version: 1.0.0
summary: Azure Web App Environment
description: Deploys a web app in Azure without a datastore
runner: ARM
templatePath: azuredeploy.json
定義
下表說明 environment.yaml 內可使用的屬性。
屬性 | 型別 | 說明 | 必要 | 範例 |
---|---|---|---|---|
NAME | 字串 | 目錄項目的顯示名稱。 | Yes | |
version | string | 目錄項目的版本。 | 1.0.0 | |
摘要 | string | 目錄項目的簡短摘要字串。 | ||
description | string | 目錄項目的描述。 | ||
runner | string | 執行動作時要使用的容器映像。 | ARM 範本 Terraform |
|
templatePath | string | 輸入範本檔案的相對路徑。 | Yes | main.tf main.bicep azuredeploy.json |
parameters | 陣列 | 建立環境和執行動作時要使用的輸入參數。 | #/definitions/Parameter |
environment.yaml 中的參數
參數可讓您在不同案例中重複使用環境定義。 例如,您可能希望不同區域的開發人員都部署相同環境。 您可定義位置參數,提示開發人員建立環境時輸入所需位置。
具有參數的 environment.yaml 範例
下列指令碼是 environment.yaml 檔案的範例,包括兩個參數;location
和 name
:
name: WebApp
summary: Azure Web App Environment
description: Deploys a web app in Azure without a datastore
runner: ARM
templatePath: azuredeploy.json
parameters:
- id: "location"
name: "location"
description: "Location to deploy the environment resources"
default: "[resourceGroup().location]"
type: "string"
required: false
- id: "name"
name: "name"
description: "Name of the Web App "
default: ""
type: "string"
required: false
參數定義
下表說明 environment.yaml 內可使用的資料類型。 environment.yaml 資訊清單檔使用的資料類型名稱,有別於 ARM 範本。
每個參數都可使用下列任何屬性:
屬性 | 型別 | 說明 | 進階設定 |
---|---|---|---|
識別碼 | string | 參數的唯一識別碼。 | |
NAME | 字串 | 參數的顯示名稱。 | |
description | string | 參數的描述。 | |
預設值 | 陣列 布林值 整數 數值 物件 字串 |
參數的「預設值」。 | |
type | 陣列 布林值 整數 數值 物件 字串 |
參數的資料類型。 此資料類型必須與 ARM 範本、BICEP 檔案或 Terraform 檔案的參數資料類型相同,且參數名稱要相對應。 | 預設類型:字串 |
readOnly | boolean | 不論如何,此參數是唯讀的。 | |
必要 | boolean | 不論如何,此參數是必要的。 | |
允許 | 陣列 | 允許的值之陣列。 | "items": { "type": "string" }, "minItems": 1, "uniqueItems": true, |
YAML 結構描述
Azure 部署環境的 environment.yaml 檔案有明確定義的結構描述,因此編輯這些檔案可能稍微容易。 您可在 environment.yaml 檔案開頭新增結構描述定義:
# yaml-language-server: $schema=https://github.com/Azure/deployment-environments/releases/download/2022-11-11-preview/manifest.schema.json
以下是使用本結構描述的環境定義範例:
# yaml-language-server: $schema=https://github.com/Azure/deployment-environments/releases/download/2022-11-11-preview/manifest.schema.json
name: FunctionApp
version: 1.0.0
summary: Azure Function App Environment
description: Deploys an Azure Function App, Storage Account, and Application Insights
runner: ARM
templatePath: azuredeploy.json
parameters:
- id: name
name: Name
description: 'Name of the Function App.'
type: string
required: true
- id: supportsHttpsTrafficOnly
name: 'Supports HTTPS Traffic Only'
description: 'Allows https traffic only to Storage Account and Functions App if set to true.'
type: boolean
- id: runtime
name: Runtime
description: 'The language worker runtime to load in the function app.'
type: string
allowed:
- 'dotnet'
- 'dotnet-isolated'
- 'java'
- 'node'
- 'powershell'
- 'python'
default: 'dotnet-isolated'