探索 Azure Resource Manager 範本結構和架構

已完成

Azure Resource Manager 範本包含一或多個 Azure 資源的 JSON 格式定義,以及可輔助自訂其設定的參數和變數。

在最簡單的結構中,範本具有下列元素:

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "",
  "apiProfile": "",
  "parameters": {  },
  "variables": {  },
  "functions": [  ],
  "resources": [  ],
  "outputs": {  }
}
元素名稱 必要 描述
$schema Yes 描述範本語言版本的 JavaScript 物件標記法 (JSON) 結構描述檔案所在的位置。 您所使用的版本號碼取決於部署範圍以及您的 JSON 編輯器。

如果您使用具 Azure Resource Manager Tools 擴充功能的 Visual Studio Code,請使用最新版本部署資源群組:
https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#

其他編輯器 (包括 Visual Studio) 可能無法處理此結構描述。 針對這些編輯器,請使用:
https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#

針對訂用帳戶部署,使用:
https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#

針對管理群組部署,請使用:
https://schema.management.azure.com/schemas/2019-08-01/managementGroupDeploymentTemplate.json#

針對租用戶部署,請使用:
https://schema.management.azure.com/schemas/2019-08-01/tenantDeploymentTemplate.json#
contentVersion Yes 範本版本 (例如 1.0.0.0)。 您可以為此元素提供任何值。 使用此值在範本中記載重大變更。 在使用範本部署資源時,您可以使用此值以確保正在使用正確的範本。
apiProfile No 做為資源類型 API 版本集合的 API 版本。 使用此值,避免必須為範本中每個資源指定 API 版本。 若在指定 API 設定檔版本時未指定資源類型的 API 版本,Resource Manager 會使用該設定檔中定義的資源類型 API 版本。

將範本部署到不同環境 (例如 Azure Stack 和全域 Azure) 時,API 設定檔屬性特別實用。 使用 API 設定檔版本,以確保您的範本會自動使用兩個環境都支援的版本。 如需目前 API 設定檔版本和設定檔中定義之資源 API 版本的清單,請參閱 API 設定檔 (英文)

如需詳細資訊,請參閱使用 API 設定檔追蹤版本
parameters No 執行部署以自訂資源部署時所提供的值。
variables No 範本中做為 JSON 片段以簡化範本語言運算式的值。
functions No 範本中可用的使用者定義函式。
resources Yes 在資源群組或訂用帳戶中部署或更新的資源類型。
輸出 No 部署後傳回的值。

選用示範