public async Task Run( [EventGridTrigger()] EventGridEvent eventGridEvent, ILogger logger) { try { EventSchema reservationEvent = new EventSchema() { ID = eventGridEvent.Id, BookReservation = ((JObject)eventGridEvent.Data).ToObject <BookReservation>(), EventTime = eventGridEvent.EventTime, EventType = (ReservationStatus)Enum.Parse(typeof(ReservationStatus), eventGridEvent.EventType), Subject = eventGridEvent.Subject }; try { logger.LogInformation(new EventId(Convert.ToInt32(Logging.EventId.CreateReserveration)), Logging.LoggingTemplate, reservationEvent.BookReservation.CorrelationID, nameof(CreateReservation), reservationEvent.EventType.ToString(), Logging.Status.Started.ToString(), "Creating auditing entry." ); await _sqlHelper.CreateReservation(reservationEvent).ConfigureAwait(false); logger.LogInformation(new EventId(Convert.ToInt32(Logging.EventId.CreateReserveration)), Logging.LoggingTemplate, reservationEvent.BookReservation.CorrelationID, nameof(CreateReservation), reservationEvent.EventType.ToString(), Logging.Status.Succeeded.ToString(), "Completed creating auditing entry." ); } catch (Exception ex) { //Output Exception Event logger.LogError(new EventId(Convert.ToInt32(Logging.EventId.CreateReserveration)), Logging.LoggingTemplate, reservationEvent.BookReservation.CorrelationID, nameof(CreateReservation), reservationEvent.EventType.ToString(), Logging.Status.Failed.ToString(), string.Format("Failed while creating auditing entry. Exception {0}", ex.Message) ); } } catch (Exception ex) { logger.LogError(new EventId(Convert.ToInt32(Logging.EventId.CreateReserveration)), Logging.GenericExceptionLoggingTemplate, nameof(CreateReservation), Logging.Status.Failed.ToString(), string.Format("Failed while parsing incoming event. Exception {0}", ex.Message) ); } }