Environment variables configuration provider implementation for Microsoft.Extensions.Configuration.
Documentation can be found at https://learn.microsoft.com/dotnet/core/extensions/configuration-providers#environment-variable-configuration-provider
The APIs and functionality are mature, but do get extended occasionally.
Microsoft.Extensions.Configuration.EnvironmentVariables is included in the ASP.NET Core shared framework. The package is deployed as out-of-band (OOB) too and can be referenced into projects directly.
The following example shows how to read application configuration from environment variables.
using System;
using Microsoft.Extensions.Configuration;
class Program
{
static void Main()
{
// Build a configuration object from environment variables
IConfiguration config = new ConfigurationBuilder()
.AddEnvironmentVariables()
.Build();
// Read configuration values
Console.WriteLine($"Server: {config["Server"]}");
Console.WriteLine($"Database: {config["Database"]}");
}
}