Example #1
0
        public async Task <HttpResponseMessage> Run(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = "broadcaster")] HttpRequest req,
            ILogger log)
        {
            TelemetryClient.TrackEvent("Start");

            using (LoggerService.Init(log))
            {
                ConfigurationModel config = ConfigurationService.GetConfiguration();

                try
                {
                    AzureMediaServicesClient client = await AuthenticationService.GetClientAsync(config);

                    InputRequestService inputRequestService = new InputRequestService(client, config);
                    StartController     startController     = new StartController(client, config);

                    InputRequestModel inputModel = await inputRequestService.GetInputRequestModelAsync(req);

                    StatusChangeOutputModel outputModel = await startController.StartServicesAsync(inputModel);

                    await WebhookService.CallWebhookAsync(config.WebhookStartSuccess, ActionEnum.Start, outputModel.Status.Summary.Name);

                    return(SuccessResponseService.CreateResponse(outputModel, HttpStatusCode.Created));
                }
                catch (AppException e)
                {
                    return(await ReportErrorAsync(config, e));
                }
                catch (Exception e)
                {
                    return(await ReportErrorAsync(config, e));
                }
            }
        }