aspnet / MicrosoftConfigurationBuilders

Microsoft.Configuration.Builders
MIT License
118 stars 61 forks source link

AzureAppConfigurationBuilder does not match keys in "Strict" mode #226

Open rehret opened 1 year ago

rehret commented 1 year ago

AzureAppConfigurationBuilder does not match keys in "Strict" mode

When operating in "Strict" mode, AzureAppConfigurationBuilder does not properly match keys from the config section. However, the keys are properly matched in "Greedy" mode.

Functional impact

When utilizing AzureAppConfigurationBuilder in "Strict" mode and using a key filter and prefix, keys are never matched. That is to say values specified in Azure App Configuration are never returned.

Minimal repro steps

Sample project can be found here: rehret/ConfigBuilders.AzureAppConfig.StrictModeTest. The README at the root contains instructions for setup and execution of the test scenario.

Generally speaking, the reproduction steps are:

  1. Define an Azure App Configuration config builder in the Web.config / App.config for the project.
    • The mode must be "Strict"
    • A key filter and prefix must be used
    • stripPrefix must be "true"
  2. Utilize the defined config builder in any configuration section by adding it to the section's configBuilders="..." attribute.
  3. Attempt to read a key defined in the configuration section whose value should be provided by the Azure App Configuration config builder.
  4. The returned value will be null.

Expected result

When reading configuration backed by an Azure App Configuration config builder in "Strict" mode with a key filter and prefix, it is expected that the value specified in Azure App Configuration with a matching key ("key" here being prefix + key) is returned.

Actual result

In "Strict" mode with a key filter and prefix, rather than returning the value specified in Azure App Configuration, AzureAppConfigurationBuilder returns null.

Further technical details

I believe the following is contributing to this: