Skip to content

Commit 54d29ee

Browse files
committed
Mock-up of approach to sharing code snippets
1 parent 8d99df4 commit 54d29ee

File tree

3 files changed

+33
-12
lines changed

3 files changed

+33
-12
lines changed

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

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
[!INCLUDE [cosmos-db-sdk-heading-java-v4-async](../../includes/cosmos-db-sdk-heading-java-v4-async.md)]
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+
[!INCLUDE [cosmos-db-sdk-heading-java-v4-sync](../../includes/cosmos-db-sdk-heading-java-v4-sync.md)]
122+
123+
[!code-java[](~/azure-cosmos-java-sql-api-samples/src/main/java/com/azure/cosmos/examples/documentationsnippets/sync/SampleDocumentationSnippetsSync.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.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
author: anfeldma-ms
3+
ms.service: cosmos-db
4+
ms.topic: include
5+
ms.date: 05/20/2020
6+
ms.author: anfeldma
7+
---
8+
9+
[Java SDK V4](sql-api-sdk-java-v4.md) (Maven [com.azure::azure-cosmos](https://mvnrepository.com/artifact/com.azure/azure-cosmos)) Async API
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
author: anfeldma-ms
3+
ms.service: cosmos-db
4+
ms.topic: include
5+
ms.date: 05/20/2020
6+
ms.author: anfeldma
7+
---
8+
9+
[Java SDK V4](sql-api-sdk-java-v4.md) (Maven [com.azure::azure-cosmos](https://mvnrepository.com/artifact/com.azure/azure-cosmos)) Sync API

0 commit comments

Comments
 (0)