private static async Task <HttpResponseMessage> ReportErrorAsync(ConfigurationModel config, Exception exception) { LoggerService.CaptureException(exception); await WebhookService.CallWebhookAsync(config.WebhookStartFailure, ActionEnum.Start, ResourceStatusEnum.Error); return(ErrorResponseService.CreateResponse(exception)); }
public async Task <HttpResponseMessage> Run( [HttpTrigger(AuthorizationLevel.Function, "delete", Route = "broadcaster")] HttpRequest req, ILogger log) { TelemetryClient.TrackEvent("Stop"); using (LoggerService.Init(log)) { ConfigurationModel config = ConfigurationService.GetConfiguration(); try { AzureMediaServicesClient client = await AuthenticationService.GetClientAsync(config); InputRequestService inputRequestService = new InputRequestService(client, config); StopController stopController = new StopController(client, config); InputRequestModel inputModel = await inputRequestService.GetInputRequestModelAsync(req); StatusChangeOutputModel outputModel = await stopController.StopServicesAsync(inputModel); await WebhookService.CallWebhookAsync(config.WebhookStartSuccess, ActionEnum.Stop, outputModel.Status.Summary.Name); return(SuccessResponseService.CreateResponse(outputModel)); } catch (AppException e) { return(await ReportErrorAsync(config, e)); } catch (Exception e) { return(await ReportErrorAsync(config, e)); } } }