CosmosClient class

Provides a client-side logical representation of the Azure Cosmos DB database account. This client is used to configure and execute requests in the Azure Cosmos DB database service.

Constructors

CosmosClient(CosmosClientOptions)

Properties

databases

Used for creating new databases, or querying/reading all databases. Use .database(id) to read, replace, or delete a specific, existing database by id.

offers

Used for querying & reading all offers. Use .offer(id) to read, or replace existing offers.

Methods

database(string)

Used for reading, updating, or deleting a existing database by id or accessing containers belonging to that database. This does not make a network call. Use .read to get info about the database after getting the <xref:Database> object.

getDatabaseAccount(RequestOptions)

Get information about the current <xref:DatabaseAccount> (including which regions are supported, etc.)

getReadEndpoint()

Gets the currently used read endpoint. Useful for troubleshooting purposes. The url may contain a region suffix (e.g. "-eastus") if we're using location specific endpoints.

getWriteEndpoint()

Gets the currently used write endpoint url. Useful for troubleshooting purposes. The url may contain a region suffix (e.g. "-eastus") if we're using location specific endpoints.

offer(string)

Used for reading, or updating a existing offer by id.

Constructor Details

CosmosClient(CosmosClientOptions)

new CosmosClient(options: CosmosClientOptions)

Parameters

options
CosmosClientOptions

Property Details

databases

Used for creating new databases, or querying/reading all databases. Use .database(id) to read, replace, or delete a specific, existing database by id.

databases: Databases

Property Value

Databases

offers

Used for querying & reading all offers. Use .offer(id) to read, or replace existing offers.

offers: Offers

Property Value

Offers

Method Details

database(string)

Used for reading, updating, or deleting a existing database by id or accessing containers belonging to that database. This does not make a network call. Use .read to get info about the database after getting the <xref:Database> object.

function database(id: string)

Parameters

id
string

The id of the database.

Returns

Database

getDatabaseAccount(RequestOptions)

Get information about the current <xref:DatabaseAccount> (including which regions are supported, etc.)

function getDatabaseAccount(options?: RequestOptions)

Parameters

options
RequestOptions

Returns

Promise<CosmosResponse<DatabaseAccount, CosmosClient>>

getReadEndpoint()

Gets the currently used read endpoint. Useful for troubleshooting purposes. The url may contain a region suffix (e.g. "-eastus") if we're using location specific endpoints.

function getReadEndpoint()

Returns

Promise<string>

getWriteEndpoint()

Gets the currently used write endpoint url. Useful for troubleshooting purposes. The url may contain a region suffix (e.g. "-eastus") if we're using location specific endpoints.

function getWriteEndpoint()

Returns

Promise<string>

offer(string)

Used for reading, or updating a existing offer by id.

function offer(id: string)

Parameters

id
string

The id of the offer.

Returns

Offer