-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathProgram.cs
More file actions
55 lines (50 loc) · 2.14 KB
/
Program.cs
File metadata and controls
55 lines (50 loc) · 2.14 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
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Common;
using Data.Database;
using Common.Interfaces;
using Microsoft.Extensions.Logging;
using NHS.Screening.ReceiveCaasFile;
using Model;
using DataServices.Client;
using HealthChecks.Extensions;
var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole());
var logger = loggerFactory.CreateLogger("program.cs");
try
{
var host = new HostBuilder()
.AddConfiguration<ReceiveCaasFileConfig>(out ReceiveCaasFileConfig config)
.AddConfiguration<AuditClientConfig>()
.AddDataServicesHandler()
.AddDataService<ParticipantDemographic>(config.DemographicDataServiceURL)
.AddCachedDataService<ScreeningLkp>(config.ScreeningLkpDataServiceURL)
.Build()
.ConfigureFunctionsWorkerDefaults()
.ConfigureServices(services =>
{
services.AddSingleton<IReceiveCaasFileHelper, ReceiveCaasFileHelper>();
services.AddScoped<IProcessCaasFile, ProcessCaasFile>(); //Do not change the lifetime of this.
services.AddSingleton<ICreateResponse, CreateResponse>();
services.AddScoped<ICheckDemographic, CheckDemographic>();
services.AddScoped<ICallDurableDemographicFunc, CallDurableDemographicFunc>();
services.AddScoped<ICreateBasicParticipantData, CreateBasicParticipantData>();
services.AddScoped<IAddBatchToQueue, AddBatchToQueue>();
services.AddScoped<IRecordsProcessedTracker, RecordsProcessedTracker>(); //Do not change the lifetime of this.
services.AddTransient<IBlobStorageHelper, BlobStorageHelper>();
services.AddTransient<ICopyFailedBatchToBlob, CopyFailedBatchToBlob>();
services.AddScoped<IValidateDates, ValidateDates>();
// Register health checks
services.AddBlobStorageHealthCheck("receiveCaasFile");
})
.AddTelemetry()
.AddHttpClient()
.AddAuditLogging(config.ServiceBusConnectionString_client_internal)
.AddExceptionHandler()
.AddDatabaseConnection()
.Build();
await host.RunAsync();
}
catch (Exception ex)
{
logger.LogCritical(ex, "failed to start up function receive caas file");
}