Skip to content

Commit fadebf4

Browse files
committed
Extend README Preview section with Delete resources by partition key
1 parent 681b5ae commit fadebf4

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

README.md

+36-2
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ To do this you will need to:
220220

221221
## Preview Features
222222

223-
The library also has a preview version that exposes some Cosmos preview features.
223+
The library also has a preview version that exposes some of CosmosDB preview features.
224224

225225
### Priority Based Execution
226226

@@ -247,7 +247,41 @@ az extension add --name cosmosdb-preview
247247
az cosmosdb update --resource-group $ResourceGroup --name $AccountName --enable-priority-based-execution true
248248
```
249249

250-
See [MS Learn](https://learn.microsoft.com/en-us/azure/cosmos-db/priority-based-execution) for further details.
250+
See [MS Learn](https://learn.microsoft.com/en-us/azure/cosmos-db/priority-based-execution) for more details.
251+
252+
### Delete resources by partition key
253+
254+
The preview version of the library extends the `ICosmosWriter` and `ILowPriorityCosmosWriter` with and additional method `DeletePartitionAsync` to delete all resources in a container based on a partition key. The deletion will be executed in a CosmosDB background service using a percentage of the RU's available. The effect are available immediatly as all resources in the partition will not be available through reads or queries.
255+
256+
In order to use this new method the "Delete All Items By Partition Key" feature needs to be enabled on the CosmosDB account.
257+
258+
This can be done through Azure CLI:
259+
260+
```bash
261+
# Delete All Items By Partition Key
262+
az cosmosdb update --resource-group $ResourceGroup --name $AccountName --capabilities DeleteAllItemsByPartitionKey
263+
```
264+
265+
or wih bicep:
266+
267+
```bicep
268+
resource cosmosAccount 'Microsoft.DocumentDB/databaseAccounts@2024-05-15' = {
269+
name: cosmosName
270+
properties: {
271+
databaseAccountOfferType: 'Standard'
272+
locations: location
273+
capabilities: [
274+
{
275+
name: 'DeleteAllItemsByPartitionKey'
276+
}
277+
]
278+
}
279+
}
280+
```
281+
282+
If the feature is not enabled when calling this method then a `CosmosException` will be thrown.
283+
284+
See [MS Learn](https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/how-to-delete-by-partition-key) for more details.
251285
252286
## Unit Testing
253287
The reader and writer interfaces can easily be mocked, but in some cases it is nice to have a fake version of a reader or writer to mimic the behavior of the read and write operations. For this purpose the `Atc.Cosmos.Testing` namespace contains the following fakes:

0 commit comments

Comments
 (0)