Databases in Azure Cosmos DB

A database in Azure Cosmos DB is a logical namespace that contains a set of containers. Think of it as a top-level resource for organizing your data.

Key Information: Databases in Azure Cosmos DB are regional resources. When you create a database, it resides within a specific Azure region.

Creating a Database

You can create a database using the Azure portal, Azure CLI, Azure PowerShell, or the Azure Cosmos DB SDKs.

Using the Azure Portal

  1. Navigate to your Azure Cosmos DB account in the Azure portal.
  2. In the left-hand navigation pane, select Create container.
  3. Under Database, select Create new.
  4. Enter a name for your new database.
  5. Click OK.

Using Azure CLI

The following command creates a new database named myDatabase:

az cosmosdb sql database create --account-name MyCosmosDbAccount --resource-group MyResourceGroup --name myDatabase

Database Operations

Common operations on databases include:

Tip: Deleting a database is a permanent operation and cannot be undone. All data within the database will be lost.

Database Properties

Each database has a unique name within the Azure Cosmos DB account. The database name is case-insensitive.

Throughput Provisioning

You can provision throughput at the database level. This allows all containers within that database to share the provisioned throughput. This is known as database-level throughput.

Note: While database-level throughput can simplify management, consider container-level throughput for more granular control and predictable performance for individual containers.

Next Steps

Now that you understand databases, explore other core concepts: