// ReSharper disable once UnusedMember.Global public async Task PublishStagedReleaseContent([TimerTrigger("%PublishReleaseContentCronSchedule%")] TimerInfo timer, ExecutionContext executionContext, ILogger logger) { logger.LogInformation($"{executionContext.FunctionName} triggered at: {DateTime.Now}"); var scheduled = (await QueryScheduledReleases()).ToList(); if (scheduled.Any()) { var published = new List <ReleaseStatus>(); foreach (var releaseStatus in scheduled) { logger.LogInformation($"Moving content for release: {releaseStatus.ReleaseId}"); await UpdateStage(releaseStatus, Started); try { await _publishingService.PublishStagedReleaseContentAsync(releaseStatus.ReleaseId); published.Add(releaseStatus); } catch (Exception e) { logger.LogError(e, $"Exception occured while executing {executionContext.FunctionName}"); await UpdateStage(releaseStatus, Failed, new ReleaseStatusLogMessage($"Exception in publishing stage: {e.Message}")); } } var releaseIds = published.Select(status => status.ReleaseId).ToArray(); try { if (!PublisherUtils.IsDevelopment()) { await _releaseService.DeletePreviousVersionsStatisticalData(releaseIds); } await _contentService.DeletePreviousVersionsDownloadFiles(releaseIds); await _contentService.DeletePreviousVersionsContent(releaseIds); await _notificationsService.NotifySubscribers(releaseIds); await UpdateStage(published, Complete); } catch (Exception e) { logger.LogError(e, $"Exception occured while executing {executionContext.FunctionName}"); await UpdateStage(published, Failed, new ReleaseStatusLogMessage($"Exception in publishing stage: {e.Message}")); } } logger.LogInformation( $"{executionContext.FunctionName} completed. {timer.FormatNextOccurrences(1)}"); }