Binding User Secrets in .Net Core Configuration

The .NET Core configuration system uses a provider model to support storing configuration settings in multiple places. Also, Visual Studio 2017 has a Secret Manager tool that provides for storing a configuration file outside of the project directory, thus ensuring that sensitive settings do not get committed to a code repository. I am using this approach for the ClientSecret values for my Microsoft Graph applications.

I ran into an issue in which the values in the Secret Manager tool were not being included when the configuration was bound to my options object.

BindUserSecrets-Debug

The problem is that I opened the Secrets Manager file (secrets.json) and just entered my value:

{
  "ClientSecret":"secret_here"
}

However, the binding is using a section named "AzureAd". I had this section in the main appsettings.json file, but I did not have it in my secrets file. The fix:

{
  "AzureAd": {
    "ClientSecret":"secret_here"
  }
}