private async Task TruncateEnvironment() { var databases = _documentClient.CreateDatabaseQuery().AsEnumerable().ToList(); foreach (var database in databases) { await _documentClient.DeleteDatabaseAsync(database.SelfLink); } }
private static async Task DeleteDatabase(IDocumentClient client) { Console.WriteLine(); Console.WriteLine("#### Deleting Database ####"); Database database = client.CreateDatabaseQuery().AsEnumerable().First(); await client.DeleteDatabaseAsync(database.SelfLink); Console.WriteLine($"Database Id: {database.Id}; Resource Id: {database.ResourceId} deleted"); }
private static async Task DeleteDatabase(IDocumentClient client, string databaseId) { Console.WriteLine(">>> Delete Database <<<"); Uri databaseUri = UriFactory.CreateDatabaseUri(databaseId); ResourceResponse <Database> foo = await client.DeleteDatabaseAsync(databaseUri); Database database = foo.Resource; PrintDatabase(database); }
/// <summary> /// Deletes the database. /// </summary> /// <param name="dbId">Id of the database to delete.</param> /// <param name="requestOptions">Request options</param> /// <returns>Database with specified database id.</returns> public async Task <ResourceResponse <Database> > DeleteDatabaseAsync( string dbId, RequestOptions requestOptions = null) { Code.ExpectsNotNullOrWhiteSpaceArgument(dbId, nameof(dbId), 0); IDocumentClient client = await GetDocumentClientAsync().ConfigureAwait(false); return(await DocumentDbAdapter.ExecuteAndLogAsync( 0, () => client.DeleteDatabaseAsync(UriFactory.CreateDatabaseUri(dbId), requestOptions)) .ConfigureAwait(false)); }
public async Task DeleteDatabaseIfExistsAsync() { try { await _client.DeleteDatabaseAsync(UriFactory.CreateDatabaseUri(_databaseId)); } catch (DocumentClientException e) { // If I know the exact error type, I'll validate that. _logger.LogWarning($"Database {_databaseId} couldn't delete. You can ignore this message if there is no Database is there.", e); } }
public async Task DropDatabaseAsync() { var databaseUri = _configs.DatabaseUri; try { await _client.DeleteDatabaseAsync(databaseUri); } catch (DocumentClientException ex) { if (ex.StatusCode != HttpStatusCode.NotFound) { throw; } } }
private static async Task DeleteDatabase(IDocumentClient client) { await client.DeleteDatabaseAsync(UriFactory.CreateDatabaseUri(GroupDB)); }
public async Task <bool> DeleteAsync(RequestOptions options = null) { var response = await _client.DeleteDatabaseAsync(await SelfLinkAsync(), options); return(response.StatusCode == HttpStatusCode.NoContent); }