Share via


DatabaseProperties Class

Definition

Represents a database in the Azure Cosmos DB account.

[System.Text.Json.Serialization.JsonConverter(typeof(Azure.Cosmos.TextJsonDatabasePropertiesConverter))]
public class DatabaseProperties
[<System.Text.Json.Serialization.JsonConverter(typeof(Azure.Cosmos.TextJsonDatabasePropertiesConverter))>]
type DatabaseProperties = class
Public Class DatabaseProperties
Inheritance
DatabaseProperties
Attributes

Examples

The example below creates a new Database with an Id property of 'MyDatabase'.

using (DocumentClient client = new DocumentClient(new Uri("service endpoint"), "auth key"))
{
    Database db = await client.CreateDatabaseAsync(new Database { Id = "MyDatabase" });
}

The example below creates a collection within this database with OfferThroughput set to 10000.

DocumentCollection coll = await client.CreateDocumentCollectionAsync(db.SelfLink,
    new DocumentCollection { Id = "MyCollection" }, 
    10000);

The example below queries for a Database by Id to retrieve the SelfLink.

using Microsoft.Azure.Cosmos.Linq;
Database database = client.CreateDatabaseQuery().Where(d => d.Id == "MyDatabase").AsEnumerable().FirstOrDefault();
string databaseLink = database.SelfLink;

The example below deletes the database using its SelfLink property.

await client.DeleteDatabaseAsync(db.SelfLink);

Remarks

Each Azure Cosmos DB database account can have zero or more databases. A database in Azure Cosmos DB is a logical container for document collections and users. Refer to for more details on databases.

Constructors

DatabaseProperties()

Initializes a new instance of the DatabaseProperties class for the Azure Cosmos DB service.

DatabaseProperties(String)

Initializes a new instance of the DatabaseProperties class for the Azure Cosmos DB service.

Properties

ETag

Gets the entity tag associated with the resource from the Azure Cosmos DB service.

Id

Gets or sets the Id of the resource in the Azure Cosmos DB service.

LastModified

Gets the last modified time stamp associated with DatabaseProperties from the Azure Cosmos DB service.

Applies to

See also