Giter Site home page Giter Site logo

Comments (11)

zack-schrag avatar zack-schrag commented on September 18, 2024 4

@DamirAinullin I also found that this worked for my situation:

public void ConfigureServices(IServiceCollection services)
{
     var logging = new Logging();
     Configuration.GetSection("Logging").Bind(logging);
     services.AddSingleton(Options.Create(logging));
}

from aws-dotnet-extensions-configuration.

KenHundley avatar KenHundley commented on September 18, 2024 2

Hey @DamirAinullin, this does work, but the full hirarchy need to exist in the param name

So in your example it would be:

  • Name: /example/settings/Logging/Level Value: Information
  • Name: /example/settings/Logging/SomethingElse Value: Test

There would be too many different ways to anticipate what someone would want to put in a param for their custom hirarchy. You mentioned json in your example, but someone could want yaml, xml, etc.

Since in this case the parameter name is the hirarchy all of this is consistent, and each param is a simple key value pair.

from aws-dotnet-extensions-configuration.

rshillington avatar rshillington commented on September 18, 2024 2

@KenHundley What's not clear in your suggestion of flattening the JSON hierarchy to kvp is how arrays would be represented. For example in this fragment how would the "WriteTo" elements be set?

{
  "Serilog": {
    "Using":  [ "Serilog.Sinks.Console", "Serilog.Sinks.Seq" ],
    "MinimumLevel": "Information",
    "WriteTo": [
      { "Name": "Console" },
      { "Name": "Seq", "Args": { "serverUrl": "http://localhost:5341" } }
    ]

Update: As it turns out, you simply include the array index value as part of the path, so the above would be:
aws ssm put-parameter --name '/WriteTo/0/Name' --value Console
aws ssm put-parameter --name '/WriteTo/1/Name' --value Seq
etc...

from aws-dotnet-extensions-configuration.

warej avatar warej commented on September 18, 2024 1

I have added an alternative solution, that works for me. Would be nice if something like this could be merged into public solution.

from aws-dotnet-extensions-configuration.

klaytaybai avatar klaytaybai commented on September 18, 2024

I misunderstood the question the first time. I don't think this is possible at the moment, but I think it is something that we could add. I'll ask.

from aws-dotnet-extensions-configuration.

klaytaybai avatar klaytaybai commented on September 18, 2024

So you can manage this on your own if you target .NET Core 3.0 like follows:

        public void ConfigureServices(IServiceCollection services)
        {
            var loggingConfig = new ConfigurationBuilder().AddJsonStream(new MemoryStream(Encoding.UTF8.GetBytes(Configuration.GetSection("logging").Value))).Build();
            services.Configure<Logging>(loggingConfig);
            ...
        }

I'm not yet sure if we'll be able to support versions lower than that.

from aws-dotnet-extensions-configuration.

DamirAinullin avatar DamirAinullin commented on September 18, 2024

Thanks for the response. My target is netcore 2.1 (standard env for AWS lambda). I had to get method AddJsonStream and related sources from net core 3.0 to my code. And your approach works well. Do you know will Reload functionality and configurations.WaitForSystemsManagerReloadToComplete method be worked well in this case? BTW should I close the issue or you are going to make this feature available out of the box in future versions and then close it?

from aws-dotnet-extensions-configuration.

KenHundley avatar KenHundley commented on September 18, 2024

effectively you can think of this the same way as the AddEnvironmentVariables. You can put whatever you want in the variable, but the provider just treats it as a kvp.

Here are the equilivant breakdowns for json, environment variables, and param store. This may help

JsonProvider:

{
  "Logging": {
    "Level": "Information",
    "SomethingElse": "Test"
  }
}

Environment Variables:

Logging:Level = Information
Logging:SomethingElse = Test

Param Store:

/prefix/Logging/Level = Inforamtion
/prefix/Logging/SomethingElse = Test

from aws-dotnet-extensions-configuration.

DamirAinullin avatar DamirAinullin commented on September 18, 2024

@KenHundley I understand your approach but it is difficult to manage params from web console when you have a lot of params for example more than hundreed. Probably should be another way how to manage them more convinient.

from aws-dotnet-extensions-configuration.

brettswift avatar brettswift commented on September 18, 2024

@DamirAinullin If by manage you mean populate SSM - I'm thinking about this as well. I put a discussion up on reddit for now, but will likely start building something soon. https://www.reddit.com/r/aws/comments/dwrtek/populating_ssm_in_a_sane_way_from_git_via_cicd/

We just starting using this library, and our goal is to have everything in git, ssm would just be the intermediary (or dynamo etc) without having to think too much about that.

from aws-dotnet-extensions-configuration.

github-actions avatar github-actions commented on September 18, 2024

We have noticed this issue has not received attention in 1 year. We will close this issue for now. If you think this is in error, please feel free to comment and reopen the issue.

from aws-dotnet-extensions-configuration.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.