/// <summary> /// Inserts a receipt like record in the database. This record will be updated when the processing /// is completed with success or error details /// </summary> /// <param name="state">metadata provided with input video (manifest type data)</param> /// <returns></returns> public async Task StoreProcessingStateRecordInCosmosAsync(VippyProcessingState state) { var collectionName = ProcessingStateCosmosCollectionName; var client = GetCosmosClient(collectionName); // upsert the json as a new document try { Document r = await client.UpsertDocumentAsync( UriFactory.CreateDocumentCollectionUri(CosmosDatabasename, collectionName), state); } catch (Exception e) { throw new ApplicationException($"Error in StoreProcessingStateRecordInCosmosAsync:/r/n{e.Message}"); } }
public static async Task ProcessBlogIntoQueue(CloudBlockBlob inputVideoBlob, string manifestContents, IAsyncCollector <string> outputQueue, TraceWriter log, Enums.OriginEnum origin) { var baseHelper = new BaseHelper(log); VippyProcessingState manifest; try { if (!string.IsNullOrEmpty(manifestContents)) { manifest = JsonConvert.DeserializeObject <VippyProcessingState>(manifestContents); baseHelper.LogMessage($"Manifest present, deserializing"); } else { manifest = new VippyProcessingState(); baseHelper.LogMessage($"Manifest empty"); } } catch (Exception e) { baseHelper.LogMessage($"Error with manifest deserialization:{e.Message}"); throw new ApplicationException($"Invalid manifest file provided for video {inputVideoBlob.Name}"); } // work out the global id for this video. If internal_id was in manifest json, use that. // Otherwise create a new one var internalId = manifest.AlternateId; var globalId = !string.IsNullOrEmpty(internalId) ? internalId : Guid.NewGuid().ToString(); manifest.Origin = origin; // stuff it back into the manifest manifest.AlternateId = globalId; manifest.BlobName = inputVideoBlob.Name; manifest.StartTime = DateTime.Now; baseHelper.LogMessage($"Video '{inputVideoBlob.Name}' landed in watch folder" + (manifestContents != null ? " with manifest json" : "without manifest file")); await outputQueue.AddAsync(manifest.ToString()); }