Azure 从何处读取APPINSIGHTS\u INSTRUMENTATIONKEY?
从何处读取InstrumentationKeyAzure 从何处读取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.
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}"
}