-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProgram.cs
29 lines (24 loc) · 1.03 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using AzureWorkerDemoNET6;
using Microsoft.ApplicationInsights.WorkerService;
using Microsoft.ApplicationInsights.Extensibility;
using Azure.Identity;
var builder = Host.CreateDefaultBuilder(args);
builder.ConfigureLogging(logging => logging.AddApplicationInsights());
builder.ConfigureAppConfiguration(config =>
{
var settings = config.Build();
var keyvaultUri = settings.GetSection("AppSettings").GetValue<string>("KEY_VAULT_URI");
if ( !string.IsNullOrWhiteSpace( keyvaultUri ))
config.AddAzureKeyVault(new Uri(keyvaultUri), new DefaultAzureCredential());
});
builder.ConfigureServices(services =>
{
services.AddHostedService<Worker>();
var options = new ApplicationInsightsServiceOptions() {
EnableAdaptiveSampling = false, // infrequently run command line tools should record all events
};
services.AddSingleton<ITelemetryInitializer, CustomTelemetryInitializer>();
services.AddApplicationInsightsTelemetryWorkerService( options );
});
var host = builder.Build();
await host.RunAsync();