Skip to content

Commit 4fc209a

Browse files
authored
Merge pull request #276731 from mumian/0529-bcp033
Bicep warnings and errors - BCP033 & BCP035
2 parents 1352f76 + 16eed3e commit 4fc209a

File tree

5 files changed

+500
-0
lines changed

5 files changed

+500
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
title: BCP033
3+
description: Error - Expected a value of type "{expectedType}" but the provided value is of type "{actualType}".
4+
ms.topic: reference
5+
ms.custom: devx-track-bicep
6+
ms.date: 06/28/2024
7+
---
8+
9+
# Bicep warning and error code - BCP033
10+
11+
This error occurs when you assign a value of a mismatched data type.
12+
13+
## Error description
14+
15+
`Expected a value of type "{expectedType}" but the provided value is of type "{actualType}".`
16+
17+
## Solution
18+
19+
Use the expected data type.
20+
21+
## Examples
22+
23+
The following example raises the error because the expected data type is a string. The actual provided value is an integer:
24+
25+
```bicep
26+
var myValue = 5
27+
28+
output myString string = myValue
29+
```
30+
31+
You can fix the error by providing a string value:
32+
33+
```bicep
34+
var myValue = '5'
35+
36+
output myString string = myValue
37+
```
38+
39+
## Next steps
40+
41+
For more information about Bicep warning and error codes, see [Bicep warnings and errors](./bicep-error-codes.md).
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
---
2+
title: BCP035
3+
description: Error - The specified <data-type> declaration is missing the following required properties.
4+
ms.topic: reference
5+
ms.custom: devx-track-bicep
6+
ms.date: 06/28/2024
7+
---
8+
9+
# Bicep warning and error code - BCP035
10+
11+
This warning occurs when your resource definition is missing a required property.
12+
13+
## Warning description
14+
15+
`The specified <date-type> declaration is missing the following required properties: <name-of-the-property.`
16+
17+
## Solution
18+
19+
Add the missing property to the resource definition.
20+
21+
## Examples
22+
23+
The following example raises the warning for **virtualNetworkGateway1** and **virtualNetworkGateway2**:
24+
25+
```bicep
26+
var networkConnectionName = 'testConnection'
27+
var location = 'eastus'
28+
var vnetGwAId = 'gatewayA'
29+
var vnetGwBId = 'gatewayB'
30+
31+
resource networkConnection 'Microsoft.Network/connections@2023-11-01' = {
32+
name: networkConnectionName
33+
location: location
34+
properties: {
35+
virtualNetworkGateway1: {
36+
id: vnetGwAId
37+
}
38+
virtualNetworkGateway2: {
39+
id: vnetGwBId
40+
}
41+
42+
connectionType: 'Vnet2Vnet'
43+
}
44+
}
45+
```
46+
47+
The warning is:
48+
49+
```warning
50+
The specified "object" declaration is missing the following required properties: "properties". If this is an inaccuracy in the documentation, please report it to the Bicep Team.
51+
```
52+
53+
You can verify the missing properties from the [template reference](/azure/templates). If you see the warning from Visual Studio Code, hover the cursor over the resource symbolic name and select **View document** to open the template reference.
54+
55+
You can fix the error by adding the missing properties:
56+
57+
```bicep
58+
var networkConnectionName = 'testConnection'
59+
var location = 'eastus'
60+
var vnetGwAId = 'gatewayA'
61+
var vnetGwBId = 'gatewayB'
62+
63+
resource networkConnection 'Microsoft.Network/connections@2023-11-01' = {
64+
name: networkConnectionName
65+
location: location
66+
properties: {
67+
virtualNetworkGateway1: {
68+
id: vnetGwAId
69+
properties:{}
70+
}
71+
virtualNetworkGateway2: {
72+
id: vnetGwBId
73+
properties:{}
74+
}
75+
76+
connectionType: 'Vnet2Vnet'
77+
}
78+
}
79+
```
80+
81+
## Next steps
82+
83+
For more information about Bicep warning and error codes, see [Bicep warnings and errors](./bicep-error-codes.md).
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
title: BCP072
3+
description: Error - This symbol cannot be referenced here. Only other parameters can be referenced in parameter default values.
4+
ms.topic: reference
5+
ms.custom: devx-track-bicep
6+
ms.date: 07/02/2024
7+
---
8+
9+
# Bicep warning and error code - BCP072
10+
11+
This error occurs when you reference a variable in parameter default values.
12+
13+
## Error description
14+
15+
`This symbol cannot be referenced here. Only other parameters can be referenced in parameter default values.`
16+
17+
## Solution
18+
19+
Reference another parameter instead.
20+
21+
## Examples
22+
23+
The following example raises the error because the parameter default value references a variable:
24+
25+
```bicep
26+
param foo string = bar
27+
28+
var bar = 'HelloWorld!'
29+
```
30+
31+
You can fix the error by referencing another parameter:
32+
33+
```bicep
34+
param foo string = bar
35+
param bar string = 'HelloWorld!'
36+
37+
output outValue string = foo
38+
```
39+
40+
## Next steps
41+
42+
For more information about Bicep warning and error codes, see [Bicep warnings and errors](./bicep-error-codes.md).

0 commit comments

Comments
 (0)