Appconfiguration: Is it possible to use wildcards in ConfigureRefresh?

Created on 17 Jul 2019  路  7Comments  路  Source: Azure/AppConfiguration

Guys, is it possible to use wildcards (say *) when configuring the refresher in order to update all the settings values under a given parent? I want to update any setting value inside MySeetings when they change.

class MySeetings
{
     public string Setting1 { get; set; }
     public bool Setting2 { get; set; }
     ...
}

config.AddAzureAppConfiguration(options =>
{
       options.Connect(settings["ConnectionStrings:AppConfig"])
              .ConfigureRefresh(refresh => { refresh.Register("MySettings:*"); });
});

When I do that I get a 404 error. Is there another way to do that?

.NET Config Provider

Most helpful comment

There's a chance to have a feature like that in the future? I mean, given I have my configuration in Azure I don't want to update my code every time I add a new setting (in this example within MySettings class) that way I can take advantage of the dynamic configuration avoiding to register a new setting to be refreshed.

Also, the scenario I have is an array inside of MySettings, so I need to refresh my configuration when I add an item into the array, so that array isn't fixed.

All 7 comments

Only individual key-values can be configured for refresh. The closest way to get a similar behavior to what you are talking about is to use a "sentinel" key-value in the app configuration, and trigger a reload all of your configuration when that value changes.

options.Connect(settings["ConnectionStrings:AppConfig"])
              .ConfigureRefresh(refresh => { refresh.Register(key: "MySettings:Sentinel", refreshAll: true); });

It's a slightly different workflow because you would need to update the sentinel whenever you want the app to pick up some changes that you made in the app configuration.

There's a chance to have a feature like that in the future? I mean, given I have my configuration in Azure I don't want to update my code every time I add a new setting (in this example within MySettings class) that way I can take advantage of the dynamic configuration avoiding to register a new setting to be refreshed.

Also, the scenario I have is an array inside of MySettings, so I need to refresh my configuration when I add an item into the array, so that array isn't fixed.

@vany0114 right now there is no plan for that.

Does the approach using refreshAll: true that I mentioned not work for your scenario? It does not require any code changes in your application, so I'm unsure what you meant by having to update code every time you add a new setting.

The flow would be like this

  1. Deploy app with refresh.Register(key: "MySettings:Sentinel", refreshAll: true);
  2. Perform updates to the array in app configuration
  3. Update MySettings:Sentinel in app configuration
  4. Observe app now uses the latest array values.

Sorry, I misunderstood you, I was left wondering about this, so nvm:

It's a slightly different workflow because you would need to update the sentinel whenever you want the app to pick up some changes that you made in the app configuration.

I haven't tried it out yet but should work as you said. So the Sentinel might be of whatever type, right? it triggers the refresh even if the Sentinel value is the same right? as long as I update that guy.

Right, sentinel could be anything. Just touching that value in app configuration will have the desired affect. The app will see that it got updated and doesn't need to worry about the actual value.

Although, it will get the new value for the sentinel in case you use one who's value you do care about.

Got it, thanks to reply so fast!

@vany0114 right now there is no plan for that.

Does the approach using refreshAll: true that I mentioned not work for your scenario? It does not require any code changes in your application, so I'm unsure what you meant by having to update code every time you add a new setting.

The flow would be like this

1. Deploy app with `refresh.Register(key: "MySettings:Sentinel", refreshAll: true);`

2. Perform updates to the array in app configuration

3. Update `MySettings:Sentinel` in app configuration

4. Observe app now uses the latest array values.

This definitely works, but seems excessively onerous for consumers. Explaining how to set this up and use it to every single one of the teams I support isn't anywhere near as straightforward as a bespoke option.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mmigala picture mmigala  路  4Comments

trevonmckay picture trevonmckay  路  5Comments

kamalsivalingam picture kamalsivalingam  路  6Comments

richardpark-msft picture richardpark-msft  路  6Comments

TheReaLee picture TheReaLee  路  5Comments