Bicep 的部署函式
本文所說明的 Bicep 函式,可用於取得與目前部署相關的值。
部署
deployment()
傳回目前部署作業的相關資訊。
命名空間:az。
傳回值
此函式會傳回部署期間所傳遞的物件。 傳回物件中的屬性取決於您是否:
將本機 Bicep 檔案部署至資源群組時:此函式會傳回下列格式:
{
"name": "",
"properties": {
"template": {
"$schema": "",
"contentVersion": "",
"parameters": {},
"variables": {},
"resources": [],
"outputs": {}
},
"templateHash": "",
"parameters": {},
"mode": "",
"provisioningState": ""
}
}
當您部署至 Azure 訂閱、管理群組或租用戶時,傳回物件會包含 location
屬性。 部署 location
本機 Bicep 檔案時,不會包含 屬性。 其格式為:
{
"name": "",
"location": "",
"properties": {
"template": {
"$schema": "",
"contentVersion": "",
"resources": [],
"outputs": {}
},
"templateHash": "",
"parameters": {},
"mode": "",
"provisioningState": ""
}
}
範例
下列範例會傳回部署物件︰
output deploymentOutput object = deployment()
上述範例會傳回下列物件︰
{
"name": "deployment",
"properties": {
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [],
"outputs": {
"deploymentOutput": {
"type": "Object",
"value": "[deployment()]"
}
}
},
"templateHash": "13135986259522608210",
"parameters": {},
"mode": "Incremental",
"provisioningState": "Accepted"
}
}
environment
environment()
傳回用於部署的 Azure 環境相關資訊。 函 environment()
式不知道資源組態。 它只能傳回每個資源類型的單一預設 DNS 後綴。
命名空間:az。
備註
若要查看您帳戶的已註冊環境清單,請使用 az cloud list 或 Get-AzEnvironment。
傳回值
此函式會傳回目前 Azure 環境的屬性。 下列範例顯示全域 Azure 的屬性。 主權雲端可能會傳回稍微不同的屬性。
{
"name": "",
"gallery": "",
"graph": "",
"portal": "",
"graphAudience": "",
"activeDirectoryDataLake": "",
"batch": "",
"media": "",
"sqlManagement": "",
"vmImageAliasDoc": "",
"resourceManager": "",
"authentication": {
"loginEndpoint": "",
"audiences": [
"",
""
],
"tenant": "",
"identityProvider": ""
},
"suffixes": {
"acrLoginServer": "",
"azureDatalakeAnalyticsCatalogAndJob": "",
"azureDatalakeStoreFileSystem": "",
"azureFrontDoorEndpointSuffix": "",
"keyvaultDns": "",
"sqlServerHostname": "",
"storage": ""
}
}
範例
下列範例 Bicep 檔案會傳回環境物件。
output environmentOutput object = environment()
上述範例會在部署到全域 Azure 時傳回下列物件:
{
"name": "AzureCloud",
"gallery": "https://gallery.azure.com/",
"graph": "https://graph.windows.net/",
"portal": "https://portal.azure.com",
"graphAudience": "https://graph.windows.net/",
"activeDirectoryDataLake": "https://datalake.azure.net/",
"batch": "https://batch.core.windows.net/",
"media": "https://rest.media.azure.net",
"sqlManagement": "https://management.core.windows.net:8443/",
"vmImageAliasDoc": "https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/arm-compute/quickstart-templates/aliases.json",
"resourceManager": "https://management.azure.com/",
"authentication": {
"loginEndpoint": "https://login.microsoftonline.com/",
"audiences": [ "https://management.core.windows.net/", "https://management.azure.com/" ],
"tenant": "common",
"identityProvider": "AAD"
},
"suffixes": {
"acrLoginServer": ".azurecr.io",
"azureDatalakeAnalyticsCatalogAndJob": "azuredatalakeanalytics.net",
"azureDatalakeStoreFileSystem": "azuredatalakestore.net",
"azureFrontDoorEndpointSuffix": "azurefd.net",
"keyvaultDns": ".vault.azure.net",
"sqlServerHostname": ".database.windows.net",
"storage": "core.windows.net"
}
}
下一步
- 若要從資源、資源群組或訂用帳戶中取得值,請參閱 資源函式。