public async Task <IActionResult> GetUploadURL( [HttpTrigger(AuthorizationLevel.Anonymous, "POST", Route = "MediaService/GetUploadURL")] [RequestBodyType(typeof(MetadataInputDTO), "Get Upload URL")] HttpRequest req, [SwaggerIgnore] ILogger log) { try { try { var credential = await GetAmsCredential(log); string requestBody = await new StreamReader(req.Body).ReadToEndAsync(); var input = JsonConvert.DeserializeObject <MetadataInputDTO>(requestBody); var result = new MetadataOutputDTO(); var asset = new AssetAMS(); asset.Id = Guid.NewGuid().ToString(); asset.Filename = input.FileName; asset.Subject = input.Subject ?? input.FileName; asset.Status = "draft"; asset.CreatedDateUtc = DateTime.UtcNow; asset.CreatedDate = DateTime.UtcNow.AddHours(7); asset.CreatedBy = input.Author; asset.ContentAddress = asset.Id; asset.UploadUrl = result.UploadUrl = (await _amsService.InitVideoContainer(credential, asset.ContentAddress, asset.Filename)).ToString(); await _amsService.CreateAssetAMS(asset); result.ResourceId = asset.Id; result.ContentAddress = asset.ContentAddress; return(new OkObjectResult(result)); } catch (Exception e) { log.LogError(e.ToString()); return(new BadRequestResult()); } } catch (Exception ex) { return(new BadRequestObjectResult(ex.Message)); } }