1

If you use IOptions pattern i.e typed settings approach how should you then be able to have a dynamic name convention for parameters in App Configuration (AC) ? Let's say we have 3 environments test, stage and prod and in AC we would like to have a name convention for parameters as:

<environment>:<application name>:<param name>

Is that possible to achieve due to when I have tested there seems to be some "behind the scene" mapping based IOptions entity name and appsettings.json structure or can I override this this behavior to achieve a more dynamic param name convention based on Env parameters as (test|stage|prod), Env parameter for service name and a more generic name convention in IOptions entity/appsettings files for all parameters that should be centrally/dynamically stored

Thanks!

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
user3154653
  • 203
  • 1
  • 11
  • Could you elaborate what this means and what is the expectation? - "Is that possible to achieve due to when I have tested there seems to be some "behind the scene" mapping based IOptions-entity-name and appsettings-json-structure or can I override this this behavior to achieve a more dynamic param name convention based on Env-parameters as (test|stage|prod), Env-parammeter for service name and a more generic name convention in IOptions-entity/appsettings-files for all parameters that should be centrally/dynamically stored" – Abhilash Arora Jan 18 '21 at 08:54

1 Answers1

2

The naming convention you plan to use will work, however, I would recommend naming config keys like below and use labels in AC for environments.

<application name>:<param name>

For example,

Key Value Label
app1:settings:debug true dev
app1:settings:debug true stage
app2:settings:color yellow test

Your application then can load only the configuration that is relevant to it (app1 vs. app2) and for the environment where it runs (dev/state/test etc.) by using key filters and label filters. You can find more details of this discussion in https://learn.microsoft.com/en-us/azure/azure-app-configuration/concept-key-value.

Here is a tutorial that shows how to use IOptionsSnapshot with App Configuration in an ASP.NET Core app: https://learn.microsoft.com/en-us/azure/azure-app-configuration/enable-dynamic-configuration-aspnet-core

Zhenlan Wang
  • 1,213
  • 8
  • 10