public void Initialize(string modelsDirectory) { Database databaseId = new Database { Id = _databaseId }; ResourceResponse <Database> database = _database.CreateDatabaseIfNotExistsAsync(databaseId).Result; Uri databaseUri = UriFactory.CreateDatabaseUri(_databaseId); string settingKey = Constant.AppSettingKey.DatabaseCollectionThroughputUnits; string throughputUnits = AppSetting.GetValue(settingKey); RequestOptions collectionOptions = new RequestOptions() { OfferThroughput = int.Parse(throughputUnits) }; DocumentCollection documentCollection = new DocumentCollection() { Id = Constant.Database.Collection.ContentInsight }; ResourceResponse <DocumentCollection> collection = _database.CreateDocumentCollectionIfNotExistsAsync(databaseUri, documentCollection, collectionOptions).Result; Uri collectionUri = UriFactory.CreateDocumentCollectionUri(_databaseId, documentCollection.Id); string collectionDirectory = string.Concat(modelsDirectory, @"\", documentCollection.Id); string jsFile = string.Concat(collectionDirectory, @"\Functions\isTimecodeFragment.js"); UserDefinedFunction function = new UserDefinedFunction() { Id = "isTimecodeFragment", Body = File.ReadAllText(jsFile) }; _database.CreateUserDefinedFunctionAsync(collectionUri, function); jsFile = string.Concat(collectionDirectory, @"\Procedures\getTimecodeFragment.js"); StoredProcedure procedure = new StoredProcedure() { Id = "getTimecodeFragment", Body = File.ReadAllText(jsFile) }; _database.CreateStoredProcedureAsync(collectionUri, procedure); documentCollection = new DocumentCollection() { Id = Constant.Database.Collection.ProcessorConfig }; collection = _database.CreateDocumentCollectionIfNotExistsAsync(databaseUri, documentCollection, collectionOptions).Result; collectionUri = UriFactory.CreateDocumentCollectionUri(_databaseId, documentCollection.Id); collectionDirectory = string.Concat(modelsDirectory, @"\", documentCollection.Id); jsFile = string.Concat(collectionDirectory, @"\Procedures\getProcessorConfig.js"); procedure = new StoredProcedure() { Id = "getProcessorConfig", Body = File.ReadAllText(jsFile) }; _database.CreateStoredProcedureAsync(collectionUri, procedure); string presetsDirectory = string.Concat(modelsDirectory, @"\ProcessorPresets"); string[] mediaProcessors = Directory.GetDirectories(presetsDirectory); foreach (string mediaProcessor in mediaProcessors) { string[] processorPresets = Directory.GetFiles(mediaProcessor); foreach (string processorPreset in processorPresets) { if (processorPreset.EndsWith(Constant.Media.FileExtension.Json, StringComparison.OrdinalIgnoreCase)) { StreamReader streamReader = new StreamReader(processorPreset); JsonTextReader presetReader = new JsonTextReader(streamReader); JObject presetConfig = JObject.Load(presetReader); UpsertDocument(documentCollection.Id, presetConfig); } } } }