Skip to content

Commit e965bd7

Browse files
committed
Fix Azure AppConfiguration documentation.
1 parent 1b41d88 commit e965bd7

1 file changed

Lines changed: 29 additions & 45 deletions

File tree

README.md

Lines changed: 29 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -176,44 +176,22 @@ and currently exposes the format of the file which, as mentioned above, should b
176176
```xml
177177
<add name="AzureAppConfig"
178178
[mode|@prefix|@stripPrefix|tokenPattern|@escapeExpandedValues|@optional=false]
179-
(@vaultName="MyVaultName" | @uri="https://MyVaultName.vault.azure.net")
180-
[@connectionString="connection string"]
181-
[@version="secrets version"]
182-
[@preloadSecretNames="true"]
183-
type="Microsoft.Configuration.ConfigurationBuilders.AzureKeyVaultConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.Azure" />
184-
```
185-
[ParameterDescription]@{ Name="endpoint"; IsRequired=$false; DefaultValue="[Config_Store_Endpoint_Url]" },
186-
[ParameterDescription]@{ Name="connectionString"; IsRequired=$false },
187-
[ParameterDescription]@{ Name="keyFilter"; IsRequired=$false });
188-
[ParameterDescription]@{ Name="labelFilter"; IsRequired=$false });
189-
[ParameterDescription]@{ Name="preferredDateTime"; IsRequired=$false },
190-
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` is
191-
required. The other attributes allow you some manual control about which vault to connect to, but are only necessary if the application is not running in an
192-
environment that works magically with `Microsoft.Azure.Services.AppAuthentication`. The Azure Services Authentication library is used to automatically pick
193-
up connection information from the execution environment if possible, but you can override that feature by providing a connection string instead.
194-
* `vaultName` - This is a required attribute. It specifies the name of the vault in your Azure subscription from which to read key/value pairs.
195-
* `connectionString` - A connection string usable by [AzureServiceTokenProvider](https://docs.microsoft.com/en-us/azure/key-vault/service-to-service-authentication#connection-string-support)
196-
* `uri` - Connect to other Key Vault providers with this attribute. If not specified, Azure is the assumed Vault provider. If the uri _is_specified, then `vaultName` is no longer a required parameter.
197-
* `version` - Azure Key Vault provides a versioning feature for secrets. If this is specified, the builder will only retrieve secrets matching this version.
198-
* `preloadSecretNames` - By default, this builder will query __all__ the key names in the key vault when it is initialized. If this is a concern, set
199-
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
200-
"List" access. (NOTE: Disabling preload is incompatible with Greedy mode.)
201-
Tip: Azure Key Vault uses random per-secret Guid assignments for versioning, which makes specifying a secret `version` tag on this builder rather
202-
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
203-
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
204-
keys with specific versions instead of needing to redefine multiple builders.
205-
When requesting a specific version for a particular key, the key name in the original config file should look like __`keyName/versionId`__. The
206-
AzureKeyVaultConfigBuilder will only substitue values for 'keyName' if the specified 'versionId' exists in the vault. When that happens, the
207-
AzureKeyVaultConfigBuilder will remove the `/versionId` from the original key, and the resulting config section will only contain `keyName`.
208-
For example:
209-
```xml
210-
<appSettings configBuilders="AzureKeyVault">
211-
<add key="item1" value="Replaced with latest value from the key vault." />
212-
<add key="item2/0123456789abcdefdeadbeefbadf00d" value="Replaced with specific version only." />
213-
</appSettings>
179+
(@endpoint="https://your-appconfig-store.azconfig.io" | @connectionString="Endpoint=https://your-appconfig-store.azconfig.io;Id=XXXXXXXXXX;Secret=XXXXXXXXXX")
180+
[@keyFilter="string"]
181+
[@labelFilter="label"]
182+
[@preferredDateTime="DateTimeOffset"]
183+
type="Microsoft.Configuration.ConfigurationBuilders.AzureAppConfigurationBuilder, Microsoft.Configuration.ConfigurationBuilders.AzureAppConfig" />
214184
```
215-
Assuming both of these items exist in the vault, and the version tag for `item2` is valid, this would result in an collection of appSettings with two
216-
entries: `item1` and `item2`.
185+
[AppConfiguration](https://docs.microsoft.com/en-us/azure/azure-app-configuration/overview) is a new offering from Azure, currently in preview. If you
186+
wish to use this new service for managing your configuration, then use this AzureAppConfigurationBuilder. Either `endpoint` or `connectionString` are
187+
required, but all other attributes are optional. If both `endpoint` and `connectionString` are used, then preference is given to the connection string.
188+
It is however, __strongly__ encouraged to use `endpoint` with a managed service identity in Azure.
189+
* `endpoint` - This specifies the AppConfiguration store to connect to.
190+
* `connectionString` - This specifies the AppConfiguration store to connect to, along with the Id and Secret necessary to access the service.
191+
* `keyFilter` - Use this to select a set of configuration values matching a certain key pattern.
192+
* `labelFilter` - Only retrieve configuration values that match a certain label.
193+
* `preferredDateTime` - Instead of versioning ala Azure Key Vault, AppConfiguration uses timestamps. Use this attribute to go back in time
194+
to retrieve configuration values from a past state.
217195

218196
### AzureKeyVaultConfigBuilder
219197
```xml
@@ -314,7 +292,8 @@ will allow any `KeyValueConfigBuilder` to operate specifically on a section of t
314292
```CSharp
315293
public class MySpecialSectionHandler : SectionHandler<MySpecialSection>
316294
{
317-
// T ConfigSection;
295+
// T ConfigSection;
296+
// public override void Initialize(string name, NameValueCollection config) {}
318297
319298
public override IEnumerator<KeyValuePair<string, object>> GetEnumerator() {}
320299

@@ -331,7 +310,12 @@ enumerable list of key/value things. The 'value' side of that pair doesn't even
331310
can simply update the old connection string (thereby preserving other existing properties like 'ProviderName') instead of creating a
332311
new one from scratch.
333312

334-
New section handlers can be introduced to the config system... via config. The `AppSettingsSectionHandler` and `ConnectionStringsSectionHandler`
313+
New section handlers can be introduced to the config system... via config. Section handlers do follow along with the old
314+
provider model introduced in .Net 2.0, so they require `name` and `type` attributes, but can additionally support any other
315+
attribute needed by passing them in a `NameValueCollection` to the `Initialize(name, config)` method.
316+
317+
318+
The `AppSettingsSectionHandler` and `ConnectionStringsSectionHandler`
335319
are implicitly added at the root level config, but they can be clear/removed just like any other item in an add/remove/clear configuration
336320
collection. As an example, here is what their explicit declaration would look like:
337321
```xml
@@ -359,9 +343,9 @@ compiled in a separate assembly in the 'bin' directory. For example:
359343
<Microsoft.Configuration.ConfigurationBuilders.SectionHandlers>
360344
<handlers>
361345
<remove name="DefaultAppSettingsHandler" />
362-
<add name="DefaultAppSettingsHandler" type="MyCustomAppSettingsSectionHandler, RefAssemblyInBin" />
346+
<add name="DefaultAppSettingsHandler" customAttr="foo" type="MyCustomAppSettingsSectionHandler, RefAssemblyInBin" />
363347
<remove name="DefaultConnectionStringsHandler" />
364-
<add name="DefaultConnectionStringsHandler" type="MyCustomConnectionStringsSectionHandler, App_Code" />
348+
<add name="DefaultConnectionStringsHandler" superCustomAttr="bar" superDuperCustomAttr="42" type="MyCustomConnectionStringsSectionHandler, App_Code" />
365349
</handlers>
366350
</Microsoft.Configuration.ConfigurationBuilders.SectionHandlers>
367351
```
@@ -398,7 +382,7 @@ public class CustomConfigBuilder : KeyValueConfigBuilder
398382
{
399383
// Use this initializer for things that must be read from 'config' immediately upon creation.
400384
// AppSettings parameter substitution is not available at this point.
401-
// Try using LazyInitialize(string, NameValueCollection) instead when possible.
385+
// Try using LazyInitialize(string, NameValueCollection) instead when possible.
402386
}
403387

404388
protected override void LazyInitialize(string name, NameValueCollection config)
@@ -416,9 +400,9 @@ public class CustomConfigBuilder : KeyValueConfigBuilder
416400
// are able to translate the bad format to a known good format to get a value from your
417401
// config source, use this method.
418402
// Ex) AppSettings are commonly named things like "area:feature", but the ':' is not a legal
419-
// character for key names in Azure Key Vault. MapKey() can help translate the ':' to a
420-
// '-' in this case, which will allow the ability to look up a config value for this appSetting
421-
// in Key Vault, even though it's original key name is not valid in Key Vault.
403+
// character for key names in Azure Key Vault. MapKey() can help translate the ':' to a
404+
// '-' in this case, which will allow the ability to look up a config value for this appSetting
405+
// in Key Vault, even though it's original key name is not valid in Key Vault.
422406
}
423407

424408
public override bool ValidateKey(string key)

0 commit comments

Comments
 (0)