You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-resource-manager/bicep/bicep-config.md
+102-5Lines changed: 102 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,14 +3,12 @@ title: Bicep config file
3
3
description: Describes the configuration file for your Bicep deployments
4
4
ms.topic: conceptual
5
5
ms.custom: devx-track-bicep
6
-
ms.date: 09/27/2023
6
+
ms.date: 02/02/2024
7
7
---
8
8
9
9
# Configure your Bicep environment
10
10
11
-
Bicep supports an optional configuration file named `bicepconfig.json`. Within this file, you can add values that customize your Bicep development experience.
12
-
13
-
To customize configuration, create this file in the same directory, or a parent directory of your Bicep files. If multiple parent directories contain `bicepconfig.json` files, Bicep uses configuration from the nearest one. If a configuration file is not found, Bicep uses default values.
11
+
Bicep supports an optional configuration file named `bicepconfig.json`. Within this file, you can add values that customize your Bicep development experience. This file is merged with the [default configuration file](https://github.com/Azure/bicep/blob/main/src/Bicep.Core/Configuration/bicepconfig.json). For more information, see [Understand the merge process](#understand-the-merge-process). To customize configuration, create a configuration file in the same directory or a parent directory of your Bicep files. If there are multiple parent directories containing `bicepconfig.json` files, Bicep uses the configuration from the nearest one. For more information, see [Understand the file resolution process](#understand-the-file-resolution-process).
14
12
15
13
To configure Bicep extension settings, see [VS Code and Bicep extension](./install.md#visual-studio-code-and-bicep-extension).
16
14
@@ -26,6 +24,105 @@ The Bicep extension for Visual Studio Code supports intellisense for your `bicep
26
24
27
25
:::image type="content" source="./media/bicep-config/bicep-linter-configure-intellisense.png" alt-text="Screenshot of the intellisense support in configuring bicepconfig.json.":::
28
26
27
+
## Understand the merge process
28
+
29
+
The `bicepconfig.json` file undergoes a recursive bottom-up merging process with the default configuration file. During the merging process, Bicep examines each path in both configurations. If a path isn't present in the default configuration, the path and its associated value are added in the final result. Conversely, if a path exists in the default configuration with a different value, the value from `bicepconfig.json` takes precedence in the merged result.
30
+
31
+
Consider a scenario where the default configuration is defined as follows:
32
+
33
+
```json
34
+
{
35
+
"cloud": {
36
+
...
37
+
"credentialPrecedence": [
38
+
"AzureCLI",
39
+
"AzurePowerShell"
40
+
]
41
+
},
42
+
"moduleAliases": {
43
+
"ts": {},
44
+
"br": {
45
+
"public": {
46
+
"registry": "mcr.microsoft.com",
47
+
"modulePath": "bicep"
48
+
}
49
+
}
50
+
},
51
+
...
52
+
}
53
+
```
54
+
55
+
And the `bicepconfig.json` is defined as follows:
56
+
57
+
```json
58
+
{
59
+
"cloud": {
60
+
"credentialPrecedence": [
61
+
"AzurePowerShell",
62
+
"AzureCLI"
63
+
]
64
+
},
65
+
"moduleAliases": {
66
+
"br": {
67
+
"ContosoRegistry": {
68
+
"registry": "contosoregistry.azurecr.io"
69
+
},
70
+
"CoreModules": {
71
+
"registry": "contosoregistry.azurecr.io",
72
+
"modulePath": "bicep/modules/core"
73
+
}
74
+
}
75
+
}
76
+
}
77
+
```
78
+
79
+
The resulting merged configuration would be:
80
+
81
+
```json
82
+
{
83
+
"cloud": {
84
+
...
85
+
"credentialPrecedence": [
86
+
"AzurePowerShell",
87
+
"AzureCLI"
88
+
]
89
+
},
90
+
"moduleAliases": {
91
+
"ts": {},
92
+
"br": {
93
+
"public": {
94
+
"registry": "mcr.microsoft.com",
95
+
"modulePath": "bicep"
96
+
},
97
+
"ContosoRegistry": {
98
+
"registry": "contosoregistry.azurecr.io"
99
+
},
100
+
"CoreModules": {
101
+
"registry": "contosoregistry.azurecr.io",
102
+
"modulePath": "bicep/modules/core"
103
+
}
104
+
}
105
+
},
106
+
...
107
+
}
108
+
```
109
+
110
+
In the preceding example, the value of `cloud.credentialPrecedence` is replaced, while the value of `cloud.moduleAliases.ContosoRegistry` and `cloud.moduleAliases.CoreModules` are appended in the merged configuration.
111
+
112
+
## Understand the file resolution process
113
+
114
+
The `bicepconfig.json` file can be placed in the same directory or a parent directory of your Bicep files. If there are multiple parent directories containing `bicepconfig.json` files, Bicep uses the configuration file from the nearest one. For instance, in the given folder structure where each folder has a `bicepconfig.json` file:
115
+
116
+
:::image type="content" source="./media/bicep-config/bicep-config-file-resolve.png" alt-text="A diagram showing resolving `bicepconfig.json` found in multiple parent folders.":::
117
+
118
+
If you compile `main.bicep` in the `child` folder, the `bicepconfig.json` file in the `child` folder is used. The configuration files in the `parent` folder and the `root` folder are ignored. If the `child` folder doesn't contain a configuration file, Bicep searches for a configuration in the `parent` folder and then the `root` folder. If no configuration file is found in any of the folders, Bicep defaults to using the [default values](https://github.com/Azure/bicep/blob/main/src/Bicep.Core/Configuration/bicepconfig.json).
119
+
120
+
In the context of a Bicep file invoking multiple modules, each module undergoes compilation using the nearest `bicepconfig.json`. Then, the main Bicep file is compiled with its corresponding `bicepconfig.json`. In the following scenario, `modA.bicep` is compiled using the `bicepconfig.json` located in the `A` folder, `modB.bicep` is compiled with the `bicepconfig.json` in the `B` folder, and finally, `main.bicep` is compiled using the `bicepconfig.json` in the `root` folder.
121
+
122
+
:::image type="content" source="./media/bicep-config/bicep-config-file-resolve-module.png" alt-text="A diagram showing resolving `bicepconfig.json` found in multiple parent folders with the module scenario.":::
123
+
124
+
In the absence of a `bicepconfig.json` file in the `A` and `B` folders, all three Bicep files are compiled using the `bicepconfig.json` found in the `root` folder. If `bicepconfig.json` isn't present in any of the folders, the compilation process defaults to using the [default values](https://github.com/Azure/bicep/blob/main/src/Bicep.Core/Configuration/bicepconfig.json).
125
+
29
126
## Configure Bicep modules
30
127
31
128
When working with [modules](modules.md), you can add aliases for module paths. These aliases simplify your Bicep file because you don't have to repeat complicated paths. You can also configure cloud profile and credential precedence for authenticating to Azure from Bicep CLI and Visual Studio Code. The credentials are used to publish modules to registries and to restore external modules to the local cache when using the insert resource function. For more information, see [Add module settings to Bicep config](bicep-config-modules.md).
@@ -38,7 +135,7 @@ The [Bicep linter](linter.md) checks Bicep files for syntax errors and best prac
38
135
39
136
You can enable experimental features by adding the following section to your `bicepconfig.json` file.
40
137
41
-
Here is an example of enabling features 'compileTimeImports' and 'userDefinedFunctions`.
138
+
Here's an example of enabling features 'compileTimeImports' and 'userDefinedFunctions`.
Copy file name to clipboardExpand all lines: articles/azure-resource-manager/bicep/modules.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ title: Bicep modules
3
3
description: Describes how to define a module in a Bicep file, and how to use module scopes.
4
4
ms.topic: conceptual
5
5
ms.custom: devx-track-bicep
6
-
ms.date: 10/13/2023
6
+
ms.date: 02/02/2024
7
7
---
8
8
9
9
# Bicep modules
@@ -19,7 +19,7 @@ To share modules with other people in your organization, create a [template spec
19
19
> - Content in the Bicep module registry can only be deployed from another Bicep file. Template specs can be deployed directly from the API, Azure PowerShell, Azure CLI, and the Azure portal. You can even use [`UiFormDefinition`](../templates/template-specs-create-portal-forms.md) to customize the portal deployment experience.
20
20
> - Bicep has some limited capabilities for embedding other project artifacts (including non-Bicep and non-ARM-template files. For example, PowerShell scripts, CLI scripts and other binaries) by using the [`loadTextContent`](./bicep-functions-files.md#loadtextcontent) and [`loadFileAsBase64`](./bicep-functions-files.md#loadfileasbase64) functions. Template specs can't package these artifacts.
21
21
22
-
Bicep modules are converted into a single Azure Resource Manager template with [nested templates](../templates/linked-templates.md#nested-template).
22
+
Bicep modules are converted into a single Azure Resource Manager template with [nested templates](../templates/linked-templates.md#nested-template). For more information about how Bicep resolves configuration files and how Bicep merge user-defined configuration file with the default configuration file, see [Configuration file resolution process](./bicep-config.md#understand-the-file-resolution-process) and [Configuration file merge process](./bicep-config.md#understand-the-merge-process).
0 commit comments