In the ConfigureServices method at Startup.cs have something like so:
var builder = new ConfigurationBuilder()
.SetBasePath(AppDomain.CurrentDomain.BaseDirectory)
.AddJsonFile($"appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile("secrets.json", optional: true, reloadOnChange: true)
.AddEnvironmentVariables();
Configuration = builder.Build();
Grab something out on the very next line like so:
var includeSecretService = Configuration.GetSection("Foo").Exists();
Configuration the variable looks like this:
namespace MyMagic
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
No comments:
Post a Comment