Ojasa Mirai

Ojasa Mirai

Cloud

Loading...

Learning Level

🟢 Beginner🔵 Advanced
🔧 Azure Account Setup⚙️ Azure Compute Overview🖥️ Virtual Machines🎯 App Service Deployment⚡ Azure Functions📁 Blob Storage🗄️ Azure SQL Database📊 Cosmos DB📊 Azure Monitoring🔑 Azure Identity & Access📈 Azure Scaling & Load Balancing🐳 Azure Containers & AKS🎯 Azure Static Web Apps💰 Azure Cost Optimization
Cloud/Azure Deployment/Cosmos Db

📊 Cosmos DB

Introduction

Azure Cosmos DB is a globally distributed, multi-model database that provides low latency and high availability.

Key Learning Outcomes

By the end of this lesson, you'll understand:

  • Creating Cosmos DB accounts and databases
  • CRUD operations
  • Querying with SQL API
  • Replication and consistency
  • Partitioning and scaling
  • Cost optimization

Creating Cosmos DB Account

# Create Cosmos DB account
az cosmosdb create \
  --name mycosmosaccount \
  --resource-group myResourceGroup \
  --locations regionName=eastus failoverPriority=0

# Create database
az cosmosdb sql database create \
  --account-name mycosmosaccount \
  --resource-group myResourceGroup \
  --name mydatabase

# Create container
az cosmosdb sql container create \
  --account-name mycosmosaccount \
  --database-name mydatabase \
  --resource-group myResourceGroup \
  --name users \
  --partition-key-path /userId \
  --throughput 400

CRUD Operations

JavaScript:

const { CosmosClient } = require("@azure/cosmos");

const client = new CosmosClient({ endpoint: "https://...", key: "..." });
const database = client.database("mydatabase");
const container = database.container("users");

// Create
await container.items.create({
  id: "user1",
  userId: "123",
  name: "Alice",
  email: "alice@example.com"
});

// Read
const { resource: user } = await container.item("user1", "123").read();

// Update
await container.item("user1", "123").replace({
  ...user,
  name: "Alice Updated"
});

// Delete
await container.item("user1", "123").delete();

Querying

// Query users
const querySpec = {
  query: "SELECT * FROM c WHERE c.email = @email",
  parameters: [
    {
      name: "@email",
      value: "alice@example.com"
    }
  ]
};

const { resources } = await container.items
  .query(querySpec)
  .fetchAll();

Key Takeaways

  • **Globally distributed** - low latency worldwide
  • **Multi-model** - SQL, MongoDB, Cassandra APIs
  • **Automatic replication** - high availability
  • **Partition keys** - distribute data efficiently
  • **Serverless** - flexible pricing model

Next Steps

Learn about Azure Monitoring for performance insights, or explore containers with AKS.


Resources

Python Docs

Ojasa Mirai

Master AI-powered development skills through structured learning, real projects, and verified credentials. Whether you're upskilling your team or launching your career, we deliver the skills companies actually need.

Learn Deep • Build Real • Verify Skills • Launch Forward

Courses

PythonFastapiReactJSCloud

© 2026 Ojasa Mirai. All rights reserved.

TwitterGitHubLinkedIn