Configure at least two regions for high availability
Impact:HighCategory:High Availability
APRL GUID:43663217-a1d3-844b-80ea-571a2ce37c6c
Description:
Enable a secondary region in Cosmos DB for higher SLA without downtime. Simple as pinning a location on a map. For Strong consistency, configure at least three regions for write availability in case of failure.
Enable service-managed failover for multi-region accounts with single write region
Impact:HighCategory:Disaster Recovery
APRL GUID:9cabded7-a1fc-6e4a-944b-d7dd98ea31a2
Description:
Cosmos DB boasts high uptime and resiliency. Even so, issues may arise. With Service-Managed failover, if a region is down, Cosmos DB automatically switches to the next available region, requiring no user action.
When availability zones are configured, Azure Cosmos DB intelligently distributes the 4 replicas of your data across all available zones. It ensures that your Azure Cosmos DB can withstand an outage in one availability zone and remain fully operational throughout.
Click the Azure Resource Graph tab to view the query
//AzureResourceGraphQuery//QuerytofindAzureCosmosDBaccountsthatdonotutilizeavailabilityzonesandaredeployedinavailability-zonesupportedregionsResources|wheretype=="microsoft.documentdb/databaseaccounts"|whereproperties.capabilities!has_cs'EnableServerless'|projectrecommendationId='921631f6-ed59-49a5-94c1-f0f3ececa580',name,id,tags,locations=properties.locations|mv-expandlocations|wherenot(locations.isZoneRedundant)//filteroutalreadyAZenabledregions|extendlocation=tostring(locations.locationName)|project-awaylocations|wherelocationin('Australia East','Brazil South','Canada Central','Central India','Central US','China North 3','East Asia','East US','East US 2','France Central','Germany West Central','Israel Central','Italy North','Japan East','Japan West','Korea Central','Mexico Central','New Zealand North','North Europe','Norway East','Poland Central','Qatar Central','South Africa North','South Central US','Southeast Asia','Spain Central','Sweden Central','Switzerland North','UAE North','UK South','US Gov Virginia','West Europe','West US 2','West US 3')//filteroutregionsunsupportedforAZs|project-renameparam1=location
Evaluate multi-region write capability
Impact:HighCategory:High Availability
APRL GUID:9ce78192-74a0-104c-b5bb-9a443f941649
Description:
Multi-region write capability allows for designing applications that are highly available across multiple regions, though it demands careful attention to consistency requirements and conflict resolution. Improper setup may decrease availability and cause data corruption due to unhandled conflicts.
Cosmos DB's backup is always on, offering protection against data mishaps. Continuous mode allows for self-serve restoration to a pre-mishap point, unlike periodic mode which requires contacting Microsoft support, leading to longer restore times.
Cosmos DB has a 4 MB response limit, leading to paginated results for large or partition-spanning queries. Each page shows availability and provides a continuation token for the next. A while loop in code is necessary to traverse all pages until completion.
Click the Azure Resource Graph tab to view the query
//under-development
Maintain singleton pattern in your client
Impact:MediumCategory:Scalability
APRL GUID:7eb32cf9-9a42-1540-acf8-597cbba8a418
Description:
Using a single instance of the SDK client for each account and application is crucial as connections are tied to the client. Compute environments have a limit on open connections, affecting connectivity when exceeded.
Click the Azure Resource Graph tab to view the query
//under-development
Implement retry logic in your client
Impact:MediumCategory:High Availability
APRL GUID:fa6ac22f-0584-bb4b-80e4-80f4755d1a97
Description:
Cosmos DB SDKs automatically manage many transient errors through retries. Despite this, it's crucial for applications to implement additional retry policies targeting specific cases that the SDKs can't generically address, ensuring more robust error handling.
Click the Azure Resource Graph tab to view the query
//under-development
Monitor Cosmos DB health and set up alerts
Impact:MediumCategory:Monitoring and Alerting
APRL GUID:deaea200-013c-414b-ac9f-bfa7a7fb13f0
Description:
Monitoring the availability and responsiveness of Azure Cosmos DB resources and having alerts set up for your workload is a good practice. This ensures you stay proactive in handling unforeseen events.