This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal class Program | |
{ | |
private static void Main() | |
{ | |
var dashboardConnectionString = ConfigurationManager | |
.AppSettings["AzureWebJobsDashboard"]; | |
var storageConnectionString = ConfigurationManager | |
.AppSettings["AzureWebJobsStorage"]; | |
// initialise the DI container | |
var svcCollection = new ServiceCollection(); | |
// add all dependencies | |
svcCollection.AddScoped<IHttpMessageHandlerFactory, | |
MockHttpMessageHandlerFactory>(); | |
svcCollection.AddScoped<ICreditCheckFilter, | |
CreditCheckFilter>(); | |
svcCollection.AddScoped<IPipe<EnrichedLoanRequest>, | |
QueueBackedLoanQuoteSubmissionPipe>(); | |
svcCollection.AddSingleton(_ => | |
SimpleQueueHelperFactory.Create( | |
"credit-checked-loan-requests", | |
storageConnectionString)); | |
// this line is crucial for all the dependencies | |
// to be resolved correctly. | |
svcCollection.AddTransient<Functions>(); | |
var config = new JobHostConfiguration(); | |
config.DashboardConnectionString = dashboardConnectionString; | |
config.StorageConnectionString = storageConnectionString; | |
// tell the config to use the custom IJobActivator | |
// implementation with the IServiceProvider DI container | |
config.JobActivator = new MyActivator( | |
svcCollection.BuildServiceProvider()); | |
var host = new JobHost(config); | |
// The following code ensures that the WebJob will be running continuously | |
host.RunAndBlock(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment