Skip to content

Commit 738dd7d

Browse files
authored
Merge pull request #254799 from mumian/1012-linter-no-deployments-resource
new linter rule - no deployments resources
2 parents 6d76b09 + c40b471 commit 738dd7d

File tree

4 files changed

+50
-1
lines changed

4 files changed

+50
-1
lines changed

articles/azure-resource-manager/bicep/bicep-config-linter.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ The following example shows the rules that are available for configuration.
4848
"no-conflicting-metadata" : {
4949
"level": "warning"
5050
},
51+
"no-deployments-resources" : {
52+
"level": "warning"
53+
}
5154
"no-hardcoded-env-urls": {
5255
"level": "warning"
5356
},
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
title: Linter rule - no deployments resources
3+
description: Linter rule - no deployments resources
4+
ms.topic: conceptual
5+
ms.custom: devx-track-bicep
6+
ms.date: 10/12/2023
7+
---
8+
9+
# Linter rule - no deployments resources
10+
11+
This linter rule issues a warning when a template contains a `Microsoft.Resources/deployments` resource on the root level.
12+
13+
## Linter rule code
14+
15+
Use the following value in the [Bicep configuration file](bicep-config-linter.md) to customize rule settings:
16+
17+
`no-deployments-resources`
18+
19+
## Solution
20+
21+
The following example fails this test because the template contains a `Microsoft.Resources/deployments` resource on the root level.
22+
23+
```bicep
24+
param name string
25+
param specId string
26+
resource foo 'Microsoft.Resources/deployments@2023-07-01' = {
27+
name: name
28+
properties: {
29+
mode: 'Incremental'
30+
templateLink: {
31+
uri: specId
32+
}
33+
parameters: {}
34+
}
35+
}
36+
```
37+
38+
It should be declared as a [Bicep module](./modules.md).
39+
40+
## Next steps
41+
42+
For more information about the linter, see [Use Bicep linter](./linter.md).

articles/azure-resource-manager/bicep/linter.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ The default set of linter rules is minimal and taken from [arm-ttk test cases](.
2626
- [max-resources](./linter-rule-max-resources.md)
2727
- [max-variables](./linter-rule-max-variables.md)
2828
- [no-conflicting-metadata](./linter-rule-no-conflicting-metadata.md)
29+
- [no-deployments-resources](./linter-rule-no-deployments-resources.md)
2930
- [no-hardcoded-env-urls](./linter-rule-no-hardcoded-environment-urls.md)
3031
- [no-hardcoded-location](./linter-rule-no-hardcoded-location.md)
3132
- [no-loc-expr-outside-params](./linter-rule-no-loc-expr-outside-params.md)
@@ -79,7 +80,7 @@ You can integrate these checks as a part of your CI/CD pipelines. You can use a
7980

8081
## Silencing false positives
8182

82-
Sometimes a rule can have false positives. For example, you may need to include a link to a blob storage directly without using the [environment()](./bicep-functions-deployment.md#environment) function.
83+
Sometimes a rule can have false positives. For example, you might need to include a link to a blob storage directly without using the [environment()](./bicep-functions-deployment.md#environment) function.
8384
In this case you can disable the warning for one line only, not the entire document, by adding `#disable-next-line <rule name>` before the line with the warning.
8485

8586
```bicep

articles/azure-resource-manager/bicep/toc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,9 @@
447447
- name: No conflicting metadata
448448
displayName: linter
449449
href: linter-rule-no-conflicting-metadata.md
450+
- name: No deployments resources
451+
displayName: linter
452+
href: linter-rule-no-deployments-resources.md
450453
- name: No hardcoded environment URLs
451454
displayName: linter
452455
href: linter-rule-no-hardcoded-environment-urls.md

0 commit comments

Comments
 (0)