0

I have a production environment located in the westus region. I want to set a configuration that only applies when both the prod environment and the westus region are matched.

Currently, the label filter overwrites the configuration if any of the labels match. For example, if I set the configuration with the following code, the config will apply to all prod environments and all westus regions, but I want the config to only apply to an environment that matches both labels (prod and westus).

Requirement:

I need the configuration to apply only when both prod and westus labels are matched, not when either of them matches.

Example:

  1. Test:Test = true
    matches all environments
  2. Test:Test = true prod
    matches all prod environments
  3. Test:Test = true westus
    matches all westus regions
  4. Test:Test = true prod, westus
    should match only when both prod environment and westus region are present

Question: How can I modify the label filtering logic so that the configuration is applied only when both labels (prod and westus) are matched, instead of when any one of them matches?

1 Answer 1

0

You could create a new label prod/westus and use it to override any existing settings. For example:

Key: Test:Test Label: prod/westus

ConfigurationBuilder.AddAzureAppConfiguration(options =>
{
    options.Connect(...)
        .Select("Test:*", $"{env}") // e.g., prod, staging, etc.
        .Select("Test:*", $"{env}/" + $"{region}"); // e.g., prod/westus
});

Alternatively, use region as a prefix of the key name instead of a label. Create a key-value:

Key: westus:Test:Test Label: prod

Then in your code, you load settings for that region and then trim the region name from the key. For example:

ConfigurationBuilder.AddAzureAppConfiguration(options =>
{
    options.Connect(...)
        .Select("Test:*", $"{env}")
        .Select($"{region}:Test:*", $"{env}")
        .TrimKeyPrefix($"{region}:");
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.