-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProgram.cs
44 lines (41 loc) · 1.21 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using WebJob_netcore_sample;
var builder = Host.CreateDefaultBuilder(args);
builder.ConfigureWebJobs(b =>
{
b.AddAzureStorageCoreServices();
b.AddTimers();
});
builder.ConfigureServices(services =>
{
services.AddApplicationInsightsTelemetryWorkerService();
services.AddSingleton<ITelemetryInitializer, ComponentNameTelemetryInitializer>();
services.AddScoped<Functions>();
services.AddScoped<MyService>();
});
builder.ConfigureLogging((context, b) =>
{
b.AddAzureWebAppDiagnostics();
b.AddApplicationInsights();
b.AddConsole();
});
builder.ConfigureAppConfiguration((context, configurationBuilder) =>
{
configurationBuilder
.AddJsonFile($"appsettings.{context.HostingEnvironment.EnvironmentName}.json", optional: false)
.AddEnvironmentVariables();
if (context.HostingEnvironment.IsDevelopment())
{
configurationBuilder
.AddUserSecrets<Program>(true);
}
});
IHost host = builder.Build();
using (host)
{
await host.RunAsync();
}