Set base path to current directory if ContentRootPath is null on hosting environment. This path is where AI would look for appsettings.json file for ikey, endpoint etc.
This commit is contained in:
Родитель
8f42004f56
Коммит
5225f37c22
|
@ -2,6 +2,7 @@
|
|||
{
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using Microsoft.ApplicationInsights.AspNetCore.Extensions;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
@ -28,7 +29,7 @@
|
|||
public void Configure(ApplicationInsightsServiceOptions options)
|
||||
{
|
||||
var configBuilder = new ConfigurationBuilder()
|
||||
.SetBasePath(this.hostingEnvironment.ContentRootPath)
|
||||
.SetBasePath(this.hostingEnvironment.ContentRootPath??Directory.GetCurrentDirectory())
|
||||
.AddJsonFile("appsettings.json", true)
|
||||
.AddJsonFile(string.Format(CultureInfo.InvariantCulture,"appsettings.{0}.json", hostingEnvironment.EnvironmentName), true)
|
||||
.AddEnvironmentVariables();
|
||||
|
|
Загрузка…
Ссылка в новой задаче