Skip to content

Latest commit

 

History

History
69 lines (52 loc) · 1.51 KB

File metadata and controls

69 lines (52 loc) · 1.51 KB
title BCP401
description The spread operator "..." is not permitted in this location.
ms.topic reference
ms.custom devx-track-bicep
ms.date 10/30/2025

Bicep diagnostic code - BCP401

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.

Description

The spread operator "..." is not permitted in this location.

Level

Error

Examples

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
        ]        
      } : {})
    }
  }
}

Next steps

For more information about Bicep diagnostics, see Bicep core diagnostics.