でも、ApplicationInsightsServiceOptions
を使用してApplicationInsightsを手動で設定することはできます。ここでの設定は、実際に解決する方法のソースコードは、次のとおりです。
internal static void AddTelemetryConfiguration(IConfiguration config, ApplicationInsightsServiceOptions serviceOptions)
{
string str1 = config["APPINSIGHTS_INSTRUMENTATIONKEY"];
if (string.IsNullOrWhiteSpace(str1))
str1 = config["ApplicationInsights:InstrumentationKey"];
if (!string.IsNullOrWhiteSpace(str1))
serviceOptions.InstrumentationKey = str1;
string str2 = config["APPINSIGHTS_DEVELOPER_MODE"];
if (string.IsNullOrWhiteSpace(str2))
str2 = config["ApplicationInsights:TelemetryChannel:DeveloperMode"];
if (!string.IsNullOrWhiteSpace(str2))
{
bool result = false;
if (bool.TryParse(str2, out result))
serviceOptions.DeveloperMode = new bool?(result);
}
string str3 = config["APPINSIGHTS_ENDPOINTADDRESS"];
if (string.IsNullOrWhiteSpace(str3))
str3 = config["ApplicationInsights:TelemetryChannel:EndpointAddress"];
if (!string.IsNullOrWhiteSpace(str3))
serviceOptions.EndpointAddress = str3;
string str4 = config["version"];
if (string.IsNullOrWhiteSpace(str4))
return;
serviceOptions.ApplicationVersion = str4;
}
だから、あなたは最高の優先度は、環境変数を持って見ることができます。 Azureアプリケーション設定でAPPINSIGHTS_INSTRUMENTATIONKEY
変数を設定すると、その変数が選択されます。
VS2017接続サービスの設定を使用する場合は、csproj
,appsettings.json
(InstrumentationKey)および/Connected Services/Application Insights/ConnectedServices.json
に構成を保存します。
AddTelemetryConfigurationメソッドは、ApplicationInsightsExtensionsクラスにあります。 –