Skip to content

Commit cd98f4b

Browse files
Update to RC. Doc cleanup. (#92)
1 parent 6d2f310 commit cd98f4b

2 files changed

Lines changed: 18 additions & 16 deletions

File tree

README.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Configuration Builders
22

33
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.
66

77
### V2 Update:
88
Version 2 is here with some new features:
@@ -11,13 +11,14 @@ Version 2 is here with some new features:
1111
read initialization parameters for config builders from `appSettings`. Read more about it [here](#appsettings-parameters).
1212
* Lazy Initialization - As part of the work to enable pulling config parameters from `appSettings`, these key/value configuration builders now support a
1313
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
1515
be lazy whenever possible.
1616
* Updateable Keys - Builders can now massage key names before inserting into config. The [AzureKeyVaultConfigBuilder](#azurekeyvaultconfigbuilder) has been
1717
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
1818
seperate from, and performed *after* prefix stripping.)
1919
* 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
2020
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.
2122
* Section Handlers - This feature allows users to develop extensions that will apply key/value config to sections other than `appSettings` and `connectionStrings`
2223
if desired. Read more about this feature in the [Section Handlers](#section-handlers) segment below.
2324

@@ -117,11 +118,10 @@ configuration section) there are limitations when using this feature on the `app
117118
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.
118119

119120
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`.
123122

124123
## 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.*
125125

126126
### EnvironmentConfigBuilder
127127
```xml
@@ -154,7 +154,7 @@ builder, the json format for Core secrets is technically an implementation detai
154154
There are three additional configuration attributes for this config builder:
155155
* `userSecretsId` - This is the preferred method for identifying an xml secrets file. It works similar to .Net Core, which uses a 'UserSecretsId' project
156156
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
158158
Windows environments) for a secrets file belonging to this identifier.
159159
* `userSecretsFile` - An optional attribute specifying the file containing the secrets. The '~' character can be used at the start to reference the app root.
160160
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
180180
[@keyFilter="string"]
181181
[@labelFilter="label"]
182182
[@acceptDateTime="DateTimeOffset"]
183-
[@useAzureKeyVault="bool"]
183+
[@useAzureKeyVault="bool"]
184184
type="Microsoft.Configuration.ConfigurationBuilders.AzureAppConfigurationBuilder, Microsoft.Configuration.ConfigurationBuilders.AzureAppConfig" />
185185
```
186186
[AppConfiguration](https://docs.microsoft.com/en-us/azure/azure-app-configuration/overview) is a new offering from Azure, currently in preview. If you
@@ -196,7 +196,8 @@ from the Azure.Identity package to handle credentials for connecting to the serv
196196
to retrieve configuration values from a past state.
197197
* `useAzureKeyVault` - Enable this feature to allow AzureAppConfigurationBuilder to connect to and retrieve secrets from Azure Key Vault for
198198
config values that are stored in Key Vault. The same managed service identity that is used for connecting to the AppConfiguration service will
199-
be used to connect to Key Vault. Default is `false`.
199+
be used to connect to Key Vault. The Key Vault uri is retrieved as part of the data from AppConfiguration and does not need to be specified here.
200+
Default is `false`.
200201

201202
### AzureKeyVaultConfigBuilder
202203
```xml
@@ -208,7 +209,7 @@ from the Azure.Identity package to handle credentials for connecting to the serv
208209
type="Microsoft.Configuration.ConfigurationBuilders.AzureKeyVaultConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.Azure" />
209210
```
210211
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
212213
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
213214
to Azure services. Instead, this iteration of the config builder exclusively uses [DefaultAzureCredential](https://docs.microsoft.com/en-us/dotnet/api/azure.identity.defaultazurecredential)
214215
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
218219
* `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
219220
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
220221
"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
222224
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
223225
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
224226
keys with specific versions instead of needing to redefine multiple builders.
@@ -239,7 +241,7 @@ entries: `item1` and `item2`.
239241
```xml
240242
<add name="KeyPerFile"
241243
[mode|@prefix|@stripPrefix|tokenPattern|@escapeExpandedValues|@optional=false]
242-
(@directoryPath="PathToSourceDirectory")
244+
@directoryPath="PathToSourceDirectory"
243245
[@ignorePrefix="ignore."]
244246
[keyDelimiter=":"]
245247
type="Microsoft.Configuration.ConfigurationBuilders.KeyPerFileConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.KeyPerFile" />
@@ -298,7 +300,7 @@ public class MySpecialSectionHandler : SectionHandler<MySpecialSection>
298300
{
299301
// T ConfigSection;
300302
// public override void Initialize(string name, NameValueCollection config) {}
301-
// public override string TryGetOriginalCase(string requestedKey) {}
303+
// public override string TryGetOriginalCase(string requestedKey) {}
302304
303305
public override IEnumerator<KeyValuePair<string, object>> GetEnumerator() {}
304306

@@ -319,8 +321,8 @@ New section handlers can be introduced to the config system... via config. Secti
319321
provider model introduced in .Net 2.0, so they require `name` and `type` attributes, but can additionally support any other
320322
attribute needed by passing them in a `NameValueCollection` to the `Initialize(name, config)` method.
321323

322-
Section handlers also have an optional override method `TryGetOriginalCase` that attempts to preserve casing in config files
323-
when executing in `Greedy` mode. When operating in `Strict` mode, config builders in this repo always preserved the case of the
324+
Section handlers also have an optional virtual method `TryGetOriginalCase(string)` that attempts to preserve casing in config files
325+
when executing in `Greedy` mode. When operating in `Strict` mode, config builders in this repo have always preserved the case of the
324326
key when updating the value. This was easy because the original key was already at hand during lookup and replacement. In `Greedy`
325327
mode however, the original key from the config file was not used since it was not needed for a one-item lookup. Thus any greedy substitutions
326328
had their keys replaced with the keys from the external config source. Functionally they should be the same, since key/value config

tools/MicrosoftConfigurationBuilders.settings.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
Release: Third for Info and Package.
2424
Update package and file without touching assembly, except for major releases.
2525
-->
26-
<BuildQuality Condition="'$(BuildQuality)' == ''">beta</BuildQuality>
26+
<BuildQuality Condition="'$(BuildQuality)' == ''">rc</BuildQuality>
2727
<VersionStartYear Condition="'$(VersionStartYear)' == ''">2019</VersionStartYear>
2828
<VersionMajor>2</VersionMajor>
2929
<VersionMinor>0</VersionMinor>

0 commit comments

Comments
 (0)