// ReSharper disable once UnusedMember.Global
        public async Task <IActionResult> Status(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "datafactory/pipeline/status/")]
            HttpRequest req,
            ILogger logger,
            ExecutionContext executionContext)
        {
            logger.LogInformation($"{executionContext.FunctionName} triggered");
            var requestBody = await new StreamReader(req.Body).ReadToEndAsync();
            var response    = JsonConvert.DeserializeObject <PipelineResponse>(requestBody);

            if (response.Status == "Complete")
            {
                await _releaseStatusService.UpdateDataStageAsync(response.ReleaseId, response.ReleaseStatusId,
                                                                 Complete);

                if (await _releaseStatusService.IsImmediate(response.ReleaseId, response.ReleaseStatusId))
                {
                    await _queueService.QueuePublishReleaseContentMessageAsync(response.ReleaseId,
                                                                               response.ReleaseStatusId);
                }
            }
            else
            {
                logger.LogError($"ADF pipeline failed: {response}");
                await _releaseStatusService.UpdateDataStageAsync(response.ReleaseId, response.ReleaseStatusId, Failed,
                                                                 new ReleaseStatusLogMessage(
                                                                     $"Exception in data stage (ADF pipeline triggered: {response.PipelineTriggerTime}): {response.ErrorMessage}"));
            }

            logger.LogInformation($"{executionContext.FunctionName} completed");

            return(response.Status != null
                ? (ActionResult) new OkObjectResult($"status, {response.Status}")
                : new BadRequestObjectResult("No status was passed in the request body"));
        }
        private async Task <bool> IsImmediate(PublishReleaseFilesMessage message)
        {
            if (message.Releases.Count() > 1)
            {
                // If there's more than one Release this invocation couldn't have been triggered for immediate publishing
                return(false);
            }

            var(releaseId, releaseStatusId) = message.Releases.Single();
            return(await _releaseStatusService.IsImmediate(releaseId, releaseStatusId));
        }