.NET SDK
Load secrets directly into a .NET application at startup.
.NET SDK
Load secrets directly into your .NET application at startup. One-liner facade, fluent builder, IConfiguration integration, or full programmatic control.
Install
dotnet add package EnvilderOne-liner: resolve + inject
Resolve secrets from the map file and inject into Environment in a single call:
using Envilder;
// Resolve secrets and inject into Environment
Env.Load("envilder.json");
var dbPassword = Environment.GetEnvironmentVariable("DB_PASSWORD");Resolve without injecting
Get secrets as a dictionary without modifying the environment:
using Envilder;
var secrets = Env.ResolveFile("envilder.json");
var dbPassword = secrets["DB_PASSWORD"];Fluent builder with overrides
Override provider settings programmatically using the fluent API:
using Envilder;
var secrets = Env.FromMapFile("envilder.json")
.WithProvider(SecretProviderType.Azure)
.WithVaultUrl("https://my-vault.vault.azure.net")
.Resolve();
// Or inject directly
Env.FromMapFile("envilder.json")
.WithProfile("staging")
.Inject();Environment-based loading
Route secret loading based on your current environment. Each environment maps to its own secrets file:
using Envilder;
var env = Environment.GetEnvironmentVariable("APP_ENV") ?? "development";
Env.Load(env, new Dictionary<string, string?>
{
["production"] = "prod-secrets.json",
["development"] = "dev-secrets.json",
["test"] = null, // no secrets loaded
});Secret validation
Opt-in validation ensures all resolved secrets have non-empty values:
using Envilder;
var secrets = Env.ResolveFile("envilder.json");
secrets.ValidateSecrets(); // throws SecretValidationException if any value is emptyVia IConfiguration (ASP.NET)
Add Envilder as a configuration source in your ASP.NET application:
var builder = WebApplication.CreateBuilder(args);
builder.Configuration.AddEnvilder("envilder.json");
var app = builder.Build();Advanced: full programmatic control
Parse the map file, resolve secrets, and inject them into environment variables:
using Envilder;
var secrets = await Env.ResolveFileAsync("envilder.json");
EnvilderClient.InjectIntoEnvironment(secrets);