Skip to content

Commit 8bd78fe

Browse files
authored
Merge pull request #115961 from anfeldma-ms/JV4APILink
Mock-up of approach to sharing code snippets
2 parents e1dbd3f + 51e4e28 commit 8bd78fe

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

.openpublishing.publish.config.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,11 @@
515515
"url": "https://github.com/Azure-Samples/azure-cosmos-java-getting-started",
516516
"branch": "master"
517517
},
518+
{
519+
"path_to_root": "azure-cosmos-java-sql-api-samples",
520+
"url": "https://github.com/Azure-Samples/azure-cosmos-java-sql-api-samples",
521+
"branch": "master"
522+
},
518523
{
519524
"path_to_root": "azure-storage-snippets",
520525
"url": "https://github.com/azure-samples/AzureStorageSnippets",

articles/cosmos-db/tutorial-global-distribution-sql-api.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ms.reviewer: sngun
1111
---
1212
# Tutorial: Set up Azure Cosmos DB global distribution using the SQL API
1313

14-
In this article, we show how to use the Azure portal to setup Azure Cosmos DB global distribution and then connect using the SQL API.
14+
In this article, we show how to use the Azure portal to set up Azure Cosmos DB global distribution and then connect using the SQL API.
1515

1616
This article covers the following tasks:
1717

@@ -105,21 +105,24 @@ client = cosmos_client.CosmosClient(ENDPOINT, {'masterKey': MASTER_KEY}, connect
105105

106106
```
107107

108-
## Java V2 SDK
108+
## Java V4 SDK
109109

110110
The following code shows how to set preferred locations by using the Java SDK:
111111

112-
```java
113-
ConnectionPolicy policy = new ConnectionPolicy();
114-
policy.setUsingMultipleWriteLocations(true);
115-
policy.setPreferredLocations(Arrays.asList("East US", "West US", "Canada Central"));
116-
AsyncDocumentClient client =
117-
new AsyncDocumentClient.Builder()
118-
.withMasterKeyOrResourceToken(this.accountKey)
119-
.withServiceEndpoint(this.accountEndpoint)
120-
.withConnectionPolicy(policy)
121-
.build();
122-
```
112+
### <a id="java4-preferred-locations"></a>
113+
#### [Async](#tab/api-async)
114+
115+
[Java SDK V4](sql-api-sdk-java-v4.md) (Maven [com.azure::azure-cosmos](https://mvnrepository.com/artifact/com.azure/azure-cosmos)) Async API
116+
117+
[!code-java[](~/azure-cosmos-java-sql-api-samples/src/main/java/com/azure/cosmos/examples/documentationsnippets/async/SampleDocumentationSnippetsAsync.java?name=TutorialGlobalDistributionPreferredLocationAsync)]
118+
119+
#### [Sync](#tab/api-sync)
120+
121+
[Java SDK V4](sql-api-sdk-java-v4.md) (Maven [com.azure::azure-cosmos](https://mvnrepository.com/artifact/com.azure/azure-cosmos)) Sync API
122+
123+
[!code-java[](~/azure-cosmos-java-sql-api-samples/src/main/java/com/azure/cosmos/examples/documentationsnippets/sync/SampleDocumentationSnippets.java?name=TutorialGlobalDistributionPreferredLocationSync)]
124+
125+
---
123126

124127
## REST
125128
Once a database account has been made available in multiple regions, clients can query its availability by performing a GET request on the following URI.

0 commit comments

Comments
 (0)