Bicep functions
This article describes all the functions you can use in a Bicep file. To define custom functions, see User-defined functions. For a description of the sections in a Bicep file, see Understand the structure and syntax of Bicep files.
Most functions work the same when deployed to a resource group, subscription, management group, or tenant. A few functions can't be used in all scopes. They're noted in the lists below.
Namespaces for functions
All Bicep functions are contained within two namespaces - az
and sys
. Typically, you don't need to specify the namespace when you use the function. You specify the namespace only when the function name is the same as another item you've defined in the Bicep file. For example, if you create a parameter named range
, you need to differentiate the range
function by adding the sys
namespace.
// Parameter contains the same name as a function
param range int
// Must use sys namespace to call the function.
// The second use of range refers to the parameter.
output result array = sys.range(1, range)
The az
namespace contains functions that are specific to an Azure deployment. The sys
namespace contains functions that are used to construct values. The sys
namespace also includes decorators for parameters and resource loops. The namespaces are noted in this article.
Any function
The any function is available in Bicep to help resolve issues around data type warnings. This function is in the sys
namespace.
Array functions
The following functions are available for working with arrays. All of these functions are in the sys
namespace.
- array
- concat
- contains
- empty
- indexOf
- first
- flatten
- intersection
- last
- lastIndexOf
- length
- min
- max
- range
- skip
- take
- union
CIDR functions
The following functions are available for working with CIDR. All of these functions are in the sys
namespace.
Date functions
The following functions are available for working with dates. All of these functions are in the sys
namespace.
Deployment value functions
The following functions are available for getting values related to the deployment. All of these functions are in the az
namespace.
File functions
The following functions are available for loading the content from external files into your Bicep file. All of these functions are in the sys
namespace.
Lambda functions
The following functions are available for working with lambda expressions. All of these functions are in the sys
namespace.
Logical function
The following function is available for working with logical conditions. This function is in the sys
namespace.
Numeric functions
The following functions are available for working with integers. All of these functions are in the sys
namespace.
Object functions
The following functions are available for working with objects. All of these functions are in the sys
namespace.
Parameters file functions
The following functions are available to be used in Bicep parameters files. All of these functions are in the sys
namespace.
Resource functions
The following functions are available for getting resource values. Most of these functions are in the az
namespace. The list functions and the getSecret function are called directly on the resource type, so they don't have a namespace qualifier.
- extensionResourceId
- getSecret
- listAccountSas
- listKeys
- listSecrets
- list*
- managementGroupResourceId
- pickZones
- providers (deprecated)
- reference
- resourceId - can be used at any scope, but the valid parameters change depending on the scope.
- subscriptionResourceId
- tenantResourceId
Scope functions
The following functions are available for getting scope values. All of these functions are in the az
namespace.
- managementGroup
- resourceGroup - can only be used in deployments to a resource group.
- subscription - can only be used in deployments to a resource group or subscription.
- tenant
String functions
Bicep provides the following functions for working with strings. All of these functions are in the sys
namespace.
- base64
- base64ToJson
- base64ToString
- concat
- contains
- dataUri
- dataUriToString
- empty
- endsWith
- first
- format
- guid
- indexOf
- join
- last
- lastIndexOf
- length
- newGuid
- padLeft
- replace
- skip
- split
- startsWith
- string
- substring
- take
- toLower
- toUpper
- trim
- uniqueString
- uri
- uriComponent
- uriComponentToString
Next steps
- For a description of the sections in a Bicep file, see Understand the structure and syntax of Bicep files.
- To iterate a specified number of times when creating a type of resource, see Iterative loops in Bicep.
- To see how to deploy the Bicep file you've created, see Deploy resources with Bicep and Azure PowerShell.