Bicep Data Types
Every value in Bicep belongs to a data type. A data type tells Bicep what kind of information a value holds: text, a whole number, a yes or no answer, a list, or a group of named properties. Bicep checks types before deployment, so a wrong value produces an error on the screen instead of a failed deployment in the cloud.
Think of labeled storage boxes in a garage. A box marked "screws" holds screws only. Bicep types work the same way: a parameter marked int refuses the word "ten".
The Six Core Types
┌──────────┬──────────────────────────┬──────────────────────────┐
│ Type │ Holds │ Sample value │
├──────────┼──────────────────────────┼──────────────────────────┤
│ string │ Text │ 'eastus' │
│ int │ Whole numbers │ 3 │
│ bool │ true or false │ true │
│ array │ An ordered list │ ['web', 'api'] │
│ object │ Named properties │ { tier: 'Basic' } │
│ null │ No value │ null │
└──────────┴──────────────────────────┴──────────────────────────┘
Strings
Strings use single quotes. Double quotes do not work in Bicep. Interpolation inserts a value into text with ${ }.
param appName string = 'shop'
param env string = 'dev'
var resourceName = '${appName}-${env}-001' // shop-dev-001Multi-Line Strings
Three single quotes on each end create text that spans several lines, such as a startup script.
var startupScript = '''
#!/bin/bash
echo "Server ready"
'''Integers and Booleans
The int type stores whole numbers only. Decimal numbers do not exist as a type in Bicep, so store prices or ratios as text when a fraction matters. A bool type switches features on and off.
param instanceCount int = 2
param enableBackup bool = trueArrays
An array holds items in order. Each item sits at a numbered position that starts at zero.
var regions = [
'eastus'
'westus'
'centralus'
]
var firstRegion = regions[0] // eastus
regions ┌────────┬────────┬───────────┐ │ [0] │ [1] │ [2] │ │ eastus │ westus │ centralus │ └────────┴────────┴───────────┘
Objects
An object bundles related properties under one name. Think of a contact card with a name, phone, and city on one card.
var plan = {
name: 'asp-shop'
sku: 'B1'
capacity: 2
}
var planSku = plan.sku // B1Safe Access with ?.
The ?. operator returns null when a property is missing, which prevents errors on optional settings.
var timeout = plan.?timeout ?? 30 // use 30 when timeout is absentLimiting Values with Literal Types
A parameter can list the exact values it accepts. Bicep flags anything outside the list while editing.
param environment 'dev' | 'test' | 'prod' = 'dev'Type Mismatch Example
param instanceCount int = 'three' // Error: a string cannot be assigned to an intThe editor underlines the line immediately. Fixing the mistake takes seconds, compared with minutes lost on a failed deployment.
Choosing the Right Type
Pick the narrowest type that fits the data. A server count belongs in an int, a backup switch belongs in a bool, and a list of region names belongs in an array. Narrow types give the editor more chances to catch mistakes. Objects work well for settings that travel together, such as the name, size, and capacity of one App Service plan. Passing a single object into a module keeps the call short and tidy.
Summary
Bicep offers string, int, bool, array, object, and null types. Strings use single quotes and support interpolation. Arrays use zero-based positions, and objects group named properties. Literal types restrict a parameter to approved values, and type checking catches mistakes before deployment.
