Domain 2 β€” Module 1 of 11 9%
16 of 31 overall
Domain 2: Secure, optimize, and deploy database solutions Free ⏱ ~14 min read

Global Replication and Failover

Learn when and how to distribute Cosmos DB data globally, configure automatic failover policies, and perform manual failovers β€” including the critical detail that a recovered region returns as read-only.

Why go global?

Simple explanation

Imagine GlobeCart has warehouses in 12 countries. If all your product data sits in one warehouse in Sydney, customers in London wait for every request to fly halfway around the world.

Global replication copies your data to multiple Azure regions so reads (and optionally writes) happen close to each customer. If Sydney burns down, London keeps serving.

Jake’s scenario: taking GlobeCart global

πŸ›’ Jake at GlobeCart has 50M products served from East US. European customers complain about 200ms+ latency on product searches. His plan:

  1. Add West Europe and Southeast Asia as read replicas and measure the resulting application read latency.
  2. Configure automatic failover β€” if East US goes down, West Europe takes over writes.
  3. Keep a single write region (for now) β€” simpler consistency, lower cost.

Single-write vs multi-write architecture

AspectSingle-Write RegionMulti-Write Regions
Write latencyLow in write region, high everywhere elseLow everywhere β€” writes go to nearest region
Availability SLAConfiguration-dependent; eligible PPAF configurations can provide five ninesQualifying multi-region multi-write configurations provide five nines
Conflict resolutionNot needed β€” one writerRequired β€” Last-Writer-Wins or custom
Consistency optionsAll five levels in supported account configurations; PPAF excludes Bounded StalenessStrong is not supported; Bounded Staleness is a documented anti-pattern
CostStandard RU/s Γ— regionsHigher β€” every region serves writes
ComplexitySimple β€” one source of truthComplex β€” conflict handling, eventual consistency

Automatic failover

For classic account-level service-managed failover (also called automatic failover), enable the feature and configure regional priority. Microsoft decides when to declare an outage and promotes an eligible healthy region in that order. This is not a separate always-on feature with a different customer-enabled automatic mechanism.

Failover priority (Jake's config):
  Priority 0: East US        ← current write region
  Priority 1: West Europe    ← first to promote if East US fails
  Priority 2: Southeast Asia ← second in line

Critical exam detail β€” the recovered region: After classic account-level failover, a recovered East US does not automatically reclaim the write role. Once regions are healthy, use the supported change-write-region operation to return writes there. PPAF is different: it automatically fails affected partitions back after recovery.

Exam tip: automatic failover timing

Service-managed account failover is not instant. Declaring an outage and triggering recovery can take significant time, potentially one hour or more. Do not invent a customer-configurable detection timer or a guaranteed five-minute recovery interval.

Writes can remain unavailable while recovery is pending; healthy regions can continue serving eligible reads. Choose the recovery mechanism against the application’s actual requirements.

Planned write-region change versus forced failover

An operator can change the write region while all regions are healthy. Replication catches up before promotion, so this planned operation has no data loss. Use it for:

  • Planned maintenance or region migration
  • Disaster recovery drills
  • Moving the write region closer to shifting traffic patterns

During an active outage, the planned operation might not be available because it requires healthy regions. A region-offline / forced-failover operation is a different recovery path. With weaker-than-Strong consistency, acknowledged writes that have not replicated can be lost. Do not apply a blanket β€œmanual means zero data loss” rule to both operations.

# Trigger manual failover β€” promote West Europe to write region
az cosmosdb failover-priority-change \
  --name globecart-cosmos \
  --resource-group rg-globecart \
  --failover-policies "westeurope=0" "eastus=1" "southeastasia=2"
// Verify current write region via SDK
AccountProperties account = await client.ReadAccountAsync();
foreach (AccountRegion region in account.WritableRegions)
{
    Console.WriteLine($"Write region: {region.Name}");
}

Account-level failover versus PPAF

FeatureService-managed account failoverPer-partition automatic failover
ScopeAccount write-region promotionOnly affected partitions
TriggerMicrosoft declares outage and initiates recoveryAutomatic partition-health detection
Recovery timingCan take an hour or more to triggerDocumented partition recovery objective under three minutes at P99
Data loss riskDepends on consistency and replication stateStrong preserves RPO zero; weaker levels can diverge
FailbackOperator changes write region after recoveryAutomatic, with incremental catch-up
ConfigurationEnable service-managed failover and regional prioritiesEligible single-write provisioned NoSQL account, Direct mode, supported SDK and tier
Exam tip: identify the actual recovery operation
  • Planned change-write-region requires healthy regions and catches up replication before promotion.
  • Region-offline recovery during an outage can lose unreplicated writes with weaker consistency.
  • Classic account-level service-managed failover and PPAF have different scope, timing and failback behavior.
  • Check the current SLA and eligibility; multi-write is not the only documented path to five-nines availability.

🎬 Video walkthrough

Flashcards

Question

After classic account-level service-managed failover, does the recovered original region automatically reclaim writes?

Click or press Enter to reveal answer

Question

Is multi-write always required for five-nines Cosmos DB availability?

Click or press Enter to reveal answer

Question

Why must you distinguish a planned region change from forced outage recovery?

Click or press Enter to reveal answer

Question

Can you add or remove Azure regions from a Cosmos DB account without downtime?

Click or press Enter to reveal answer

Knowledge Check

Knowledge Check

GlobeCart uses classic account-level service-managed failover, not PPAF, with priority: East US (0), West Europe (1), Southeast Asia (2). West Europe is promoted during an East US outage. After East US recovers, which region remains the writer without an operator change?

Knowledge Check

All GlobeCart regions are healthy. Jake wants to move its write region from East US to West Europe for planned maintenance without data loss. Which operation fits?

Knowledge Check

Which listed consistency level is unsupported with multi-region writes?


Next up: Multi-Region Writes β€” configure active-active writes and understand conflict handling.