public async Task Run( [ServiceBusTrigger(TEXTS, Connection = TEXT_QUEUES_CONNECTION)] Message message, ILogger log) { log.LogInformation($"C# ServiceBus queue trigger function processed message: {message}"); try { var correlationId = string.IsNullOrWhiteSpace(message.CorrelationId) ? Guid.NewGuid().ToString() : message.CorrelationId; await _porter.Run(message, correlationId).ConfigureAwait(false); } catch (Azure.Messaging.ServiceBus.ServiceBusException ex) when(ex.Reason == ServiceBusFailureReason.MessagingEntityAlreadyExists) { log.LogWarning(ex, ex.Message); } catch (Exception ex) { log.LogError(ex, ex.Message); } }
public async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req, ILogger log) { try { log.LogInformation("C# HTTP trigger function processed a request."); var corellationID = Guid.NewGuid().ToString(); await _porter.Run(req, corellationID).ConfigureAwait(false); return(new OkObjectResult(new Dictionary <string, string> { ["correlationId"] = corellationID })); } catch (Exception ex) { return(new BadRequestObjectResult(ex.Message)); } }