Skip to content

Commit 81964df

Browse files
Merge pull request #72319 from rimman/edits472019
fixed typos
2 parents 48679d7 + 20bcbbd commit 81964df

12 files changed

+117
-113
lines changed

articles/cosmos-db/consistency-levels-across-apis.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
22
title: Consistency levels and Azure Cosmos DB APIs
33
description: Understanding the consistency levels across APIs in Azure Cosmos DB.
4-
author: markjbrown
5-
ms.author: mjbrown
4+
author: rimman
5+
ms.author: rimman
66
ms.service: cosmos-db
77
ms.topic: conceptual
8-
ms.date: 10/23/2018
8+
ms.date: 04/08/2019
99
ms.reviewer: sngun
1010
---
1111

articles/cosmos-db/consistency-levels-tradeoffs.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
22
title: Availability and performance tradeoffs for various consistency levels in Azure Cosmos DB
33
description: Availability and performance tradeoffs for various consistency levels in Azure Cosmos DB.
4-
author: markjbrown
4+
author: rimman
55
ms.service: cosmos-db
66
ms.topic: conceptual
7-
ms.date: 2/13/2019
8-
ms.author: mjbrown
7+
ms.date: 04/08/2019
8+
ms.author: rimman
99
ms.reviewer: sngun
1010
---
1111

articles/cosmos-db/database-transactions-optimistic-concurrency.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
---
22
title: Database transactions and optimistic concurrency control in Azure Cosmos DB
33
description: This article describes database transactions and optimistic concurrency control in Azure Cosmos DB
4-
author: markjbrown
4+
author: rimman
55
ms.service: cosmos-db
66
ms.topic: conceptual
7-
ms.date: 11/14/2018
8-
ms.author: mjbrown
7+
ms.date: 04/08/2019
8+
ms.author: rimman
99
ms.reviewer: sngun
1010
---
1111

1212
# Transactions and optimistic concurrency control
1313

14-
Database transactions provide a safe and predictable programming model to deal with concurrent changes to the data. Traditional relational databases, like SQL Server allow you to write the business logic using stored-procedures and/or triggers, send it to the server for execution directly within the database engine. With traditional relational databases, you are required to deal with two different programming languages- the (non-transactional) application programming language such as JavaScript, Python, C#, Java, etc. and the transactional programming language (T-SQL) that is natively executed by the database.
14+
Database transactions provide a safe and predictable programming model to deal with concurrent changes to the data. Traditional relational databases, like SQL Server, allow you to write the business logic using stored-procedures and/or triggers, send it to the server for execution directly within the database engine. With traditional relational databases, you are required to deal with two different programming languages the (non-transactional) application programming language such as JavaScript, Python, C#, Java, etc. and the transactional programming language (such as T-SQL) that is natively executed by the database.
1515

16-
The database engine in Azure Cosmos DB supports full ACID (Atomicity, Consistency, Isolation, Durability) compliant transactions with snapshot isolation. All the database operations within the scope of a container's logical partition are transactionally executed within the database engine that is hosted by the replica of the partition. These operations include both write (updating one or more items within the logical partition) and read operations. The following table illustrates different operations and transcation types:
16+
The database engine in Azure Cosmos DB supports full ACID (Atomicity, Consistency, Isolation, Durability) compliant transactions with snapshot isolation. All the database operations within the scope of a container's [logical partition](partition-data.md) are transactionally executed within the database engine that is hosted by the replica of the partition. These operations include both write (updating one or more items within the logical partition) and read operations. The following table illustrates different operations and transcation types:
1717

1818
| **Operation** | **Operation Type** | **Single or Multi Item Transaction** |
1919
|---------|---------|---------|
@@ -36,21 +36,21 @@ The database engine in Azure Cosmos DB supports full ACID (Atomicity, Consistenc
3636

3737
## Multi-item transactions
3838

39-
Azure Cosmos DB allows you to write stored procedures, pre/post triggers, user-defined-functions (UDFs) and merge procedures in JavaScript. Azure Cosmos DB natively supports JavaScript execution inside its database engine. You can register stored procedures, pre/post triggers, user-defined-functions (UDFs) and merge procedures on a container and later execute them transactionally within the Azure Cosmos database engine. Writing application logic in JavaScript allows natural expression of control flow, variable scoping, assignment, and integration of exception handling primitives within the database transactions directly in the JavaScript language.
39+
Azure Cosmos DB allows you to write [stored procedures, pre/post triggers, user-defined-functions (UDFs)](stored-procedures-triggers-udfs.md) and merge procedures in JavaScript. Azure Cosmos DB natively supports JavaScript execution inside its database engine. You can register stored procedures, pre/post triggers, user-defined-functions (UDFs) and merge procedures on a container and later execute them transactionally within the Azure Cosmos database engine. Writing application logic in JavaScript allows natural expression of control flow, variable scoping, assignment, and integration of exception handling primitives within the database transactions directly in the JavaScript language.
4040

4141
The JavaScript-based stored procedures, triggers, UDFs, and merge procedures are wrapped within an ambient ACID transaction with snapshot isolation across all items within the logical partition. During the course of its execution, if the JavaScript program throws an exception, the entire transaction is aborted and rolled-back. The resulting programming model is simple yet powerful. JavaScript developers get a durable programming model while still using their familiar language constructs and library primitives.
4242

4343
The ability to execute JavaScript directly within the database engine provides performance and transactional execution of database operations against the items of a container. Furthermore, since Azure Cosmos database engine natively supports JSON and JavaScript, there is no impedance mismatch between the type systems of an application and the database.
4444

4545
## Optimistic concurrency control
4646

47-
Optimistic concurrency control allows you to prevent lost updates and deletes. Concurrent, conflicting operations are subjected to the regular pessimistic locking of the database engine hosted by the logical partition that owns the item. When two concurrent operations attempt to update the latest version of an item within a logical partition, one of them will win and the other will fail. However, if one or two operations attempting to concurrently update the same item had previously read an older value of the item, the database doesn’t know if the previously read value by either or both the conflicting operations was indeed the latest value of the item. Fortunately, this situation can be detected with the Optimistic Concurrency Control (OCC) before letting the two operations enter the transaction boundary inside the database engine. OCC protects your data from accidentally overwriting changes that were made by others. It also prevents others from accidentally overwriting your own changes.
47+
Optimistic concurrency control allows you to prevent lost updates and deletes. Concurrent, conflicting operations are subjected to the regular pessimistic locking of the database engine hosted by the logical partition that owns the item. When two concurrent operations attempt to update the latest version of an item within a logical partition, one of them will win and the other will fail. However, if one or two operations attempting to concurrently update the same item had previously read an older value of the item, the database doesn’t know if the previously read value by either or both the conflicting operations was indeed the latest value of the item. Fortunately, this situation can be detected with the **Optimistic Concurrency Control (OCC)** before letting the two operations enter the transaction boundary inside the database engine. OCC protects your data from accidentally overwriting changes that were made by others. It also prevents others from accidentally overwriting your own changes.
4848

4949
The concurrent updates of an item are subjected to the OCC by Azure Cosmos DB’s communication protocol layer. Azure Cosmos database ensures that the client-side version of the item that you are updating (or deleting) is the same as the version of the item in the Azure Cosmos container. This guarantees that your writes are protected from being overwritten accidentally by the writes of others and vice versa. In a multi-user environment, the optimistic concurrency control protects you from accidentally deleting or updating wrong version of an item. As such, items are protected against the infamous “lost update” or “lost delete” problems.
5050

51-
Every item stored in an Azure Cosmos container has a system defined `_etag` property. The value of the `_etag` is automatically generated and updated by the server every time the item is updated. `_etag` can be used with the client supplied if-match request header to allow the server to decide whether an item can be conditionally updated. The value of the if-match header matches the value of the `_etag` at the server, the item is then updated. If the value of the if-match request header is no longer current, the server rejects the operation with an "HTTP 412 Precondition failure" response message. The client then can refetch the item to acquire the current version of the item on the server or override the version of item in the server with its own `_etag` value for the item. In addition, `_etag` can be used with the if-none-match header to determine whether a refetch of a resource is needed.
51+
Every item stored in an Azure Cosmos container has a system defined `_etag` property. The value of the `_etag` is automatically generated and updated by the server every time the item is updated. `_etag` can be used with the client supplied `if-match` request header to allow the server to decide whether an item can be conditionally updated. The value of the `if-match` header matches the value of the `_etag` at the server, the item is then updated. If the value of the `if-match` request header is no longer current, the server rejects the operation with an "HTTP 412 Precondition failure" response message. The client then can re-fetch the item to acquire the current version of the item on the server or override the version of item in the server with its own `_etag` value for the item. In addition, `_etag` can be used with the `if-none-match` header to determine whether a refetch of a resource is needed.
5252

53-
The item’s _etag value changes every time the item is updated. For replace item operations, if-match must be explicitly expressed as a part of the request options. For an example, see the sample code in [GitHub](https://github.com/Azure/azure-documentdb-dotnet/blob/master/samples/code-samples/DocumentManagement/Program.cs#L398-L446). `_etag` values are implicitly checked for all written items touched by a stored procedure. If any conflict is detected, the stored procedure will roll back the transaction and throws an exception. With this method, either all or no writes within the stored procedure are applied atomically. This is a signal to the application to reapply updates and retry the original client request.
53+
The item’s `_etag` value changes every time the item is updated. For replace item operations, `if-match` must be explicitly expressed as a part of the request options. For an example, see the sample code in [GitHub](https://github.com/Azure/azure-documentdb-dotnet/blob/master/samples/code-samples/DocumentManagement/Program.cs#L398-L446). `_etag` values are implicitly checked for all written items touched by the stored procedure. If any conflict is detected, the stored procedure will roll back the transaction and throw an exception. With this method, either all or no writes within the stored procedure are applied atomically. This is a signal to the application to reapply updates and retry the original client request.
5454

5555
## Next steps
5656

@@ -59,3 +59,4 @@ Learn more about database transactions and optimistic concurrency control in the
5959
- [Working with Azure Cosmos databases, containers and items](databases-containers-items.md)
6060
- [Consistency levels](consistency-levels.md)
6161
- [Conflict types and resolution policies](conflict-resolution-policies.md)
62+
- [Stored procedures, triggers, and user-defined functions](stored-procedures-triggers-udfs.md)

articles/cosmos-db/how-to-manage-database-account.md

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
---
22
title: Learn how to manage database accounts in Azure Cosmos DB
33
description: Learn how to manage database accounts in Azure Cosmos DB
4-
author: christopheranderson
4+
author: rimman
55
ms.service: cosmos-db
66
ms.topic: sample
7-
ms.date: 10/17/2018
8-
ms.author: chrande
7+
ms.date: 04/08/2019
8+
ms.author: rimman
99
---
1010

1111
# Manage an Azure Cosmos account
1212

13-
This article describes how to manage your Azure Cosmos DB account. You learn how to set up multi-homing, add or remove a region, configure multiple write regions, and set up failover priorities.
13+
This article describes how to manage your Azure Cosmos account. You will learn how to set up multi-homing, add or remove a region, configure multiple write regions, and set up failover priorities.
1414

1515
## Create a database account
1616

@@ -94,30 +94,30 @@ client = cosmos_client.CosmosClient(self.account_endpoint, {'masterKey': self.ac
9494

9595
### <a id="add-remove-regions-via-portal"></a>Azure portal
9696

97-
1. Go to your Azure Cosmos DB account, and open the **Replicate data globally** menu.
97+
1. Go to your Azure Cosmos account, and open the **Replicate data globally** menu.
9898

99-
2. To add regions, select the hexagons on the map with the **+** label that correspond to your desired region. To add a region, select the **+ Add region** option and choose a region from the drop-down menu.
99+
2. To add regions, select the hexagons on the map with the **+** label that correspond to your desired region(s). Alternatively, to add a region, select the **+ Add region** option and choose a region from the drop-down menu.
100100

101101
3. To remove regions, clear one or more regions from the map by selecting the blue hexagons with check marks. Or select the "wastebasket" (🗑) icon next to the region on the right side.
102102

103103
4. To save your changes, select **OK**.
104104

105105
![Add or remove regions menu](./media/how-to-manage-database-account/add-region.png)
106106

107-
In single-region write mode, you can't remove the write region. You must fail over to a different region before you can delete that current write region.
107+
In a single-region write mode, you cannot remove the write region. You must fail over to a different region before you can delete the current write region.
108108

109-
In multi-region write mode, you can add or remove any region if you have at least one region.
109+
In a multi-region write mode, you can add or remove any region, if you have at least one region.
110110

111111
### <a id="add-remove-regions-via-cli"></a>Azure CLI
112112

113113
```bash
114-
# Given an account created with 1 region like so
114+
# Create an account with 1 region
115115
az cosmosdb create --name <Azure Cosmos account name> --resource-group <Resource Group name> --locations eastus=0
116116

117-
# Add a new region by adding another region to the list
117+
# Add a region
118118
az cosmosdb update --name <Azure Cosmos account name> --resource-group <Resource Group name> --locations eastus=0 westus=1
119119

120-
# Remove a region by removing a region from the list
120+
# Remove a region
121121
az cosmosdb update --name <Azure Cosmos account name> --resource-group <Resource Group name> --locations westus=0
122122
```
123123

@@ -137,7 +137,7 @@ az cosmosdb create --name <Azure Cosmos account name> --resource-group <Resource
137137

138138
### <a id="configure-multiple-write-regions-arm"></a>Resource Manager template
139139

140-
The following JSON code is an example of an Azure Resource Manager template. You can use it to deploy an Azure Cosmos DB account with a consistency policy of bounded staleness. The maximum staleness interval is set at 5 seconds. The maximum number of stale requests that's tolerated is set at 100. To learn about the Resource Manager template format and syntax, see [Resource Manager](../azure-resource-manager/resource-group-authoring-templates.md).
140+
The following JSON code is an example of an [Azure Resource Manager](https://docs.microsoft.com/azure/azure-resource-manager/resource-group-overview) template. You can use it to deploy an Azure Cosmos account with [bounded staleness consistency level](consistency-levels.md). The maximum staleness interval is set to 5 seconds. The maximum number of stale requests that is tolerated is set to 100. To learn about the Resource Manager template format and syntax, see [Resource Manager](../azure-resource-manager/resource-group-authoring-templates.md).
141141

142142
```json
143143
{
@@ -192,11 +192,11 @@ The following JSON code is an example of an Azure Resource Manager template. You
192192
```
193193

194194

195-
## <a id="manual-failover"></a>Enable manual failover for your Azure Cosmos DB account
195+
## <a id="manual-failover"></a>Enable manual failover for your Azure Cosmos account
196196

197197
### <a id="enable-manual-failover-via-portal"></a>Azure portal
198198

199-
1. Go to your Azure Cosmos DB account, and open the **Replicate data globally** menu.
199+
1. Go to your Azure Cosmos account, and open the **Replicate data globally** menu.
200200

201201
2. At the top of the menu, select **Manual Failover**.
202202

@@ -211,7 +211,7 @@ The following JSON code is an example of an Azure Resource Manager template. You
211211
### <a id="enable-manual-failover-via-cli"></a>Azure CLI
212212

213213
```bash
214-
# Given your account currently has regions with priority like so: eastus=0 westus=1
214+
# Given your account currently has regions with priority: eastus=0 westus=1
215215
# Change the priority order to trigger a failover of the write region
216216
az cosmosdb update --name <Azure Cosmos account name> --resource-group <Resource Group name> --locations westus=0 eastus=1
217217
```
@@ -247,11 +247,11 @@ az cosmosdb update --name <Azure Cosmos account name> --resource-group <Resource
247247
az cosmosdb update --name <Azure Cosmos account name> --resource-group <Resource Group name> --enable-automatic-failover false
248248
```
249249

250-
## Set failover priorities for your Azure Cosmos DB account
250+
## Set failover priorities for your Azure Cosmos account
251251

252252
### <a id="set-failover-priorities-via-portal"></a>Azure portal
253253

254-
1. From your Azure Cosmos DB account, open the **Replicate data globally** pane.
254+
1. From your Azure Cosmos account, open the **Replicate data globally** pane.
255255

256256
2. At the top of the pane, select **Automatic Failover**.
257257

@@ -265,7 +265,7 @@ az cosmosdb update --name <Azure Cosmos account name> --resource-group <Resource
265265

266266
![Automatic failover portal menu](./media/how-to-manage-database-account/automatic-failover.png)
267267

268-
You can't modify the write region on this menu. To change the write region manually, you must do a manual failover.
268+
You cannot modify the write region on this menu. To change the write region manually, you must do a manual failover.
269269

270270
### <a id="set-failover-priorities-via-cli"></a>Azure CLI
271271

@@ -276,8 +276,13 @@ az cosmosdb failover-priority-change --name <Azure Cosmos account name> --resour
276276

277277
## Next steps
278278

279-
Learn about how to manage consistency levels and data conflicts in Azure Cosmos DB. See the following articles:
279+
Read the following articles:
280280

281281
* [Manage consistency](how-to-manage-consistency.md)
282282
* [Manage conflicts between regions](how-to-manage-conflicts.md)
283+
* [Global distribution - under the hood](global-dist-under-the-hood.md)
284+
* [How to configure multi-master in your applications](how-to-multi-master.md)
285+
* [Configure clients for multihoming](how-to-manage-database-account.md#configure-clients-for-multi-homing)
286+
* [Add or remove regions from your Azure Cosmos DB account](how-to-manage-database-account.md#addremove-regions-from-your-database-account)
287+
* [Create a custom conflict resolution policy](how-to-manage-conflicts.md#create-a-custom-conflict-resolution-policy)
283288

0 commit comments

Comments
 (0)