2017-05-12 8 views
0

以前のVS2017では、コード内のAsp.NETコアアプリケーションにApplication Insightの統合を設定することができました。 VS2017では、「Microsoft.ApplicationInsights.AspNetCore」(2.0.0)のようにIDE(Connected Services)を使用しても、​​の拡張子は提供されません。関連するすべてのリソースはVS2017(つまりhttps://github.com/Microsoft/ApplicationInsights-aspnetcore/wiki/Getting-Started)では機能しません。VS2017のAsp.Netコアとアプリケーションのインサイト - 複数の環境

新しいVS2017機能「接続サービス」を使用する場合、環境ごとに異なるApplication Insightインスタンスに接続する方法は?

答えて

1

でも、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に構成を保存します。

+0

AddTelemetryConfigurationメソッドは、ApplicationInsightsExtensionsクラスにあります。 –

関連する問題