public static void Run( [TimerTrigger("0 30 6 * * *")] TimerInfo myTimer, TraceWriter tracer, [SendGrid(ApiKey = "SendGridApiKey")] IAsyncCollector <Mail> mails) { if (mails is null) { throw new ArgumentNullException(nameof(mails)); } var log = new Logger(tracer); try { log.Info("Beginning execution"); var configurationLocation = Environment.GetEnvironmentVariable("SubscriberConfigurationLocation"); log.Info("Downloading configuration from " + configurationLocation + "..."); var configurationString = DownloadConfigurationString(configurationLocation); log.Info("Downloaded configuration"); var comicMailBuilder = new ComicMailBuilder( DateTime.Now.Date, new ConfigurationParser(configurationString), new WebComicFetcher(), log); foreach (var mail in comicMailBuilder.CreateMailMessage()) { mails.AddAsync(mail); } } catch (Exception e) { log.Error("Error " + e.ToString()); } log.Info("Finished execution"); }
public static void Run( [TimerTrigger("0 30 6 * * *")] TimerInfo myTimer, TraceWriter tracer, [SendGrid(ApiKey = "SendGridApiKey")] IAsyncCollector <Mail> mails) { var log = new Logger(tracer); log.Info("Beginning execution"); var comicMailBuilder = new ComicMailBuilder( DateTime.Now.Date, new SimpleConfigurationParser( Environment.GetEnvironmentVariable("TestSubscriberConfiguration") ?? Environment.GetEnvironmentVariable("SubscriberConfiguration")), new WebComicFetcher(), log); foreach (var mail in comicMailBuilder.CreateMailMessage()) { mails.AddAsync(mail); } log.Info("Finished execution"); }