Hands-on exercises on Azure Cosmos DB NoSQL API

Below are the Hands-on  exercises that you can practice on Azure Cosmos DB NoSQL API, integrated across various Azure services. Each section gives you distinct, practical tasks to deepen your proficiency.

Sign up for Azure Portal Free Azure Portal Access - Cloud Nerchuko to practice hands-on.

1. Azure Cosmos DB NoSQL API

Using anyone programming language to interact with NoSQL API. Ex: Python SDK, Java SDK or .NET SDK etc.

Database and Container Management

  1. Create, read, list, and delete databases in Cosmos DB account.
  2. Create, query, list, and delete containers.

Item Operations (CRUD & Beyond)

  1. Create, read, upsert, query, replace, and delete items
  2. Read all items or iterate over query results
  3. Use point reads vs. queries; apply continuation tokens and pagination 
  4. Use patch/partial updates, perform bulk inserts and transactional batches
  5. Use ETags for optimistic concurrency control
  6. Manage TTL (time-to-live), request metrics, session consistency, and index policies.

Indexing Controls

  • Define indexing policies, include/exclude paths, use composite and range indexes 

Server-Side Programming

  • Develop and invoke stored procedures, triggers, and user‑defined functions (UDFs) in JavaScript.

Change Feed & Change Feed Processor

  • Consume change feed using container.query_items_change_feed or via Change Feed Processor in supported SDKs (Python doesn’t support processor library directly)
  • Use Azure Functions (Cosmos DB trigger) to process changes as they happen. 

Migration & Bulk Movement of Data

  • Use bulk SDK operations to move data between containers or accounts manually.

Capacity Planning & Scaling

  • Configure throughput (manual/auto scale), provision globally distributed accounts, apply ARM templates, use CLI for failover, key management, and encryption. 

Synapse Link & Analytical Store

  • Enable analytical store or Synapse Link for near-real-time analytics with no ETL

Monitoring, Backup, & Security

  • Set up alerts, analyze metrics, manage backup configurations, configure RBAC, customer‑managed keys, CORS, and network access policies

2. Azure Functions

Hands‑on tasks involving Cosmos DB:

  • Create Cosmos DB trigger for Azure Function to process inserts, updates, deletes in real time using the change feed.

  • Use Functions to handle change feed events reliably at scale, across partitions

3. Azure Data Factory (ADF) / Synapse Pipelines

Hands‑on integration scenarios:

  • Data copy & transformation

    • Use Copy Activity to move data to/from Cosmos DB (insert/upsert/delete), using key, service principal, or managed identity authentication.

    • Use Mapping Data Flows for transformation logic (e.g. derive new columns, filter, flatten JSON) 

  • Change Feed Integration in Pipelines

    • Use Cosmos DB change feed as a source, enabling incremental processing without code.

  • Analytical Store CDC (public preview)

    • Capture incremental changes from analytical store via ADF or Synapse with minimal ETL, supporting filters and transformations 

4. Microsoft Fabric

  1. Ingesting the data into Cosmos DB Containers and doing CRUD operations using Microsoft Fabric.
  2. Use Cosmos DB API to interact with Azure Cosmos DB.
  3. Near real‑time analytics with no ETL

    • Mirror Cosmos DB data into Fabric’s OneLake or use Synapse Link for seamless Apache Spark-based querying and ML workflows

    • Build BI dashboards or ML models using Spark/MLOps on live operational data.

  4. Bulk ingestion of data into Cosmos DB containers using Spark connector for Cosmos DB NoSQL.

5. Azure Event hubs

  • Change‑feed event streaming

    • Build a pipeline: Drop data into Cosmos DB → Process change feed via Function → Push to Event Hub → Azure Data Explorer for streaming analytics and dashboards.

6. Azure Logic Apps

  • Use Cosmos DB connectors to automate workflows:
  • Trigger logic apps on document change or creation
  • Move or process data based on Cosmos DB changes
  • Orchestrate business processes with conditionals and connectors (email, Teams, etc.)

Comments