5

In .net core if we have to bind the configuration directly from Json configuration as shown below

{  
  "AzureAdJwtSettings": {
    "Authority": "https://login.microsoftonline.com/tenantid",
  },
  "WebSecJwtSettings": {
    "Authority": "https://example.com",
  }
}

we can write something like this

configuration.Bind("AzureAdJwtSettings", options);

I am looking to find a way so that I can group my json configuration in such a way

{  
  "JwtSettings": {
    "AzureAdJwtSettings": {
      "Authority": "https://login.microsoftonline.com/tenantid"
    },
    "WebSecJwtSettings": {
      "Authority": "https://example.com"
    }
  }
}

But when I try to load the configuration in my code it didn't load properly.. I am using the below code

configuration.Bind("JwtSettings.AzureAdJwtSettings", options);

I know there must be way to load nested properties but couldn't find it working...

1
  • 3
    Use colon (:) instead of dot (.) Commented Apr 22, 2020 at 0:46

1 Answer 1

5

As per suggested comments, the format should use colon (:) instead of dot (.) with keys for configuration option binding to work

For example

configuration.Bind("JwtSettings:AzureAdJwtSettings", options);
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.