/// <inheritdoc/> public async Task CreateCollectionIfNotExistsAsync() { try { await _db.CreateRepositoryIfNotExistsAsync(); Collection = await _db.Client.ReadDocumentCollectionAsync(UriFactory.CreateDocumentCollectionUri(_db.DatabaseId, _collectionId)); } catch (DocumentClientException e) { if (e.StatusCode == System.Net.HttpStatusCode.NotFound) { Collection = await _db.Client.CreateDocumentCollectionAsync( UriFactory.CreateDatabaseUri(_db.DatabaseId), new DocumentCollection { Id = _collectionId, UniqueKeyPolicy = _db.UniqueKeyPolicy }, new RequestOptions { OfferThroughput = _requestLevelLowest }); } else { throw; } } }
public void Start() { Task.Run(async() => { try { await _repository.CreateRepositoryIfNotExistsAsync(); await _applicationDatabase.Initialize(); await _certificateRequest.Initialize(); _logger.Information("Database warm start successful."); } catch (Exception ex) { _logger.Error("Failed to warm start databases.", ex); } }); }