I am overriding the values which are set in appsettings.json file by configuring them in azure portal. To do so I have made following changes which are working fine except when I debug my code.
Startup.cs
public Startup(IConfiguration configuration, IHostingEnvironment env)
{
Configuration = configuration;
IConfigurationBuilder builder = new ConfigurationBuilder();
builder.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
builder.AddEnvironmentVariables();
Configuration = builder.Build();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseHsts();
}
DBContext.ConnectionString = Configuration.GetConnectionString("Connectionstr");
Constants.AppLogicURI = Configuration["MailUri:LogicAppUri"];
Constants.BlobStorageKey = Configuration["BlobKey:BlobStorageKey"];
Constants.BlobStorageConnectionString = Configuration["BlobConnectionString:BlobStorageConnectionString"];
Constants.BlobUri = Configuration["Uri:BlobUri"];
Constants.StorageAccount = Configuration["AccountName:StorageAccount"];
}
When I am debugging my code I am not getting any of the values from appsettings.json file due to which application failed to start.
I only get the values if I comment out the line Configuration = builder.Build();
Not sure why I need to do this and how to resolve this issue.