public async Task <HttpResponseMessage> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "viewer/locators")] HttpRequest req,
            ILogger log)
        {
            TelemetryClient.TrackEvent("Locators");

            using (LoggerService.Init(log))
            {
                try
                {
                    ConfigurationModel       config = ConfigurationService.GetConfiguration();
                    AzureMediaServicesClient client = await AuthenticationService.GetClientAsync(config);

                    InputRequestService inputRequestService = new InputRequestService(client, config);
                    LocatorsController  locatorsController  = new LocatorsController(client, config);

                    InputRequestModel inputModel = await inputRequestService.GetInputRequestModelAsync(req);

                    LocatorsOutputModel outputModel = await locatorsController.GetLocatorsAsync(inputModel);

                    return(SuccessResponseService.CreateResponse(outputModel));
                }
                catch (AppException e)
                {
                    return(ReportError(e));
                }
                catch (Exception e)
                {
                    return(ReportError(e));
                }
            }
        }
Example #2
0
        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));
                }
            }
        }