Skip to content

How do I read single KV value and also keep existing appsettings.json #125

@sebstepien

Description

@sebstepien

I have a single key value that I want to read (consul) in alongside the appsettings.json file(not consul)
The value is a string representation of a boolean (true, false)
but when calling the injected _configuration["test-key"] from within the controller I am not getting any result.
Can I please have some guidance of what is potentially happening? I don't see any exeptions in the logs.

     public static IWebHostBuilder CreateWebHostBuilder(string[] args, CancellationTokenSource cancellationTokenSource) =>
          WebHost.CreateDefaultBuilder(args)
                 .ConfigureAppConfiguration(
                      (hostingContext, builder) =>
                      {
                          builder
                              .AddConsul("test-key",
                                  cancellationTokenSource.Token,
                                  options =>
                                  {
                                      options.ConsulConfigurationOptions =
                                          cco => { cco.Address = new Uri("http://127.0.0.1:8500"); };
                                      options.Parser = new SimpleConfigurationParser();
                                      options.Optional = false;
                                      options.ReloadOnChange = true;
                                      options.OnLoadException = exceptionContext =>
                                      {
                                          Console.WriteLine($"{exceptionContext.Exception}");
                                          exceptionContext.Ignore = true;

                                      };
                              })
                              .AddEnvironmentVariables();

                 })
                 .ConfigureKestrel(options => { options.Limits.MinResponseDataRate = null; })
                 .UseStartup<Startup>()
                 .UseNLog();

consul sturcture would be

test-key:test-value
features/feature1:true
features/feature2:false

How am I able to get just keys prefixed by features?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions