Skip to content

Commit 089861d

Browse files
authored
Merge pull request #180033 from tfitzmac/1115config
split config file
2 parents 786ba06 + 6f4e8f3 commit 089861d

File tree

8 files changed

+277
-217
lines changed

8 files changed

+277
-217
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ For example:
132132
az bicep publish storage.bicep --target br:exampleregistry.azurecr.io/bicep/modules/storage:v1
133133
```
134134

135-
The `publish` command doesn't recognize aliases that you've defined in a [bicepconfig.json](bicep-config.md) file. Provide the full module path.
135+
The `publish` command doesn't recognize aliases that you've defined in a [bicepconfig.json](bicep-config-modules.md) file. Provide the full module path.
136136

137137
> [!WARNING]
138138
> Publishing to the same target overwrites the old module. We recommend that you increment the version when updating.
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
---
2+
title: Linter settings for Bicep config
3+
description: Describes how to customize configuration values for the Bicep linter
4+
ms.topic: conceptual
5+
ms.date: 11/16/2021
6+
---
7+
8+
# Add linter settings in the Bicep config file
9+
10+
In a **bicepconfig.json** file, you can customize validation settings for the [Bicep linter](linter.md). The linter uses these settings when evaluating your Bicep files for best practices.
11+
12+
This article describes the settings that are available for working with the Bicep linter.
13+
14+
## Customize linter
15+
16+
The linter settings are available under the `analyzers` element. You can enable or disable the linter, supply rule-specific values, and set the level of rules.
17+
18+
The following example shows the rules that are available for configuration.
19+
20+
```json
21+
{
22+
"analyzers": {
23+
"core": {
24+
"enabled": true,
25+
"verbose": true,
26+
"rules": {
27+
"no-hardcoded-env-urls": {
28+
"level": "warning"
29+
},
30+
"no-unused-params": {
31+
"level": "error"
32+
},
33+
"no-unused-vars": {
34+
"level": "error"
35+
},
36+
"prefer-interpolation": {
37+
"level": "warning"
38+
},
39+
"secure-parameter-default": {
40+
"level": "error"
41+
},
42+
"simplify-interpolation": {
43+
"level": "warning"
44+
}
45+
}
46+
}
47+
}
48+
}
49+
```
50+
51+
The properties are:
52+
53+
- **enabled**: specify **true** for enabling linter, **false** for disabling linter.
54+
- **verbose**: specify **true** to show the bicepconfig.json file used by Visual Studio Code.
55+
- **rules**: specify rule-specific values. Each rule has a level that determines how the linter responds when a violation is found.
56+
57+
The available values for **level** are:
58+
59+
| **level** | **Build-time behavior** | **Editor behavior** |
60+
|--|--|--|
61+
| `Error` | Violations appear as Errors in command-line build output, and causes the build to fail. | Offending code is underlined with a red squiggle and appears in Problems tab. |
62+
| `Warning` | Violations appear as Warnings in command-line build output, but they don't cause the build to fail. | Offending code is underlined with a yellow squiggle and appears in Problems tab. |
63+
| `Info` | Violations don't appear in the command-line build output. | Offending code is underlined with a blue squiggle and appears in Problems tab. |
64+
| `Off` | Suppressed completely. | Suppressed completely. |
65+
66+
## Environment URLs
67+
68+
For the rule about hardcoded environment URLs, you can customize which URLs are checked. By default, the following settings are applied:
69+
70+
```json
71+
{
72+
"analyzers": {
73+
"core": {
74+
"verbose": false,
75+
"enabled": true,
76+
"rules": {
77+
"no-hardcoded-env-urls": {
78+
"level": "warning",
79+
"disallowedhosts": [
80+
"management.core.windows.net",
81+
"gallery.azure.com",
82+
"management.core.windows.net",
83+
"management.azure.com",
84+
"database.windows.net",
85+
"core.windows.net",
86+
"login.microsoftonline.com",
87+
"graph.windows.net",
88+
"trafficmanager.net",
89+
"vault.azure.net",
90+
"datalake.azure.net",
91+
"azuredatalakestore.net",
92+
"azuredatalakeanalytics.net",
93+
"vault.azure.net",
94+
"api.loganalytics.io",
95+
"api.loganalytics.iov1",
96+
"asazure.windows.net",
97+
"region.asazure.windows.net",
98+
"api.loganalytics.iov1",
99+
"api.loganalytics.io",
100+
"asazure.windows.net",
101+
"region.asazure.windows.net",
102+
"batch.core.windows.net"
103+
],
104+
"excludedhosts": [
105+
"schema.management.azure.com"
106+
]
107+
}
108+
}
109+
}
110+
}
111+
}
112+
```
113+
114+
## Next steps
115+
116+
* [Configure your Bicep environment](bicep-config.md)
117+
* [Add module settings in Bicep config](bicep-config-modules.md)
118+
* Learn about the [Bicep linter](linter.md)
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
---
2+
title: Module setting for Bicep config
3+
description: Describes how to customize configuration values for modules in Bicep deployments.
4+
ms.topic: conceptual
5+
ms.date: 11/16/2021
6+
---
7+
8+
# Add module settings in the Bicep config file
9+
10+
In a **bicepconfig.json** file, you can create aliases for module paths and configure credential precedence for restoring a module.
11+
12+
This article describes the settings that are available for working with [modules](modules.md).
13+
14+
## Aliases for modules
15+
16+
To simplify the path for linking to modules, create aliases in the config file. An alias refers to either a module registry or a resource group that contains template specs.
17+
18+
The config file has a property for `moduleAliases`. This property contains all of the aliases you define. Under this property, the aliases are divided based on whether they refer to a registry or a template spec.
19+
20+
To create an alias for a **Bicep registry**, add a `br` property. To add an alias for a **template spec**, use the `ts` property.
21+
22+
```json
23+
{
24+
"moduleAliases": {
25+
"br": {
26+
<add-registry-aliases>
27+
},
28+
"ts": {
29+
<add-template-specs-aliases>
30+
}
31+
}
32+
}
33+
```
34+
35+
Within the `br` property, add as many aliases as you need. For each alias, give it a name and the following properties:
36+
37+
- **registry** (required): registry login server name
38+
- **modulePath** (optional): registry repository where the modules are stored
39+
40+
Within the `ts` property, add as many aliases as you need. For each alias, give it a name and the following properties:
41+
42+
- **subscription** (required): the subscription ID that hosts the template specs
43+
- **resourceGroup** (required): the name of the resource group that contains the template specs
44+
45+
The following example shows a config file that defines two aliases for a module registry, and one alias for a resource group that contains template specs.
46+
47+
```json
48+
{
49+
"moduleAliases": {
50+
"br": {
51+
"ContosoRegistry": {
52+
"registry": "contosoregistry.azurecr.io"
53+
},
54+
"CoreModules": {
55+
"registry": "contosoregistry.azurecr.io",
56+
"modulePath": "bicep/modules/core"
57+
}
58+
},
59+
"ts": {
60+
"CoreSpecs": {
61+
"subscription": "00000000-0000-0000-0000-000000000000",
62+
"resourceGroup": "CoreSpecsRG"
63+
}
64+
}
65+
}
66+
}
67+
```
68+
69+
When using an alias in the module reference, you must use the formats:
70+
71+
```bicep
72+
br/<alias>:<file>:<tag>
73+
ts/<alias>:<file>:<tag>
74+
```
75+
76+
Define your aliases to the folder or resource group that contains modules, not the file itself. The file name must be included in the reference to the module.
77+
78+
**Without the aliases**, you would link to a module in a registry with the full path.
79+
80+
```bicep
81+
module stgModule 'br:contosoregistry.azurecr.io/bicep/modules/core/storage:v1' = {
82+
```
83+
84+
**With the aliases**, you can simplify the link by using the alias for the registry.
85+
86+
```bicep
87+
module stgModule 'br/ContosoRegistry:bicep/modules/core/storage:v1' = {
88+
```
89+
90+
Or, you can simplify the link by using the alias that specifies the registry and module path.
91+
92+
```bicep
93+
module stgModule 'br/CoreModules:storage:v1' = {
94+
```
95+
96+
For a template spec, use:
97+
98+
```bicep
99+
module stgModule 'ts/CoreSpecs:storage:v1' = {
100+
```
101+
102+
## Credentials for restoring modules
103+
104+
To [restore](bicep-cli.md#restore) external modules to the local cache, the account must have the correct permissions to access the registry. You can configure the credential precedence for authenticating to the registry. By default, Bicep uses the credentials from the user authenticated in Azure CLI or Azure PowerShell. To customize the credential precedence, add `cloud` and `credentialPrecedence` elements to the config file.
105+
106+
```json
107+
{
108+
"cloud": {
109+
"credentialPrecedence": [
110+
"AzureCLI",
111+
"AzurePowerShell"
112+
]
113+
}
114+
}
115+
```
116+
117+
The available credentials are:
118+
119+
* AzureCLI
120+
* AzurePowerShell
121+
* Environment
122+
* ManagedIdentity
123+
* VisualStudio
124+
* VisualStudioCode
125+
126+
## Next steps
127+
128+
* [Configure your Bicep environment](bicep-config.md)
129+
* [Add linter settings to Bicep config](bicep-config-linter.md)
130+
* Learn about [modules](modules.md)

0 commit comments

Comments
 (0)