public async Task AppConfigSyncFunction( [TimerTrigger("%UpdatePollingTime%")] TimerInfo timer, ILogger log) { await queueService.ConnectAsync(); IEnumerable <Event> events; do { events = await queueService.ReceiveEventsAsync(30); if (events != null && events.Any()) { appConfigSyncService.Connect(); bool syncResult = true; foreach (var @event in events) { using (var metricLogger = new DurationMetricLogger(MetricNames.EventSynchronizationDuration, log)) { syncResult = true; if (@event.IsKeyValueModified()) // the setting was added or updated { syncResult = await appConfigSyncService.UpsertToSecondary(@event); } else if (@event.IsKeyValueDeleted()) // the setting was deleted { syncResult = await appConfigSyncService.DeleteFromSecondary(@event); } } if (syncResult) { await queueService.DeleteEventAsync(@event); } } } } while (events != null && events.Any()); }