Skip to content

Commit b10b4d8

Browse files
Merge pull request #206577 from mumian/0729-linter-artifacts-parameters
new linter rule - artifacts-parameters
2 parents a3f2ffa + b66f784 commit b10b4d8

File tree

5 files changed

+73
-3
lines changed

5 files changed

+73
-3
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Linter settings for Bicep config
33
description: Describes how to customize configuration values for the Bicep linter
44
ms.topic: conceptual
5-
ms.date: 07/29/2022
5+
ms.date: 08/01/2022
66
---
77

88
# Add linter settings in the Bicep config file
@@ -26,6 +26,9 @@ The following example shows the rules that are available for configuration.
2626
"adminusername-should-not-be-literal": {
2727
"level": "warning"
2828
},
29+
"artifacts-parameters": {
30+
"level": "warning"
31+
},
2932
"no-hardcoded-env-urls": {
3033
"level": "warning"
3134
},
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
title: Linter rule - artifacts parameters
3+
description: Linter rule - artifacts parameters
4+
ms.topic: conceptual
5+
ms.date: 08/05/2022
6+
---
7+
8+
# Linter rule - artifacts parameters
9+
10+
This rule verifies whether the artifacts parameters are defined correctly. The following conditions must be met to pass the test:
11+
12+
- If you provide one parameter (either `_artifactsLocation` or `_artifactsLocationSasToken`), you must provide the other.
13+
- `_artifactsLocation` must be a string.
14+
- If `_artifactsLocation` has a default value, it must be either `deployment().properties.templateLink.uri` or a raw URL for its default value.
15+
- `_artifactsLocationSasToken` must be a secure string.
16+
- If `_artifactsLocationSasToken` has a default value, it must be an empty string.
17+
- If a referenced module has an `_artifactsLocation` or `_artifactsLocationSasToken` parameter, a value must be passed in for those parameters, even if they have default values in the module.
18+
19+
## Linter rule code
20+
21+
Use the following value in the [Bicep configuration file](bicep-config-linter.md) to customize rule settings:
22+
23+
`artifacts-parameters`
24+
25+
## Solution
26+
27+
The following example fails this test because `_artifactsLocationSasToken` is missing:
28+
29+
```bicep
30+
@description('The base URI where artifacts required by this template are located including a trailing \'/\'')
31+
param _artifactsLocation string = deployment().properties.templateLink.uri
32+
33+
...
34+
```
35+
36+
The next example fails this test because `_artifactsLocation` must be either `deployment().properties.templateLink.uri` or a raw URL when the default value is provided, and the default value of `_artifactsLocationSasToken` is not an empty string.
37+
38+
```bicep
39+
@description('The base URI where artifacts required by this template are located including a trailing \'/\'')
40+
param _artifactsLocation string = 'something'
41+
42+
@description('SAS Token for accessing script path')
43+
@secure()
44+
param _artifactsLocationSasToken string = 'something'
45+
46+
...
47+
````
48+
49+
This example passes this test.
50+
51+
```bicep
52+
@description('The base URI where artifacts required by this template are located including a trailing \'/\'')
53+
param _artifactsLocation string = deployment().properties.templateLink.uri
54+
55+
@description('SAS Token for accessing script path')
56+
@secure()
57+
param _artifactsLocationSasToken string = ''
58+
59+
...
60+
```
61+
62+
## Next steps
63+
64+
For more information about the linter, see [Use Bicep linter](./linter.md).

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ The linter is integrated into the Bicep CLI and the Bicep extension for Visual S
1818
The default set of linter rules is minimal and taken from [arm-ttk test cases](../templates/template-test-cases.md). The extension and Bicep CLI check the following rules, which are set to the warning level.
1919

2020
- [adminusername-should-not-be-literal](./linter-rule-admin-username-should-not-be-literal.md)
21+
- [artifacts-parameters](./linter-rule-artifacts-parameters.md)
2122
- [max-outputs](./linter-rule-max-outputs.md)
2223
- [max-params](./linter-rule-max-parameters.md)
2324
- [max-resources](./linter-rule-max-resources.md)

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,8 @@
354354
items:
355355
- name: Admin user name not literal
356356
href: linter-rule-admin-username-should-not-be-literal.md
357+
- name: Artifacts parameters
358+
href: linter-rule-artifacts-parameters.md
357359
- name: Max outputs
358360
href: linter-rule-max-outputs.md
359361
- name: Max parameters

articles/event-grid/toc.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ items:
2525
- name: Azure PowerShell
2626
href: ../storage/blobs/storage-blob-event-quickstart-powershell.md?toc=%2fazure%2fevent-grid%2ftoc.json
2727
- name: Bicep
28-
displayName: Resource Manager, ARM
28+
displayName: Resource Manager,ARM,template
2929
href: blob-event-quickstart-bicep.md
3030
- name: ARM template
3131
displayName: Resource Manager
@@ -289,7 +289,7 @@ items:
289289
- name: Get access keys for topics or domains
290290
href: get-access-keys.md
291291
- name: Get schema supported by a topic
292-
href: get-topic-schema.md
292+
href: get-topic-schema.md
293293
- name: Publish events custom topics using access keys
294294
href: post-to-custom-topic.md
295295
- name: Receive events at HTTP endpoint

0 commit comments

Comments
 (0)