Skip to content

Commit b08f49a

Browse files
Merge pull request #284204 from mumian/0807-error-codes-bcp055
Document bcp018, 057, 062, 192, 288, 294, 302, 401
2 parents 039deb3 + 162a3d7 commit b08f49a

File tree

16 files changed

+657
-172
lines changed

16 files changed

+657
-172
lines changed

articles/azure-resource-manager/bicep/bicep-core-diagnostics.md

Lines changed: 167 additions & 167 deletions
Large diffs are not rendered by default.

articles/azure-resource-manager/bicep/data-types.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,12 @@ type oneOfSeveralObjects = {foo: 'bar'} | {fizz: 'buzz'} | {snap: 'crackle'}
329329
type mixedTypeArray = ('fizz' | 42 | {an: 'object'} | null)[]
330330
```
331331

332+
Type unions must be reducible to a single ARM type, such as 'string', 'int', or 'bool'. Otherwise, you get the [BCP294](./diagnostics/bcp294.md) error code. For example:
333+
334+
```bicep
335+
type foo = 'a' | 1
336+
```
337+
332338
Any type expression can be used as a sub-type in a union type declaration (between `|` characters). For example, the following examples are all valid:
333339

334340
```bicep
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
title: BCP018
3+
description: Error - Expected the <character> character at this location.
4+
ms.topic: reference
5+
ms.custom: devx-track-bicep
6+
ms.date: 08/08/2024
7+
---
8+
9+
# Bicep error code - BCP018
10+
11+
This error occurs when a character, such as a bracket, is missing.
12+
13+
## Error description
14+
15+
`Expected the <character> character at this location.`
16+
17+
## Solution
18+
19+
Add the missing character.
20+
21+
## Examples
22+
23+
The following example raises the error because the code is missing a _}_.
24+
25+
```bicep
26+
output tennisBall object = {
27+
type: 'tennis'
28+
color: 'yellow'
29+
```
30+
31+
You can fix the error by adding the missing _}_.
32+
33+
```bicep
34+
output tennisBall object = {
35+
type: 'tennis'
36+
color: 'yellow'
37+
}
38+
```
39+
40+
The following example raises the error because the code is missing a _]_.
41+
42+
```bicep
43+
output colors array = [
44+
'red'
45+
'blue'
46+
'white'
47+
```
48+
49+
You can fix the error by adding the missing _]_.
50+
51+
```bicep
52+
output colors array = [
53+
'red'
54+
'blue'
55+
'white'
56+
]
57+
```
58+
59+
## Next steps
60+
61+
For more information about Bicep error and warning codes, see [Bicep core diagnostics](../bicep-core-diagnostics.md).

articles/azure-resource-manager/bicep/diagnostics/bcp053.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ This error/warning occurs when you reference a property that isn't defined in th
1616

1717
## Solution
1818

19-
Reference the correct property name
19+
Reference the correct property name.
2020

2121
## Examples
2222

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
title: BCP055
3+
description: Error - Cannot access properties of type <type-name>. A <type-name> type is required.
4+
ms.topic: reference
5+
ms.custom: devx-track-bicep
6+
ms.date: 08/07/2024
7+
---
8+
9+
# Bicep error code - BCP055
10+
11+
This error occurs when you reference a nonexistent property of a type.
12+
13+
## Error description
14+
15+
`Cannot access properties of type <type-name>. A <type-name> type is required.`
16+
17+
## Examples
18+
19+
The following example raises the error because _string.bar_ isn't defined:
20+
21+
```bicep
22+
type foo = string.bar
23+
```
24+
25+
You can fix the error by removing the reference:
26+
27+
```bicep
28+
type foo = string
29+
```
30+
31+
## Next steps
32+
33+
For more information about Bicep error and warning codes, see [Bicep core diagnostics](../bicep-core-diagnostics.md).
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
title: BCP057
3+
description: Error - The name <name> doesn't exist in the current context.
4+
ms.topic: reference
5+
ms.custom: devx-track-bicep
6+
ms.date: 08/08/2024
7+
---
8+
9+
# Bicep error code - BCP057
10+
11+
This error occurs when the referenced name doesn't exist, either because of a typo or because it hasn't been declared.
12+
13+
## Error description
14+
15+
`The name <name> does not exist in the current context.`
16+
17+
## Solution
18+
19+
Fix the typo or declare the name.
20+
21+
## Examples
22+
23+
The following example raises the error because _bar_ has never been declared:
24+
25+
```bicep
26+
var foo = bar
27+
```
28+
29+
The following example raises the error because _bar1_ is a typo:
30+
31+
```bicep
32+
var bar = 'white'
33+
var foo = bar1
34+
```
35+
36+
You can fix the error by declaring _bar_, or fix the typo.
37+
38+
```bicep
39+
var bar = 'white'
40+
var foo = bar
41+
```
42+
43+
## Next steps
44+
45+
For more information about Bicep error and warning codes, see [Bicep core diagnostics](../bicep-core-diagnostics.md).
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
title: BCP062
3+
description: Error - The referenced declaration with name <type-name> is not valid.
4+
ms.topic: reference
5+
ms.custom: devx-track-bicep
6+
ms.date: 08/08/2024
7+
---
8+
9+
# Bicep error code - BCP062
10+
11+
This error occurs when the referenced declaration has an error.
12+
13+
## Error description
14+
15+
`The referenced declaration with name <type-name> is not valid.`
16+
17+
## Examples
18+
19+
The following example raises the error because the referenced [user-defined data type](../user-defined-data-types.md) has an error:
20+
21+
```bicep
22+
type ball = object.bar
23+
24+
output tennisBall ball = {
25+
name: 'tennis'
26+
color: 'yellow'
27+
}
28+
```
29+
30+
You can fix the error by fixing the _ball_ definition:
31+
32+
```bicep
33+
type ball = object
34+
35+
output tennisBall ball = {
36+
name: 'tennis'
37+
color: 'yellow'
38+
}
39+
```
40+
41+
## Next steps
42+
43+
For more information about Bicep error and warning codes, see [Bicep core diagnostics](../bicep-core-diagnostics.md).

articles/azure-resource-manager/bicep/diagnostics/bcp089.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ This error/warning occurs when a property name seems to be a typo.
1212

1313
## Error/warning description
1414

15-
`The property <property-name> is not allowed on objects of type <resource-type>. Did you mean <property-name>?`
15+
`The property <property-name> is not allowed on objects of type <resource-type/type-definition>. Did you mean <property-name>?`
16+
17+
## Solution
18+
19+
Fix the typo.
1620

1721
## Examples
1822

@@ -32,6 +36,34 @@ resource storageAccount 'Microsoft.Storage/storageAccounts@2023-05-01' existing
3236
}
3337
```
3438

39+
The following example raises the error because the property name _color1_ looks like a typo.
40+
41+
```bicep
42+
type ball = {
43+
name: string
44+
color: string
45+
}
46+
47+
output tennisBall ball = {
48+
name: 'tennis'
49+
color1: 'yellow'
50+
}
51+
```
52+
53+
You can fix the error by correcting the typo:
54+
55+
```bicep
56+
type ball = {
57+
name: string
58+
color: string
59+
}
60+
61+
output tennisBall ball = {
62+
name: 'tennis'
63+
color: 'yellow'
64+
}
65+
```
66+
3567
## Next steps
3668

3769
For more information about Bicep error and warning codes, see [Bicep warnings and errors](../bicep-core-diagnostics.md).
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
title: BCP192
3+
description: Error - Unable to restore the artifact with reference <reference>.
4+
ms.topic: reference
5+
ms.custom: devx-track-bicep
6+
ms.date: 08/08/2024
7+
---
8+
9+
# Bicep error code - BCP192
10+
11+
This error occurs when Bicep can't copy the external module to the local cache. For example, an incorrect module reference. For more information about using modules in Bicep and Bicep restore, see [Bicep modules](../modules.md).
12+
13+
## Error description
14+
15+
`Unable to restore the artifact with reference <reference>: <error-message>.`
16+
17+
## Solution
18+
19+
Fix the module reference.
20+
21+
## Examples
22+
23+
The following example raises the error because the public module version doesn't exist:
24+
25+
```bicep
26+
module storage 'br/public:avm/res/storage/storage-account:0.1.0' = {
27+
name: 'myStorage'
28+
params: {
29+
name: 'store${resourceGroup().name}'
30+
}
31+
}
32+
```
33+
34+
The following example raises the error because there is a typo in the reference:
35+
36+
```bicep
37+
module storage 'br/public:avm/res/storage/storage-account1:0.11.1' = {
38+
name: 'myStorage'
39+
params: {
40+
name: 'store${resourceGroup().name}'
41+
}
42+
}
43+
```
44+
45+
You can fix the error by correct the AVM reference and the version:
46+
47+
```bicep
48+
module storage 'br/public:avm/res/storage/storage-account:0.11.1' = {
49+
name: 'myStorage'
50+
params: {
51+
name: 'store${resourceGroup().name}'
52+
}
53+
}
54+
```
55+
56+
## Next steps
57+
58+
For more information about Bicep error and warning codes, see [Bicep core diagnostics](../bicep-core-diagnostics.md).
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
title: BCP288
3+
description: Error - <name> refers to a type but is being used as a value here.
4+
ms.topic: reference
5+
ms.custom: devx-track-bicep
6+
ms.date: 08/08/2024
7+
---
8+
9+
# Bicep error code - BCP288
10+
11+
This error occurs when the name specified is a type, but it's being used as a value.
12+
13+
## Error description
14+
15+
`<name> refers to a type but is being used as a value here.`
16+
17+
## Solution
18+
19+
Use a name of a value.
20+
21+
## Examples
22+
23+
The following example raises the error because _bar_ is a name of a [user-defined data type](../user-defined-data-types.md), not a value:
24+
25+
```bicep
26+
type bar = 'white'
27+
var foo = bar
28+
```
29+
30+
You can fix the error by assigning a value to the variable _foo_:
31+
32+
```bicep
33+
var bar = 'white'
34+
var foo = bar
35+
```
36+
37+
## Next steps
38+
39+
For more information about Bicep error and warning codes, see [Bicep core diagnostics](../bicep-core-diagnostics.md).

0 commit comments

Comments
 (0)