Tutorial by Examples

The recommended approach would be to avoid doing so and rather use IOptions<TOptions> and IServiceCollection.Configure<TOptions>. That said, this is still pretty straightforward to make IConfigurationRootavailable application wide. In the Startup.cs constructor you should have the foll...
In this example we will describe what happens when you scaffold a new project. First thing, the following dependencies will be added to you project (currently project.json file) : "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0", "Microsoft.Extensions.Co...
You can source configuration from environment variables by calling .AddEnvironmentVariables() on you ConfigurationBuilder. It will load environment variables prefixed with APPSETTING_ It will then use colon : as the key path separator. This means that : following environement settings : APPSETTI...
When dealing with large configuration sets of value, it might become quite unhandy to load them one buy one. Option model which comes with asp.net offers a convenient way to map a section to a dotnet poco: For instance, one might hydrate StorageOptions directly from a configuration section b addin...
You can also source configuration from an in memory object such as a Dictionary<string,string> .AddInMemoryCollection(new Dictionary<string, string> { ["akey"] = "a value" }) This can reveal helpful in integration/unit testing scenarios.

Page 1 of 1