【发布时间】:2022-01-06 12:18:23
【问题描述】:
我在为各种类型的应用配置 AppInsights 采样时遇到了 this MSDN article。
但是我找不到为 azure webjobs 配置它的方法。
在为 WebJob 配置 appinsights 时,它看起来像这样 (MSDN):
static async Task Main()
{
var builder = new HostBuilder();
builder.UseEnvironment(EnvironmentName.Development);
builder.ConfigureWebJobs(b =>
{
b.AddAzureStorageCoreServices();
b.AddAzureStorage();
});
builder.ConfigureLogging((context, b) =>
{
b.AddConsole();
// If the key exists in settings, use it to enable Application Insights.
string instrumentationKey = context.Configuration["APPINSIGHTS_INSTRUMENTATIONKEY"];
if (!string.IsNullOrEmpty(instrumentationKey))
{
b.AddApplicationInsightsWebJobs(o => o.InstrumentationKey = instrumentationKey);
}
});
var host = builder.Build();
using (host)
{
await host.RunAsync();
}
}
相关代码为:
b.AddApplicationInsightsWebJobs(o => o.InstrumentationKey = instrumentationKey);
选项本身如下:
是否可以禁用自适应采样?
非常感谢任何帮助。谢谢!
【问题讨论】:
标签: azure azure-application-insights azure-webjobs