private static async Task RunScanWith(Options opts) { if (opts.From.HasValue != opts.To.HasValue) { Log.Error("Specifying the only one From or To dates is not supported. Both values should be set or removed"); return; } else if (opts.From.HasValue && opts.From > opts.To) { Log.Error("From date should be behind To date"); return; } var today = DateTime.UtcNow.Date; var startDate = opts.From ?? today; var endDate = opts.To ?? today; if (opts.Verbose) { loggingLevelSwitch.MinimumLevel = LogEventLevel.Verbose; } var config = new ConfigurationParser(opts.ConfigPath); var factory = new ScannerFactory(config); // Az-Sk allows to use only one output folder for all concurrently running processes. // Also, user has no control over this folder structure. // Therefore it's easier to run scan sequentially. foreach (var subscription in opts.Subscriptions) { try { var scanDate = startDate; while (scanDate <= endDate) { var subscriptionScanner = new SubscriptionScanner(factory.GetScanner(), factory.GetExporter()); var result = await subscriptionScanner.Scan(subscription, scanDate); Log .ForContext <Program>() .Information("Subscription {Subscription} was scanned with result: {ScanResult} at {ScanDate}", subscription, result.ScanResult, scanDate); scanDate = scanDate.AddDays(1); } } catch (Exception ex) { Log .ForContext <Program>() .Error(ex, "A subscription {Subscription} scanning failed", subscription); } } }