Share via


CosmosDatabase Class

Definition

Operations for reading or deleting an existing database.

CosmosClient for or creating new databases, and reading/querying all databases; use client.Databases.

public abstract class CosmosDatabase
type CosmosDatabase = class
Public MustInherit Class CosmosDatabase
Inheritance
CosmosDatabase

Remarks

Note: all these operations make calls against a fixed budget. You should design your system such that these calls scale sub-linearly with your application. For instance, do not call `database.ReadAsync()` before every single `item.ReadAsync()` call, to ensure the database exists; do this once on application start up.

Constructors

CosmosDatabase()

Properties

Id

The Id of the Cosmos database

Methods

CreateContainerAsync(ContainerProperties, Nullable<Int32>, RequestOptions, CancellationToken)

Creates a container as an asynchronous operation in the Azure Cosmos service.

CreateContainerAsync(String, String, Nullable<Int32>, RequestOptions, CancellationToken)

Creates a container as an asynchronous operation in the Azure Cosmos service.

CreateContainerIfNotExistsAsync(ContainerProperties, Nullable<Int32>, RequestOptions, CancellationToken)

Check if a container exists, and if it doesn't, create it. Only the container id is used to verify if there is an existing container. Other container properties such as throughput are not validated and can be different then the passed properties.

CreateContainerIfNotExistsAsync(String, String, Nullable<Int32>, RequestOptions, CancellationToken)

Check if a container exists, and if it doesn't, create it. This will make a read operation, and if the container is not found it will do a create operation.

CreateContainerStreamAsync(ContainerProperties, Nullable<Int32>, RequestOptions, CancellationToken)

Creates a container as an asynchronous operation in the Azure Cosmos service.

CreateUserAsync(String, RequestOptions, CancellationToken)

Creates a user as an asynchronous operation in the Azure Cosmos service.

DefineContainer(String, String)

Creates a containerBuilder.

DeleteAsync(RequestOptions, CancellationToken)

Delete a DatabaseProperties from the Azure Cosmos DB service as an asynchronous operation.

DeleteStreamAsync(RequestOptions, CancellationToken)

Delete a DatabaseProperties from the Azure Cosmos DB service as an asynchronous operation.

GetContainer(String)

Returns a reference to a container object.

GetContainerQueryIterator<T>(QueryDefinition, String, QueryRequestOptions, CancellationToken)

This method creates a query for containers under an database using a SQL statement. It returns a FeedIterator. For more information on preparing SQL statements with parameterized values, please see QueryDefinition overload.

GetContainerQueryIterator<T>(String, String, QueryRequestOptions, CancellationToken)

This method creates a query for containers under an database using a SQL statement. It returns a FeedIterator. For more information on preparing SQL statements with parameterized values, please see QueryDefinition overload.

GetContainerQueryStreamIterator(QueryDefinition, String, QueryRequestOptions, CancellationToken)

This method creates a query for containers under an database using a SQL statement. It returns a FeedIterator. For more information on preparing SQL statements with parameterized values, please see QueryDefinition overload.

GetContainerQueryStreamIterator(String, String, QueryRequestOptions, CancellationToken)

This method creates a query for containers under an database using a SQL statement. It returns a FeedIterator. For more information on preparing SQL statements with parameterized values, please see QueryDefinition overload.

GetUser(String)

Returns a reference to a user object.

GetUserQueryIterator<T>(QueryDefinition, String, QueryRequestOptions, CancellationToken)

This method creates a query for users under an database using a SQL statement. It returns a FeedIterator. For more information on preparing SQL statements with parameterized values, please see QueryDefinition overload.

GetUserQueryIterator<T>(String, String, QueryRequestOptions, CancellationToken)

This method creates a query for users under an database using a SQL statement. It returns a FeedIterator. For more information on preparing SQL statements with parameterized values, please see QueryDefinition overload.

ReadAsync(RequestOptions, CancellationToken)

Reads a DatabaseProperties from the Azure Cosmos service as an asynchronous operation.

ReadStreamAsync(RequestOptions, CancellationToken)

Reads a DatabaseProperties from the Azure Cosmos service as an asynchronous operation.

ReadThroughputAsync(CancellationToken)

Gets database throughput in measurement of request units per second in the Azure Cosmos service.

ReadThroughputAsync(RequestOptions, CancellationToken)

Gets database throughput in measurement of request units per second in the Azure Cosmos service.

ReplaceThroughputAsync(Int32, RequestOptions, CancellationToken)

Sets throughput provisioned for a database in measurement of request units per second in the Azure Cosmos service.

UpsertUserAsync(String, RequestOptions, CancellationToken)

Upserts a user as an asynchronous operation in the Azure Cosmos service.

Applies to