Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This diagnostic occurs when you use expressions to define resource bodies as the Spread
operator gets converted to a function. It's a limitation in JSON.
The spread operator "..." is not permitted in this location.
Error
The following example raises the diagnostic because the spread
operator is used to define the resource body:
param location string = resourceGroup().location
param addressPrefix string = '10.0.0.0/24'
resource vnet 'Microsoft.Network/virtualNetworks@2024-01-01' = {
name: 'vnetName'
location: location
...(addressPrefix != '' ? {
properties: {
addressSpace: {
addressPrefixes: [
addressPrefix
]
}
}
} : {})
}
You can fix the diagnostic by using the operator in the lower level:
param location string = resourceGroup().location
param addressPrefix string = '10.0.0.0/24'
resource vnet 'Microsoft.Network/virtualNetworks@2024-01-01' = {
name: 'vnetName'
location: location
properties: {
addressSpace: {
...(addressPrefix != '' ? {
addressPrefixes: [
addressPrefix
]
} : {})
}
}
}
For more information about Bicep diagnostics, see Bicep core diagnostics.