Skip to content

Commit 25aeff5

Browse files
committed
Additional replica items
1 parent 61e5606 commit 25aeff5

File tree

1 file changed

+62
-48
lines changed

1 file changed

+62
-48
lines changed

articles/cosmos-db/mongodb/vcore/quickstart-cross-region-replica-portal.md

Lines changed: 62 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ You can also select add 0.0.0.0 - 255.255.255.255 firewall rule to allow not jus
118118

119119
## Connect to primary cluster and ingest data
120120

121-
Get the connection string you need to connect to this primary cluster using your application code.
121+
Get the connection string you need to connect to the primary (read-write) cluster in the Azure portal.
122122

123123
1. From the Azure Cosmos DB for MongoDB vCore primary cluster page, select the **Connection strings** navigation menu option under **Settings**.
124124

@@ -129,68 +129,72 @@ Get the connection string you need to connect to this primary cluster using your
129129
> [!IMPORTANT]
130130
> The connection string in the portal does not include the username and password values. You must replace the `<user>` and `<password>` placeholders with the credentials you entered when you created the cluster.
131131
132-
1. In MongoDB shell, connect to the primary cluster using the connection string.
132+
1. In command line, use the MongoDB shell to connect to the primary cluster using the connection string.
133133

134134
```cmd
135-
mongosh mongodb+srv://<user>@<cluster_name>.mongocluster.cosmos.azure.com/?tls=true&authMechanism=SCRAM-SHA-256&retrywrites=false&maxIdleTimeMS=120000
135+
mongosh mongodb+srv://<user>@<primary_cluster_name>.mongocluster.cosmos.azure.com/?tls=true&authMechanism=SCRAM-SHA-256&retrywrites=false&maxIdleTimeMS=120000
136136
```
137137

138-
1. Create a *my_script.js* script file to run from the MongoDB shell. This script file creates two collections and inserts documents with data into those collections.
138+
### Ingest data
139+
140+
Create a *my_script.js* script file to run from the MongoDB shell.
139141

140142
```JavaScript
141-
let dogDocs = [
142-
{
143-
name: "pooch",
144-
breed: "poodle",
145-
weight: "6 lbs"
146-
},
147-
{
148-
name: "mutt",
149-
breed: "bulldog",
150-
weight: "10 lbs"
151-
}
152-
];
153-
154-
let catDocs = [
155-
{
156-
name: "minni",
157-
breed: "persian",
158-
color: "white"
159-
},
160-
{
161-
name: "tinkle",
162-
breed: "bombay",
163-
color: "black"
164-
}
165-
];
166-
167-
let dogIndex = { name : 1 };
168-
let catIndex = { name : 1 };
169-
170-
let collInfoObjs = [
171-
{ coll: "dogs", data: dogDocs, index: dogIndex },
172-
{ coll: "cats", data: catDocs, index: catIndex }
173-
];
174-
175-
for (obj of collInfoObjs) {
176-
db[obj.coll].insertMany(obj.data);
177-
db[obj.coll].createIndex(obj.index);
178-
}
143+
let dogDocs = [
144+
{
145+
name: "pooch",
146+
breed: "poodle",
147+
weight: "6 lbs"
148+
},
149+
{
150+
name: "mutt",
151+
breed: "bulldog",
152+
weight: "10 lbs"
153+
}
154+
];
155+
156+
let catDocs = [
157+
{
158+
name: "minni",
159+
breed: "persian",
160+
color: "white"
161+
},
162+
{
163+
name: "tinkle",
164+
breed: "bombay",
165+
color: "black"
166+
}
167+
];
168+
169+
let dogIndex = { name : 1 };
170+
let catIndex = { name : 1 };
171+
172+
let collInfoObjs = [
173+
{ coll: "dogs", data: dogDocs, index: dogIndex },
174+
{ coll: "cats", data: catDocs, index: catIndex }
175+
];
176+
177+
for (obj of collInfoObjs) {
178+
db[obj.coll].insertMany(obj.data);
179+
db[obj.coll].createIndex(obj.index);
180+
}
179181
```
180182

181-
1. Run the script from the MongoDB shell.
183+
This script file creates two collections and inserts documents with data into those collections.
184+
185+
Run the script from the MongoDB shell.
182186

183187
```MongoDB Shell
184188
load(my_script.js);
185189
```
186190

187-
1. In the MongoDB shell, read data from the database.
191+
In the MongoDB shell, read data from the database.
188192

189193
```MongoDB Shell
190194
db.dogs.find();
191195
db.cats.find();
192196
```
193-
197+
194198
## Connect to read replica cluster in another region and read data
195199

196200
Get the connection string for the read cluster replica in another region.
@@ -199,20 +203,30 @@ Get the connection string for the read cluster replica in another region.
199203

200204
:::image type="content" source="media/quickstart-cross-region-replication/global-distribution-page-on-primary-cluster.png" alt-text="Screenshot of the global distribution preview page in the primary cluster propteries.":::
201205

202-
1. Select the cluster replica name to open the read cluster replica properties in the Azure portal.
206+
1. Select *cluster replica name* to open the read cluster replica properties in the Azure portal.
203207

204208
1. On the replica cluster sidebar, under **Cluster management**, select **Connection strings**.
205209

206210
1. Copy the value from the **Connection string** field.
207211

208212
> [!IMPORTANT]
209-
> The connection string in the portal does not include the username and password values. You must replace the `<user>` and `<password>` placeholders with the credentials you entered when you created the cluster.
213+
> The connection string of the read replica cluster in the portal contains unique replica cluster name that you selected during replica creation. The username and password values for the read replica cluster are always the same as the ones on its primary cluster.
210214
211-
1. In MongoDB shell, connect to the read replica cluster using its connection string.
215+
1. In command line, use the MongDB shell to connect to the read replica cluster using its connection string.
212216

213217
```cmd
214218
mongosh mongodb+srv://<user>@<cluster_replica_name>.mongocluster.cosmos.azure.com/?tls=true&authMechanism=SCRAM-SHA-256&retrywrites=false&maxIdleTimeMS=120000
215219
```
220+
### Read data from replica cluster
221+
222+
In the MongoDB shell, read data from the database.
223+
224+
```MongoDB Shell
225+
db.dogs.find();
226+
db.cats.find();
227+
```
228+
229+
216230

217231

218232
## Clean up resources

0 commit comments

Comments
 (0)