Deployment functions for Bicep

This article describes the Bicep functions for getting values related to the current deployment.

deployment

deployment()

Returns information about the current deployment operation.

Namespace: az.

Return value

This function returns the object that is passed during deployment. The properties in the returned object differ based on whether you are:

When deploying a local Bicep file to a resource group, the function returns the following format:

{
  "name": "",
  "properties": {
    "template": {
      "$schema": "",
      "contentVersion": "",
      "parameters": {},
      "variables": {},
      "resources": [],
      "outputs": {}
    },
    "templateHash": "",
    "parameters": {},
    "mode": "",
    "provisioningState": ""
  }
}

When you deploy to an Azure subscription, management group, or tenant, the return object includes a location property. The location property isn't included when deploying a local Bicep file. The format is:

{
  "name": "",
  "location": "",
  "properties": {
    "template": {
      "$schema": "",
      "contentVersion": "",
      "resources": [],
      "outputs": {}
    },
    "templateHash": "",
    "parameters": {},
    "mode": "",
    "provisioningState": ""
  }
}

Example

The following example returns the deployment object:

output deploymentOutput object = deployment()

The preceding example returns the following object:

{
  "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()

Returns information about the Azure environment used for deployment. The environment() function is not aware of resource configurations. It can only return a single default DNS suffix for each resource type.

Namespace: az.

Remarks

To see a list of registered environments for your account, use az cloud list or Get-AzEnvironment.

Return value

This function returns properties for the current Azure environment. The following example shows the properties for global Azure. Sovereign clouds may return slightly different properties.

{
  "name": "",
  "gallery": "",
  "graph": "",
  "portal": "",
  "graphAudience": "",
  "activeDirectoryDataLake": "",
  "batch": "",
  "media": "",
  "sqlManagement": "",
  "vmImageAliasDoc": "",
  "resourceManager": "",
  "authentication": {
    "loginEndpoint": "",
    "audiences": [
      "",
      ""
    ],
    "tenant": "",
    "identityProvider": ""
  },
  "suffixes": {
    "acrLoginServer": "",
    "azureDatalakeAnalyticsCatalogAndJob": "",
    "azureDatalakeStoreFileSystem": "",
    "azureFrontDoorEndpointSuffix": "",
    "keyvaultDns": "",
    "sqlServerHostname": "",
    "storage": ""
  }
}

Example

The following example Bicep file returns the environment object.

output environmentOutput object = environment()

The preceding example returns the following object when deployed to Azure China Cloud:

{
  "name": "AzureChinaCloud",
  "gallery": "https://gallery.chinacloudapi.cn/",
  "graph": "https://graph.chinacloudapi.cn/",
  "portal": "https://portal.azure.cn",
  "graphAudience": "https://graph.chinacloudapi.cn/",
  "activeDirectoryDataLake": "https://datalake.chinacloudapi.cn/",
  "batch": "https://batch.chinacloudapi.cn/",
  "media": "https://rest.media.chinacloudapi.cn",
  "sqlManagement": "https://management.core.chinacloudapi.cn:8443/",
  "vmImageAliasDoc": "https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/arm-compute/quickstart-templates/aliases.json",
  "resourceManager": "https://management.chinacloudapi.cn/",
  "authentication": {
    "loginEndpoint": "https://login.chinacloudapi.cn/",
    "audiences": [ "https://management.core.chinacloudapi.cn/", "https://management.chinacloudapi.cn/" ],
    "tenant": "common",
    "identityProvider": "AAD"
  },
  "suffixes": {
    "acrLoginServer": ".azurecr.cn",
    "azureDatalakeAnalyticsCatalogAndJob": "azuredatalakeanalytics.net",
    "azureDatalakeStoreFileSystem": "azuredatalakestore.net",
    "azureFrontDoorEndpointSuffix": "azurefd.net",
    "keyvaultDns": ".vault.azure.cn",
    "sqlServerHostname": ".database.chinacloudapi.cn",
    "storage": "core.chinacloudapi.cn"
  }
}

Next steps

  • To get values from resources, resource groups, or subscriptions, see Resource functions.