1
"AppSettings": 
{"AzureAd":
 {
"Instance": "https://login.microsoftonline.com/",
"Domain": "abc.com",
"TenantId": "90836560-70ab-4caa-9e10-7e80b43d8d5a"
 }
}

How to get the value of a "Instance" value in the class file. I have tried this below which doesn't work

 var symmetrickey = _configuration.GetSection("AppSettings:AzureAd:Instance").GetChildren()
                  .Select(configSection => configSection.Value);

where as Im getting array of node "AzureAd" when I modify like below

var symmetrickey = _configuration.GetSection("AppSettings:AzureAd").GetChildren()
                  .Select(configSection => configSection.Value);

But I want the "Instance"/"TenantId" value by specifically mentioning either of the text .

Panagiotis Kanavos
  • 120,703
  • 13
  • 188
  • 236
krity
  • 49
  • 3
  • 7
  • This has nothing to do with JSON. The .NET Core configuration system reads data from *any* of the configured providers and converts them to key/value pairs. It looks like the actual question is how to get a value by specifying the full path? Have you tried [GetValue](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-2.2#getvalue) ? – Panagiotis Kanavos Jul 01 '19 at 09:48
  • GetValue It didnt work @Kanavos – krity Jul 01 '19 at 10:48
  • How did you use it? In fact, why don't you use the common way shown in the docs of loading all the settings as a single object and eg registering with DI ? – Panagiotis Kanavos Jul 01 '19 at 11:10
  • Possible duplicate of [How to read AppSettings values from .json file in ASP.NET Core](https://stackoverflow.com/questions/31453495/how-to-read-appsettings-values-from-json-file-in-asp-net-core) – Rahul Sharma Jul 03 '19 at 18:22

0 Answers0