Skip to content

Commit 139dc04

Browse files
Merge pull request #261942 from richagaur/richagaur/pk-delete-enrol-update
added self-serve capability to enable feature
2 parents 2cddbc3 + 1f439cf commit 139dc04

File tree

1 file changed

+34
-9
lines changed

1 file changed

+34
-9
lines changed

articles/cosmos-db/nosql/how-to-delete-by-partition-key.md

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ This article explains how to use the Azure Cosmos DB SDKs to delete all items by
1717

1818
> [!IMPORTANT]
1919
> 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.
2121
> For more information, see [Supplemental Terms of Use for Microsoft Azure Previews](https://azure.microsoft.com/support/legal/preview-supplemental-terms/).
2222
2323
## Feature overview
@@ -30,9 +30,34 @@ The delete by partition key operation is constrained to consume at most 10% of t
3030

3131
## Getting started
3232

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.
42+
```azurecli-interactive
43+
$cosmosdb = az cosmosdb show \
44+
--resource-group $resourceGroupName \
45+
--name $accountName
46+
$capabilities = ($cosmosdb | ConvertFrom-Json).capabilities
47+
```
48+
- 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+
```
3661
3762
#### [.NET](#tab/dotnet-example)
3863
@@ -87,22 +112,22 @@ Yes, once the delete by partition key operation starts, the documents to be dele
87112
See [Known issues](#known-issues) for exceptions.
88113

89114
#### 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.
91116

92117
### 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.
94119

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.
96121

97122
### 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.
99124

100125
- 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.
101126
- 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.
102127
- [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.
103128

104129
### 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.
106131

107132
## How to give feedback or report an issue/bug
108133
* Email [email protected] with questions or feedback.

0 commit comments

Comments
 (0)