Repository navigation
Expand file tree
/
Copy pathProgram.cs
More file actions
73 lines (65 loc) · 2.42 KB
/
Copy pathProgram.cs
File metadata and controls
73 lines (65 loc) · 2.42 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using Common.Web;
using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using ProblemSource.Services.Storage.AzureTables;
using ProblemSourceModule.Services;
using WebJob;
using Microsoft.Azure.WebJobs.Logging.ApplicationInsights;
var builder = new HostBuilder();
builder.ConfigureWebJobs(b =>
{
//b.AddAzureStorageCoreServices();
//b.AddAzureStorage();
//b.AddTimers();
})
.ConfigureAppConfiguration(b =>
{
b.AddJsonFile("appsettings.json");
//b.AddCommandLine(args);
})
.ConfigureLogging((context, b) =>
{
if (context.Configuration["environment"] == Environments.Development)
{
b.SetMinimumLevel(LogLevel.Debug);
b.AddConsole();
}
else
{
b.SetMinimumLevel(LogLevel.Information);
b.AddConsole();
}
var aiConn = context.Configuration.GetValue<string>("ApplicationInsights:ConnectionString");
if (!string.IsNullOrEmpty(aiConn))
b.AddApplicationInsightsWebJobs(config => config.ConnectionString = aiConn);
// configure CommonLogging to use Serilog
//var logConfig = new LogConfiguration();
//context.Configuration.GetSection("LogConfiguration").Bind(logConfig);
//LogManager.Configure(logConfig);
//var log = new LoggerConfiguration()
// .WriteTo
// .File("webjob-log.txt", rollingInterval: RollingInterval.Day)
// .CreateLogger();
//Log.Logger = log;
})
.ConfigureServices((context, services) =>
{
services.AddSingleton(context.Configuration);
services.AddSingleton<IWorkInstanceProvider, WorkInstanceProvider>();
//services.AddMemoryCache();
TypedConfiguration.ConfigureTypedConfiguration<AzureTableConfig>(services, context.Configuration, "AppSettings:AzureTable");
//var section = context.Configuration.GetRequiredSection("AppSettings:AzureTable");
//var tableConfig = TypedConfiguration.Bind<AzureTableConfig>(section);
services.AddSingleton<TrainingAnalyzerCollection>();
new ProblemSource.ProblemSourceModule().ConfigureForAzureTables(services, useCaching: false);
})
.UseConsoleLifetime();
using (var host = builder.Build())
{
await host.StartAsync();
var jobHost = host.Services.GetRequiredService<IJobHost>();
await jobHost.CallAsync(nameof(Functions.ContinuousMethod));
}