When to call AddPlaceholderResolver? #1623
-
|
Hello All. I just upgraded to 4.0 and I am using the config server and placeholder providers. builder.Configuration.AddConfigServer();
builder.Host.AddPlaceholderResolver();Where my appsettings.json contained the keys and placeholders for After moving to 4.0.0 I had to change the order and add the placeholder builder method both before and after configserver like this for the placeholders in appsettings.json to resolve for config server and again after all the config server "config" values are pulled (this ends up working like 3.x) builder.Configuration.AddPlaceholderResolver();
builder.AddConfigServer();
builder.Configuration.AddPlaceholderResolver();Is there a better way to wire things up and not duplicate the placeholder call. And should I use this extension instead and build up the options manually from the env vars vs appsettings.json? public static IConfigurationBuilder AddConfigServer(this IConfigurationBuilder builder, ConfigServerClientOptions options, ILoggerFactory loggerFactory)Notes: This is a k8s deployment and I am just using standard Spring Cloud Config server. Migrated from Slack, originally posted by Grant Alexander on Friday, November 21st |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Using Migrated from Slack, originally posted by @bart-vmware on Friday, November 21st |
Beta Was this translation helpful? Give feedback.
-
|
Thank you! Migrated from Slack, originally posted by Grant Alexander on Friday, November 21st |
Beta Was this translation helpful? Give feedback.
Using
builder.AddConfigServer()is preferred, as it takes care of most things. It internally calls the extension method onIConfigurationBuilder, which is exposed separately for compatibility and corner cases. About the order of calls, things have changed a bit since 3.0 (AddConfigServerused to callAddPlaceholderResolverinternally, which was sometimes desired, but sometimes not; and possibly lead to replacements multiple times). This is described at https://steeltoe.io/docs/v4/welcome/whats-new.html#behavior-changes-2. So it depends on when you want replacements to happen.Migrated from Slack, originally posted by @bart-vmware on Friday, November 21st