Reputation: 193
Let’s say, I want to deploy a separate resource only if param isProduction bool
is true
.
Is that possible with Bicep?
I could not find this in the documentation.
Upvotes: 2
Views: 2335
Reputation: 1146
In addition to the answer already given, not only can the whole resource be deployed based on a condition, but also individual properties of a resource can be changed for a specific environment using conditional ternary operator. The following is an example for Azure Front Door, where only in the production environment the Premium Tier is used:
resource profile 'Microsoft.Cdn/profiles@2020-09-01' = {
name: 'azureFrontDoor'
location: 'global'
sku: {
name: isProduction ? 'Premium_AzureFrontDoor' : 'Standard_AzureFrontDoor'
}
tags: tags
}
Upvotes: 1
Reputation: 193
There is a syntax if(isProduction)
that can be used after =
, for example:
param isProduction bool
resource prodWebApp 'Microsoft.Web/sites@2020-12-01' = if (isProduction) {
name: 'MyWebApp'
...<other props>...
}
Upvotes: 3