This article compares Bicep syntax with JSON syntax for Azure Resource Manager templates (ARM templates). In most cases, Bicep provides syntax that is less verbose than the equivalent in JSON.
If you're familiar with using JSON to develop ARM templates, use the following examples to learn about the equivalent syntax for Bicep.
Compare complete files
The Bicep Playground lets you view Bicep and equivalent JSON side by side. You can compare the implementations of the same infrastructure.
For example, you can view the file to deploy a SQL server and database. The Bicep is about half the size of the ARM template.
For Bicep, you can set an explicit dependency but this approach isn't recommended. Instead, rely on implicit dependencies. An implicit dependency is created when one resource declaration references the identifier of another resource.
The following shows a network interface with an implicit dependency on a network security group. It references the network security group with netSecurityGroup.id.
To get a property from an existing resource that isn't deployed in the template:
resource storageAccount 'Microsoft.Storage/storageAccounts@2023-04-01' existing = {
name: storageAccountName
}
// use later in template as often as needed
storageAccount.properties.primaryEndpoints.blob
// required every time the property is needed
"[reference(resourceId('Microsoft.Storage/storageAccounts/', parameters('storageAccountName')), '2019-06-01').primaryEndpoints.blob]"
In Bicep, use the nested accessor (::) to get a property on a resource nested within a parent resource:
The Bicep ternary operator is the equivalent to the if function in an ARM template JSON, not the condition property. The ternary syntax has to evaluate to one value or the other. If the condition is false in the preceding samples, Bicep outputs a hostname with an empty string, but JSON outputs no values.
Build end-to-end solutions in Microsoft Azure to create Azure Functions, implement and manage web apps, develop solutions utilizing Azure storage, and more.