When we did a .net core service we found that the appsettings.json was not read and hence the variable we null. If your normal configuration builder is as below,
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile(“appsettings.json”, optional: true, reloadOnChange: true);
replace the same with
var builder = new ConfigurationBuilder()
.SetBasePath(System.AppDomain.CurrentDomain.BaseDirectory)
.AddJsonFile(“appsettings.json”, optional: true, reloadOnChange: true);
and give it a try. Sorry I could find that in the your code in a quick glance to show the exact location.