Skip to content

Instantly share code, notes, and snippets.

@explorer14
Last active June 10, 2018 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save explorer14/e6d84b68de347ccb91fcd2c9c5ae4324 to your computer and use it in GitHub Desktop.
Save explorer14/e6d84b68de347ccb91fcd2c9c5ae4324 to your computer and use it in GitHub Desktop.
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