Azure Cosmos DB for NoSQL
Azure Cosmos DB is a fully managed, globally distributed NoSQL database service that offers turnkey global replication, enterprise-grade security, and the ability to elastically scale throughput and storage.
Getting Started
Follow the quickstart to provision a Cosmos DB account and explore basic operations.
az group create --name myResourceGroup --location eastus
az cosmosdb create --name myCosmosAccount --resource-group myResourceGroup --kind GlobalDocumentDB
Key Concepts
- Containers: Logical collections of items that share the same partition key.
- Items: Individual JSON documents stored within containers.
- Partitioning: Distributes data across physical partitions for scalability.
- Request Units (RU): The currency for throughput, representing the cost of database operations.
Sample Code (Node.js)
const { CosmosClient } = require("@azure/cosmos");
const client = new CosmosClient({ endpoint: "", key: "" });
async function run() {
const database = client.database("MyDatabase");
const container = database.container("MyContainer");
const { resource: item } = await container.items.create({ id: "item1", name: "Sample" });
console.log(item);
}
run();
Resources
Explore more topics: