springconfigserversteeltoe

How do I get multiple config files from a spring config service into a dotnetcore app using Steeltoe extension?


How can I get back multiple config files from a spring config server?

I have c# dotnetcore 3.1 application using Steeltoe.Extensions.ConfigServerCore.2.2.0

I am able to get the configurations that match the spring application name. ie if my application name is "my-service" then I can get "my-service.properties" as well as "application.properties" by using

var configBuilder = new ConfigurationBuilder()
                    ...
                    .AddConfigServer();
var config = configBuilder.Build();

This works if the spring application name matches a file name in the config server.

what I tried

configBuilder.AddConfigServer("external");
var config = configBuilder.Build();

with different variants of environment. But I never get the extra configs back. What am I doing wrong?


Solution

  • Steeltoe largely relies on Config Server's logic for finding the backing files by specifying the app name, environment name and additional labels. Because of the way .NET configuration is flattened into a dictionary, you won't see this reflected later in your application, but if config values are missing that you're hoping to see it may be due to the file names not matching the expected conventions.

    Using AddConfigServer("external") will result in a request for "my-service-external.properties". Due to the dash being used in the convention for separating the app name from environment (or profile) name you might not want to use it in your app name.

    Additionally, there have been a few releases of Steeltoe since 2.2.0, I'd suggest using the latest GA release available (currently 2.4.3)