Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Azure 从何处读取APPINSIGHTS\u INSTRUMENTATIONKEY?_Azure_Azure Application Insights_Webjob - Fatal编程技术网

Azure 从何处读取APPINSIGHTS\u INSTRUMENTATIONKEY?

Azure 从何处读取APPINSIGHTS\u INSTRUMENTATIONKEY?,azure,azure-application-insights,webjob,Azure,Azure Application Insights,Webjob,从何处读取InstrumentationKey context.Configuration["APPINSIGHTS_INSTRUMENTATIONKEY"]; 我已将该键放在部分的applicationInsights.config中 <InstrumentationKey>94efb022-e651-46a0-b103-5735daa213f1</InstrumentationKey> 您需要安装以下软件包: Microsoft.Azure.WebJobs.

从何处读取InstrumentationKey

context.Configuration["APPINSIGHTS_INSTRUMENTATIONKEY"];
我已将该键放在部分的applicationInsights.config中

  <InstrumentationKey>94efb022-e651-46a0-b103-5735daa213f1</InstrumentationKey>

您需要安装以下软件包:

  • Microsoft.Azure.WebJobs.Logging.ApplicationInsights(目前处于测试版)
  • Microsoft.Extensions.Logging
  • Microsoft.Extensions.Logging.Console
并按如下方式配置作业主机配置:

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;
}

您可以阅读有关Azure web作业的配置应用程序洞察。希望有帮助。

如果你想在Azure上阅读它,只需在门户的
应用程序设置中设置它

如果您在本地运行它,请在
appsettings.json
文件中添加
APPINSIGHTS\u INSTRUMENTATIONKEY
字段

{
    "AzureWebJobsStorage": "{storage connection string}",
    "APPINSIGHTS_INSTRUMENTATIONKEY": "{instrumentation key}"
}
更多信息,请参阅本文件:。希望这能对你有所帮助

{
    "AzureWebJobsStorage": "{storage connection string}",
    "APPINSIGHTS_INSTRUMENTATIONKEY": "{instrumentation key}"
}