I am trying to create a bicep template to deploy a VM with either 1 or 2 NICs depending on a conditional.
Anyone know if there is a way to deploy a VM NIC using conditional statements inside a property definition? Seems an if function is not permitted inside a resource definition and a ternary errors out due to invalid ID.
Just trying to avoid having 2 dupicate VM resource definitions using resource = if (bool) {}
networkProfile: {
networkInterfaces: [
{
id: nic_wan.id
properties: {
primary: true
}
}
{
id: bool ? nic_lan.id : '' #Trying to deploy this as a conditional if bool = true.
properties: {
primary: false
}
}
]
}
The above code errors out because as soon as you define a NIC, it needs a valid ID.
'properties.networkProfile.networkInterfaces[1].id' is invalid. Expect fully qualified resource Id that start with '/subscriptions/{subscriptionId}' or '/providers/{resourceProviderNamespace}/'. (Code:LinkedInvalidPropertyId)