Azure CosmosDB Mongo

Azure Cosmos MongoDB is a fully managed, serverless NoSQL database for high-performance applications of any size or scale using the MongoDB API.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Made by

Massdriver

Official

Yes

Azure Cosmos DB for MongoDB

Azure Cosmos DB for MongoDB is a fully-managed NoSQL database service designed to scale horizontally with flexible schemas. It provides high availability, multi-region replication, automated failover, and low-latency read/write operations.

Design Decisions

  • Automatic Failover: Configured to enable automatic failover to enhance availability.
  • Multiple Write Locations: Supports multiple write locations to allow writes in any region.
  • Geo-Redundancy: Configures paired regions and supports additional regions for enhanced redundancy.
  • Backup Configuration: Supports both continuous and periodic backups to ensure data safety.
  • Network Security: Uses virtual network rules, private endpoints, and DNS zones to restrict network access.
  • Monitoring and Alarming: Implements monitors and alarms for RU consumption and server latency to ensure operational efficiency.
  • Capabilities: Enables serverless, aggregation pipeline, document-level TTL, and MongoDB version 3.4 capabilities.

Runbook

Connection Issues to MongoDB Instance

If you are experiencing issues connecting to the Azure Cosmos DB instance, verify the connection details and permissions.

Check MongoDB connection info:

az cosmosdb show --name <cosmosdb_account_name> --resource-group <resource_group>

Expected output should contain correct connection strings and available keys.

Ensure you can ping the database endpoint:

ping <cosmosdb_account_name>.mongo.cosmos.azure.com

Check your firewall rules to see if the IP is allowed:

az cosmosdb list-keys --name <cosmosdb_account_name> --resource-group <resource_group> | jq

High RU Consumption

If the database is consuming more than the allocated Request Units (RU), investigate the workloads and adjust provisioned RUs or optimize queries.

Monitor RU consumption:

az monitor metrics list --resource <resource_id> --metric "NormalizedRUConsumption"

Optimize queries using indexes:

db.collection.createIndex({ fieldname: 1 })

Latency Issues

If you are experiencing high latency, ensure that your configurations leverage the closest region/replica and verify the health.

Check latency metrics:

az monitor metrics list --resource <resource_id> --metric "ServerSideLatency"

Verify database health using Mongo shell:

db.serverStatus().opcounters

Ensure indexes are in place to optimize read/write efficiency:

db.collection.createIndex({ fieldname: 1 })

Backup and Restore Issues

If you encounter issues with backup or restore processes, check the configured backup settings.

Verify backup settings:

az cosmosdb show --name <cosmosdb_account_name> --resource-group <resource_group> --query "backupPolicy"

Restore data using a point in time restore:

az cosmosdb restore --name <cosmosdb_account_name> --resource-group <resource_group> --restore-timestamp <timestamp>

Permission Issues

Ensure the necessary permissions are granted to the service principal or user accessing the Cosmos DB.

Check current permissions:

az cosmosdb sql role assignment list --account-name <cosmosdb_account_name> --resource-group <resource_group>

Grant necessary permissions:

az cosmosdb sql role assignment create --account-name <cosmosdb_account_name> --resource-group <resource_group> --scope "/" --role-definition-id "<role_id>" --principal-id "<principal_id>"

These commands and guidelines should help you effectively manage and troubleshoot your Azure Cosmos DB for MongoDB instances.

VariableTypeDescription
backups.backup_typestringThe backup type to use for the Cosmos DB account. This cannot be changed after it is set.
database.consistency_levelstringThe consistency level to use for this CosmosDB Account. Learn more.
database.mongo_server_versionstringThe server version of the MongoDB account.
database.serverlessbooleanNo description
database.total_throughput_limitintegerThe total throughput limit imposed on this Cosmos DB account in RU/s (-1 means no limit).
geo_redundancy.additional_regions[].failover_priorityintegerThe failover priority of the region. The lower the value, the higher the priority is. Minimum value is 2, maximum value is 100.
geo_redundancy.additional_regions[].locationstringThe Azure region to host replicated data.
geo_redundancy.automatic_failoverbooleanNo description
geo_redundancy.multi_region_writesbooleanNo description
monitoring.modestringEnable and customize Function App metric alarms.
network.autobooleanEnabling this will automatically select an available CIDR range for your database. Unchecking will require you to specify the CIDR.