Skip to content

Commit 400dce1

Browse files
committed
add bcp414
1 parent 4a6b122 commit 400dce1

File tree

1 file changed

+69
-0
lines changed
  • articles/azure-resource-manager/bicep/diagnostics

1 file changed

+69
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
title: BCP414
3+
description: The spread operator "..." is not permitted in this location.
4+
ms.topic: reference
5+
ms.custom: devx-track-bicep
6+
ms.date: 05/20/2025
7+
---
8+
9+
# Bicep diagnostic code - BCP414
10+
11+
This diagnostic occurs when you use expressions to define resource bodies as the [`Spread`](../operator-spread.md) operator gets converted to a function. It's a limitation in JSON.
12+
13+
## Description
14+
15+
The spread operator "..." is not permitted in this location.
16+
17+
## Level
18+
19+
Error
20+
21+
## Examples
22+
23+
The following example raises the diagnostic because the `spread` operator is used to define the resource body:
24+
25+
```bicep
26+
param location string = resourceGroup().location
27+
param addressPrefix string = '10.0.0.0/24'
28+
29+
resource vnet 'Microsoft.Network/virtualNetworks@2024-01-01' = {
30+
name: 'vnetName'
31+
location: location
32+
33+
...(addressPrefix != '' ? {
34+
properties: {
35+
addressSpace: {
36+
addressPrefixes: [
37+
addressPrefix
38+
]
39+
}
40+
}
41+
} : {})
42+
}
43+
```
44+
45+
You can fix the diagnostic by using the operator in the lower level:
46+
47+
```bicep
48+
param location string = resourceGroup().location
49+
param addressPrefix string = '10.0.0.0/24'
50+
51+
resource vnet 'Microsoft.Network/virtualNetworks@2024-01-01' = {
52+
name: 'vnetName'
53+
location: location
54+
55+
properties: {
56+
addressSpace: {
57+
...(addressPrefix != '' ? {
58+
addressPrefixes: [
59+
addressPrefix
60+
]
61+
} : {})
62+
}
63+
}
64+
}
65+
```
66+
67+
## Next steps
68+
69+
For more information about Bicep diagnostics, see [Bicep core diagnostics](../bicep-core-diagnostics.md).

0 commit comments

Comments
 (0)