|
| 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). |
0 commit comments