Use Azure Application Insights with Azure WebJob

后端 未结 2 1582
闹比i
闹比i 2020-12-30 21:00

The Azure documentation covers many examples of integrating Azure Application Insights into different applications types, such as ASP.NET, Java, etc. However, the documentat

2条回答
  •  旧时难觅i
    2020-12-30 21:31

    Since the above answer is 2 years old and many things have changed since then. Now there is nuget package available for Application insights integration with Azure Webjobs. You need to install below packages:

    1. Microsoft.Azure.WebJobs.Logging.ApplicationInsights (Currently in beta)
    2. Microsoft.Extensions.Logging
    3. Microsoft.Extensions.Logging.Console

    Configure JobHostConfiguration as below:

    string instrumentationKey = Environment.GetEnvironmentVariable("APPINSIGHTS_INSTRUMENTATIONKEY");
    if (!string.IsNullOrEmpty(instrumentationKey))
    {
          // build up a LoggerFactory with ApplicationInsights and a Console Logger
           config.LoggerFactory = new LoggerFactory().AddApplicationInsights(instrumentationKey, null).AddConsole();
           config.Tracing.ConsoleLevel = TraceLevel.Off;
    }
    

    See full post on this here

提交回复
热议问题