Skip to content

Commit 3340c29

Browse files
committed
Adding tabs
1 parent e5acf07 commit 3340c29

File tree

1 file changed

+29
-15
lines changed

1 file changed

+29
-15
lines changed

articles/cosmos-db/how-to-manage-consistency.md

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ This article explains how to manage consistency levels in Azure Cosmos DB. You l
1818

1919
The [default consistency level](consistency-levels.md) is the consistency level that clients use by default.
2020

21-
### CLI
21+
# [Azure portal](#tab/portal
22+
23+
To view or modify the default consistency level, sign in to the Azure portal. Find your Azure Cosmos account, and open the **Default consistency** pane. Select the level of consistency you want as the new default, and then select **Save**. The Azure portal also provides a visualization of different consistency levels with music notes.
24+
25+
![Consistency menu in the Azure portal](./media/how-to-manage-consistency/consistency-settings.png)
26+
27+
# [CLI](#tab/cli)
2228

2329
Create a Cosmos account with Session consistency, then update the default consistency.
2430

@@ -30,7 +36,7 @@ az cosmosdb create --name $accountName --resource-group $resourceGroupName --def
3036
az cosmosdb update --name $accountName --resource-group $resourceGroupName --default-consistency-level Strong
3137
```
3238

33-
### PowerShell
39+
# [PowerShell](#tab/powershell)
3440

3541
Create a Cosmos account with Session consistency, then update the default consistency.
3642

@@ -44,11 +50,7 @@ Update-AzCosmosDBAccount -ResourceGroupName $resourceGroupName `
4450
-Name $accountName -DefaultConsistencyLevel "Strong"
4551
```
4652

47-
### Azure portal
48-
49-
To view or modify the default consistency level, sign in to the Azure portal. Find your Azure Cosmos account, and open the **Default consistency** pane. Select the level of consistency you want as the new default, and then select **Save**. The Azure portal also provides a visualization of different consistency levels with music notes.
50-
51-
![Consistency menu in the Azure portal](./media/how-to-manage-consistency/consistency-settings.png)
53+
---
5254

5355
## Override the default consistency level
5456

@@ -57,7 +59,9 @@ Clients can override the default consistency level that is set by the service. C
5759
> [!TIP]
5860
> Consistency can only be **relaxed** at the request level. To move from weaker to stronger consistency, update the default consistency for the Cosmos account.
5961
60-
### <a id="override-default-consistency-dotnet"></a>.NET SDK V2
62+
### <a id="override-default-consistency-dotnet"></a>.NET SDK
63+
64+
# [.NET SDK V2](#tab/dotnetv2)
6165

6266
```csharp
6367
// Override consistency at the client level
@@ -69,7 +73,7 @@ RequestOptions requestOptions = new RequestOptions { ConsistencyLevel = Consiste
6973
var response = await client.CreateDocumentAsync(collectionUri, document, requestOptions);
7074
```
7175

72-
### <a id="override-default-consistency-dotnet-v3"></a>.NET SDK V3
76+
# [.NET SDK V3](#tab/dotnetv3)
7377

7478
```csharp
7579
// Override consistency at the request level via request options
@@ -81,8 +85,11 @@ var response = await client.GetContainer(databaseName, containerName)
8185
new PartitionKey(itemPartitionKey),
8286
requestOptions);
8387
```
88+
---
8489

85-
### <a id="override-default-consistency-java-async"></a>Java Async SDK
90+
### <a id="override-default-consistency-java"></a>Java SDK
91+
92+
# [Java Async SDK](#tab/javaasync)
8693

8794
```java
8895
// Override consistency at the client level
@@ -96,13 +103,14 @@ AsyncDocumentClient client =
96103
.withConnectionPolicy(policy).build();
97104
```
98105

99-
### <a id="override-default-consistency-java-sync"></a>Java Sync SDK
106+
# [Java sync SDK](#tab/javasync)
100107

101108
```java
102109
// Override consistency at the client level
103110
ConnectionPolicy connectionPolicy = new ConnectionPolicy();
104111
DocumentClient client = new DocumentClient(accountEndpoint, accountKey, connectionPolicy, ConsistencyLevel.Eventual);
105112
```
113+
---
106114

107115
### <a id="override-default-consistency-javascript"></a>Node.js/JavaScript/TypeScript SDK
108116

@@ -132,7 +140,9 @@ One of the consistency levels in Azure Cosmos DB is *Session* consistency. This
132140

133141
To manage session tokens manually, get the session token from the response and set them per request. If you don't need to manage session tokens manually, you don't need to use these samples. The SDK keeps track of session tokens automatically. If you don't set the session token manually, by default, the SDK uses the most recent session token.
134142

135-
### <a id="utilize-session-tokens-dotnet"></a>.NET SDK V2
143+
### <a id="utilize-session-tokens-dotnet"></a>.NET SDK
144+
145+
# [.NET SDK V2](#tab/dotnetv2)
136146

137147
```csharp
138148
var response = await client.ReadDocumentAsync(
@@ -145,7 +155,7 @@ var response = await client.ReadDocumentAsync(
145155
UriFactory.CreateDocumentUri(databaseName, collectionName, "SalesOrder1"), options);
146156
```
147157

148-
### <a id="utilize-session-tokens-dotnet-v3"></a>.NET SDK V3
158+
# [.NET SDK V3](#tab/dotnetv3)
149159

150160
```csharp
151161
Container container = client.GetContainer(databaseName, collectionName);
@@ -156,8 +166,11 @@ ItemRequestOptions options = new ItemRequestOptions();
156166
options.SessionToken = sessionToken;
157167
ItemResponse<SalesOrder> response = await container.ReadItemAsync<SalesOrder>(salesOrder.Id, new PartitionKey(salesOrder.PartitionKey), options);
158168
```
169+
---
159170

160-
### <a id="utilize-session-tokens-java-async"></a>Java Async SDK
171+
### <a id="utilize-session-tokens-java"></a>Java SDK
172+
173+
# [Java Async SDK](#tab/javaasync)
161174

162175
```java
163176
// Get session token from response
@@ -179,7 +192,7 @@ requestOptions.setSessionToken(sessionToken);
179192
Observable<ResourceResponse<Document>> readObservable = client.readDocument(document.getSelfLink(), options);
180193
```
181194

182-
### <a id="utilize-session-tokens-java-sync"></a>Java Sync SDK
195+
# [Java sync SDK](#tab/javasync)
183196

184197
```java
185198
// Get session token from response
@@ -191,6 +204,7 @@ RequestOptions options = new RequestOptions();
191204
options.setSessionToken(sessionToken);
192205
ResourceResponse<Document> response = client.readDocument(documentLink, options);
193206
```
207+
---
194208

195209
### <a id="utilize-session-tokens-javascript"></a>Node.js/JavaScript/TypeScript SDK
196210

0 commit comments

Comments
 (0)