コード例 #1
0
        /// <inheritdoc/>
        protected override async Task <ResponseBaseDTO> DoWorkAsync(RequestMediaServicesV2EncodeCreateDTO eventData, string eventType)
        {
            // Call the service that will do work:
            ServiceOperationResultEncodeDispatched encodeDispatched = await _mediaServicesV2Encoder.EncodeCreateAsync(eventData).ConfigureAwait(false);

            // Convert the service operation result into a success DTO:
            return(new ResponseEncodeDispatchedDTO(CustomEventTypes.ResponseEncodeMediaServicesV2Dispatched)
            {
                WorkflowJobName = encodeDispatched.WorkflowJobName,
                EncoderContext = encodeDispatched.EncoderContext,
                OperationContext = encodeDispatched.OperationContext,
            });
        }
コード例 #2
0
        public async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "post", "get", Route = null)] HttpRequest req,
            ILogger log)
        {
            string jobId;

            try
            {
                // TODO: Parse your arguments to build a job
                var todo = req?.ContentLength;

                string requestBody;
                using (var sr = new StreamReader(req?.Body))
                {
                    requestBody = await sr.ReadToEndAsync().ConfigureAwait(false);
                }

                var parameters = JsonConvert.DeserializeObject <EncodingFunctionInputDTO>(requestBody);

                string     presetName         = parameters?.PresetName ?? throw new Exception("Property 'presetName' is missing in the json body.");
                List <Uri> sourceUris         = parameters?.Inputs?.Select(i => i.BlobUri).ToList() ?? throw new Exception("Property 'inputs' is missing in the json body.");
                string     outputAssetStorage = parameters?.OutputAssetStorage;

                var operationContext = parameters?.OperationContext;

                jobId = await _mediaServicesV2Encoder.EncodeCreateAsync(
                    presetName,
                    sourceUris,
                    outputAssetStorage,
                    operationContext).ConfigureAwait(false);
            }
            catch (Exception e)
            {
                return(new BadRequestObjectResult(new { error = $"Failed.\n\nException.Message:\n{e.Message}\n\nInnerException.Message:\n{e.InnerException?.Message}" }));
            }

            var msg = $"Started: {jobId}";

            log.LogInformation(msg);
            return(new OkObjectResult(msg));
        }