Manage cross-region replication on your Azure Cosmos DB for MongoDB vCore cluster (preview)
APPLIES TO: MongoDB vCore
Important
Cross-region replication in Azure Cosmos DB for MongoDB vCore is currently in preview. This preview version is provided without a service level agreement (SLA), and it's not recommended for production workloads. Certain features might not be supported or might have constrained capabilities.
Azure Cosmos DB for MongoDB vCore allows continuous data streaming to a replica cluster in another Azure region. That capability provides cross-region disaster recovery (DR) protection and read scalability across the regions. This document serves as a quick guide for developers who want to learn how to manage cross-region replication for their clusters.
Prerequisites
- An Azure account with an active subscription. Create an account for free.
Enable cross-region replication
To enable cross-region replication on a new cluster during cluster creation, follow these steps:
- Follow the steps to create a new Azure Cosmos DB for MongoDB vCore cluster.
- On the Basics tab, select Enable global distribution (preview) flag.
- On the Global distribution (preview) tab, select Enable for the Read replica in another region (preview).
- Provide a replica cluster name in the Read replica name field.
- Select a region in the Read replica region. The replica cluster is hosted in the selected Azure region.
- (optionally) Select desired network access settings for the cluster on the Networking tab.
- On the Review + create tab, review cluster configuration details, and then select Create.
Note
The replica cluster is created in the same Azure subscirption and resource group as its primary cluster.
To enable cross-region replication on a new cluster at any time after cluster creation, follow these steps:
- Follow the steps to create a new Azure Cosmos DB for MongoDB vCore cluster.
- On the Basics tab, select Enable global distribution (preview) flag.
- Skip Global distribution (preview) tab. This tab is used to create a cluster replica during primary cluster provisioning.
- Once cluster is created, on the cluster sidebar, under Settings, select Global distribution (preview).
- Select Add new read replica.
- Provide a replica cluster name in the Read replica name field.
- Select a region in the Read replica region. The replica cluster is hosted in the selected Azure region.
- Verify your selection and select the Save button to confirm replica creation.
Promote a replica
To promote a cluster replica to a read-write cluster, follow these steps:
- Select the cluster replica you would like to promote in the portal.
- On the cluster sidebar, under Settings, select Global distribution.
- On the Global distribution page, select Promote.
- On the Promote <cluster name> screen, double check the cluster replica's name, read the warning text, and select Promote.
After the cluster replica is promoted, it becomes a readable and writable cluster.
Check cluster replication role and replication region
To check replication role of a cluster, follow these steps:
- Select an existing Azure Cosmos DB for MongoDB vCore cluster.
- Select Overview page.
- Check Read region (on the primary cluster) or Write region (on the replica cluster) value.
If Read region value is Not enabled, this cluster has cross-region replication disabled.
Disable cross-region replication
To disable cross-region replication, follow these steps:
- Select the Azure Cosmos DB for MongoDB vCore replica cluster.
- Select Overview.
- Confirm that it's a replica cluster.
- In the Azure portal, on the Overview page for the replica cluster, select Delete.
- On the Delete <replica name> screen, read the warning text, and enter cluster's name in the Confirm the account name field.
- Select Delete to confirm deletion of the replica.
If you need to delete the primary and replica clusters, you would need to delete the replica cluster first.
Use connection strings
You can connect to the cluster replica as you would to a regular read-write cluster. Follow these steps to get the connection strings for different cases:
- Select the primary cluster or its cluster replica in the portal.
- On the cluster sidebar, under Settings, select Connection strings.
- Copy the connection string for currently selected cluster to connect to that cluster.
Connection strings are preserved after the cluster replica promotion. You can continue to use either string for read operations. You need to change connection string to point to the promoted replica cluster to continue writes to the database after promotion is completed.