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: README.md
+17-15Lines changed: 17 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
1
# Configuration Builders
2
2
3
3
Configuration Builders are a new feature of the full .Net Framework, introduced in .Net 4.7.1. You can read about the concept in [this blog post](http://jeffreyfritz.com/2017/11/modern-configuration-for-asp-net-4-7-1-with-configurationbuilders/).
4
-
With this project, Microsoft is providing a basic set of Configuration Builders that should make it easy for developers to get started with the new feature. They
5
-
are also intended to address some of the basic needs of applications as they move into a container and cloud focused environment.
4
+
With this project, Microsoft is providing a basic set of Configuration Builders that should make it easy for developers to leverage this feature in their apps. They
5
+
are also intended to address some of the basic dynamic/non-local configuration needs of applications as they move into a container and cloud focused environment.
6
6
7
7
### V2 Update:
8
8
Version 2 is here with some new features:
@@ -11,13 +11,14 @@ Version 2 is here with some new features:
11
11
read initialization parameters for config builders from `appSettings`. Read more about it [here](#appsettings-parameters).
12
12
* Lazy Initialization - As part of the work to enable pulling config parameters from `appSettings`, these key/value configuration builders now support a
13
13
lazy initialization model. Things that must happen immediately can be left in the existing `Initialize(name, config)` method, or builders can leverage
14
-
the `LazyInitialize(name, config)` method for things that can happen just before retrieving values. All builders in this project have been updated to
14
+
the new `LazyInitialize(name, config)` method for things that can happen just before retrieving values. All builders in this project have been updated to
15
15
be lazy whenever possible.
16
16
* Updateable Keys - Builders can now massage key names before inserting into config. The [AzureKeyVaultConfigBuilder](#azurekeyvaultconfigbuilder) has been
17
17
updated to use this feature to allow embedding 'version' tags in key names instead of applying a single 'version' tag to the builder. (Note: This is
18
18
seperate from, and performed *after* prefix stripping.)
19
19
* Base Optional Tag - The [optional](#optional) tag that some of the builders in this project employed in V1 has been moved into the base class and is now available
20
20
on all key/value config builders.
21
+
* Escaping Expanded Values - It is possible to xml-escape inserted values in `Expand` mode now using the new [escapeExpandedValues](#escapeexpandedvalues) attribute.
21
22
* Section Handlers - This feature allows users to develop extensions that will apply key/value config to sections other than `appSettings` and `connectionStrings`
22
23
if desired. Read more about this feature in the [Section Handlers](#section-handlers) segment below.
23
24
@@ -117,11 +118,10 @@ configuration section) there are limitations when using this feature on the `app
117
118
is enabled - __but__ it can only draw on values that were hard-coded, or inserted into `appSettings` by config builders that execute before it in the builder chain.
118
119
119
120
Although most initialization parameters can take advantage of this flexibility, it might not always make sense to apply this technique to all parameters. Of the
120
-
base parameters defined for all key/value config builders, `mode` and `tokenPrefix` stand out as the two that *do not allow* reading from `appSettings`. *To make
121
-
it easier to identify parameters that do allow appSettings substitution, in the definitions below of builders available in this project, such parameter names are
122
-
preceded with an '@' symbol.
121
+
base parameters defined for all key/value config builders, `mode` and `tokenPrefix` stand out as the two that *do not allow* reading from `appSettings`.
123
122
124
123
## Config Builders In This Project
124
+
*Note about following codeboxes: Parameters inside `[]`s are optional. Parameters grouped in `()`s are mutually exclusive. Parameters beginning with `@` allow appSettings substitution. The first line of parameters are common to all builders and optional. Their meaning and use are [documented above](#keyvalue-config-builders) and they are grouped on one line for brevity. Because different builders have a different default value for `optional`, this default is also specified in this first line summary of common attributes.*
125
125
126
126
### EnvironmentConfigBuilder
127
127
```xml
@@ -154,7 +154,7 @@ builder, the json format for Core secrets is technically an implementation detai
154
154
There are three additional configuration attributes for this config builder:
155
155
*`userSecretsId` - This is the preferred method for identifying an xml secrets file. It works similar to .Net Core, which uses a 'UserSecretsId' project
156
156
property to store this identifier. (The string does not have to be a Guid. Just unique. The VS "Manage User Secrets" experience produces a Guid.) With this
157
-
attribute, the `UserSecretsConfigBuilder` will look in a well-known local location (%APPDATA%\Microsoft\UserSecrets\<userSecretsId>\secrets.xml in
157
+
attribute, the `UserSecretsConfigBuilder` will look in a well-known local location (%APPDATA%\Microsoft\UserSecrets\\<userSecretsId>\secrets.xml in
158
158
Windows environments) for a secrets file belonging to this identifier.
159
159
*`userSecretsFile` - An optional attribute specifying the file containing the secrets. The '~' character can be used at the start to reference the app root.
160
160
One of this attribute or the 'userSecretsId' attribute is required. If both are specified, 'userSecretsFile' takes precedence.
@@ -180,7 +180,7 @@ and currently exposes the format of the file which, as mentioned above, should b
If your secrets are kept in Azure Key Vault, then this config builder is for you. There are three additional attributes for this config builder. The `vaultName`
211
-
(or `uri`) is required. Previous iterations of this config builder allowed for a `connectionString` as a way to supply credential information for connecting to
212
+
attribute (or `uri`) is required. Previous iterations of this config builder allowed for a `connectionString` as a way to supply credential information for connecting to
212
213
Azure Key Vault. This method is no longer allowed as it is not a supported scenario for the current `Azure.Identity` SDK which is used for connecting
213
214
to Azure services. Instead, this iteration of the config builder exclusively uses [DefaultAzureCredential](https://docs.microsoft.com/en-us/dotnet/api/azure.identity.defaultazurecredential)
214
215
from the `Azure.Identity` package to handle credentials for connecting to Azure Key Vault.
@@ -218,7 +219,8 @@ from the `Azure.Identity` package to handle credentials for connecting to Azure
218
219
*`preloadSecretNames` - By default, this builder will query __all__ the key names in the key vault when it is initialized to improve performance. If this is
219
220
a concern, set this attribute to 'false', and secrets will be retrieved one at a time. This could also be useful if the vault allows "Get" access but not
220
221
"List" access. (NOTE: Disabling preload is incompatible with Greedy mode.)
221
-
Tip: Azure Key Vault uses random per-secret Guid assignments for versioning, which makes specifying a secret `version` tag on this builder rather
222
+
223
+
__Tip:__ Azure Key Vault uses random per-secret Guid assignments for versioning, which makes specifying a secret `version` tag on this builder rather
222
224
limiting, as it will only ever update one config value. To make version handling more useful, V2 of this builder takes advantage of the new key-updating
223
225
feature to allow users to specify version tags in key names rather than on the config builder declaration. That way, the same builder can handle multiple
224
226
keys with specific versions instead of needing to redefine multiple builders.
0 commit comments