You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ChainedConfigurationSource doesn't support reloading manually #58683
This was found as a part of investigating dotnet/aspnetcore#36181. It seems like manually calling IConfigurationRoot.Reload on a chained configuration source doesn't work.
I'm actually (ab)using this behavior to reorder configuration providers, without rebuilding the whole tree.
varbuilder=WebApplication.CreateBuilder(Args);builder.Configuration.InsertConsul(newUri("..."),^2,// insert before before env and args"config1","config2","config3");// ...staticIConfigurationBuilderInsertConsul(thisIConfigurationBuilderbuilder,UriconsulUri,IndexinsertPosition,paramsstring[]cfgNodes){IConfigurationBuilder?oldBuilder=null;if(!insertPosition.Equals(^0))// not to the end{oldBuilder=builder;builder=newConfigurationBuilder();}foreach(varcfgNodeincfgNodes){builder.AddConsul(cfgNode, options =>{options.ConsulConfigurationOptions= cco =>cco.Address=consulUri;});}if(oldBuilder!=null){// WebApplication's ConfigurationManager eagerly rebuilds configuration on Sources modification// Create ChainedSource wrapper to add them as one item; as side effect it also disables reload// Otherwise (inserting directly into ConfigurationManager.Sources) it will// rebuild configuration tree on each Insert (makes 1+2+3+N blocking HTTP calls, instead of N)varsource=newChainedConfigurationSource{Configuration=builder.Build(),ShouldDisposeConfiguration=true};builder=oldBuilder;varsources=builder.Sources;sources.Insert(insertPosition.GetOffset(sources.Count),source);}returnbuilder;}
It would be nice to have some API to temporally pause eager configuration evaluation. Or some other way to reorder providers.
Can we just reorder providers and rebuild lazily (on first access)?
Activity
OwnageIsMagic commentedon Feb 18, 2023
I'm actually (ab)using this behavior to reorder configuration providers, without rebuilding the whole tree.
It would be nice to have some API to temporally pause eager configuration evaluation. Or some other way to reorder providers.
Can we just reorder providers and rebuild lazily (on first access)?
rosebyte commentedon Mar 3, 2026
Triage: we should fix it.
Support reload in ChainedConfigurationSource
Merge branch 'main' into dotnetgh-58683
Merge branch 'main' into dotnetgh-58683
Merge branch 'main' into dotnetgh-58683
Merge branch 'main' into dotnetgh-58683
Support reload in ChainedConfigurationSource (dotnet#125122)
Support reload in ChainedConfigurationSource (#125122)