/// <inheritdoc/> public async Task RouteNotificationAsync(Notification notification, bool scheduleEnabled = true) { string queueName; if (notification.IsScheduled && scheduleEnabled) { string message = JsonConvert.SerializeObject(notification); queueName = await _tableConfiguration.GetSettingAsync(ConfigurationKeys.SCHEDULE_QUEUE_NAME); await _cloudQueueStorage.SendMessageAsync(queueName, message); return; } string expectedQueue = notification.NotificationType.ToString().ToLower(); queueName = await _tableConfiguration.GetSettingAsync(_ => _.Value.Contains(expectedQueue)); if (string.IsNullOrWhiteSpace(queueName)) { throw new Exception("Expected queue not found", new Exception("Please add the expected queue into configuration table")); } await _cloudQueueStorage.CreateQueueIfNotExistsAsync(queueName); await _cloudQueueStorage.SendMessageAsync(queueName, notification.Body); }
public async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "post", Route = "notifications")] HttpRequest request) { // TODO: Use [FromBody] attribute once issue is fixed string requestBody = await new StreamReader(request.Body).ReadToEndAsync(); Notification notification = JsonConvert.DeserializeObject <Notification>(requestBody); string queueName = await _tableConfiguration.GetSettingAsync(ConfigurationKeys.NOTIFICATION_POOL_QUEUE_NAME); await _cloudQueueStorage.SendMessageAsync(queueName, requestBody); return(new AcceptedResult("notifications", notification.Id)); }