You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/cosmos-db/nosql/how-to-delete-by-partition-key.md
+34-9Lines changed: 34 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ This article explains how to use the Azure Cosmos DB SDKs to delete all items by
17
17
18
18
> [!IMPORTANT]
19
19
> Delete items by partition key value is in public preview.
20
-
> This feature is provided without a service level agreement, and it's not recommended for production workloads.
20
+
> This feature is provided without a service level agreement.
21
21
> For more information, see [Supplemental Terms of Use for Microsoft Azure Previews](https://azure.microsoft.com/support/legal/preview-supplemental-terms/).
22
22
23
23
## Feature overview
@@ -30,9 +30,34 @@ The delete by partition key operation is constrained to consume at most 10% of t
30
30
31
31
## Getting started
32
32
33
-
To use the feature, your Azure Cosmos DB account must be enrolled in the preview. To enroll, submit a request for the **DeleteAllItemsByPartitionKey** feature via the [**Preview Features** page](../../azure-resource-manager/management/preview-features.md) in your Azure Subscription overview page.
34
-
35
-
:::image type="content" source="media/how-to-delete-by-partition-key/preview-enrollment-delete-by-partition-key.png" alt-text="Screenshot that shows the enroll in Delete All Items By Partition Key in Preview Features blade.":::
33
+
Update your Azure Cosmos DB account to enable "Delete by partition key" feature using Azure CLI.
34
+
35
+
- Step 1: Set shell variables
36
+
```azurecli-interactive
37
+
$resourceGroupName = <azure_resource_group>
38
+
$accountName = <azure_cosmos_db_account_name>
39
+
$DeleteByPk = "DeleteAllItemsByPartitionKey"
40
+
```
41
+
- Step 2: List down existing capabilities of your account.
- Step 3: Add "Delete items by partition key" capability in the list of capabilities if it doesn't exist already.
49
+
>!Note
50
+
The list of capabilities must always specify all capabilities that you want to enable, inclusively. This includes capabilities that are already enabled for the account that you want to keep.
51
+
52
+
```azurecli-interactive
53
+
$capabilities += $DeleteByPk
54
+
```
55
+
56
+
- Step 4: Update Cosmos DB account to enable "Delete items by partition key" feature
57
+
```azurecli-interactive
58
+
az cosmosdb update --capabilities $capabilities \
59
+
-n $accountName -g $resourceGroupName
60
+
```
36
61
37
62
#### [.NET](#tab/dotnet-example)
38
63
@@ -87,22 +112,22 @@ Yes, once the delete by partition key operation starts, the documents to be dele
87
112
See [Known issues](#known-issues) for exceptions.
88
113
89
114
#### What happens if I issue a delete by partition key operation, and then immediately write a new document with the same partition key?
90
-
When the delete by partition key operation is issued, only the documents that exist in the container at that point in time with the partition key value will be deleted. Any new documents that come in won't be in scope for the deletion.
115
+
When the delete by partition key operation is issued, only the documents that exist in the container then with the partition key value will be deleted. Any new documents that come in won't be in scope for the deletion.
91
116
92
117
### How is the delete by partition key operation prioritized among other operations against the container?
93
-
By default, the delete by partition key value operation can consume up to a reserved fraction - 0.1, or 10% - of the overall RU/s on the resource. Any Request Units (RUs) in this bucket that are unused will be available for other non-background operations, such as reads, writes, and queries.
118
+
By default, the delete by partition key value operation can consume up to a reserved fraction - 0.1, or 10% - of the overall RU/s on the resource. Any Request Units (RUs) in this bucket that are unused will be available for other nonbackground operations, such as reads, writes, and queries.
94
119
95
-
For example, suppose you've provisioned 1000 RU/s on a container. There's an ongoing delete by partition key operation that consumes 100 RUs each second for 5 seconds. During each of these 5 seconds, there are 900 RUs available for non-background database operations. Once the delete operation is complete, all 1000 RU/s are now available again.
120
+
For example, suppose you've provisioned 1000 RU/s on a container. There's an ongoing delete by partition key operation that consumes 100 RUs each second for 5 seconds. During each of these 5 seconds, there are 900 RUs available for nonbackground database operations. Once the delete operation is complete, all 1000 RU/s are now available again.
96
121
97
122
### Known issues
98
-
For certain scenarios, the effects of a delete by partition key operation isn't guaranteed to be immediately reflected. The effect may be partially seen as the operation progresses.
123
+
In some scenarios, a delete by partition key operation may not immediately guarantee its effects, and partial visibility may occur during the operation.
99
124
100
125
- Aggregate queries that use the index - for example, COUNT queries - that are issued during an ongoing delete by partition key operation may contain the results of the documents to be deleted. This may occur until the delete operation is fully complete.
101
126
- Queries issued against the [analytical store](../analytical-store-introduction.md) during an ongoing delete by partition key operation may contain the results of the documents to be deleted. This may occur until the delete operation is fully complete.
102
127
-[Continuous backup (point in time restore)](../continuous-backup-restore-introduction.md) - a restore that is triggered during an ongoing delete by partition key operation may contain the results of the documents to be deleted in the restored collection. It isn't recommended to use this preview feature if you have a scenario that requires continuous backup.
103
128
104
129
### Limitations
105
-
-[Hierarchical partition keys](../hierarchical-partition-keys.md) deletion is not supported. This feature permits the deletion of items solely based on the last level of partition keys. For example, consider a scenario where a partition key consists of three hierarchical levels: country, state, and city. In this context, the delete by partition keys functionality can be employed effectively by specifying the complete partition key, encompassing all levels, namely country/state/city. Attempting to delete using intermediate partition keys, such as country/state or solely country, will result in an error.
130
+
-[Hierarchical partition keys](../hierarchical-partition-keys.md) deletion isn't supported. This feature permits the deletion of items solely based on the last level of partition keys. For example, consider a scenario where a partition key consists of three hierarchical levels: country, state, and city. In this context, the delete by partition keys functionality can be employed effectively by specifying the complete partition key, encompassing all levels, namely country/state/city. Attempting to delete using intermediate partition keys, such as country/state or solely country, will result in an error.
0 commit comments