Skip to content

Commit

Permalink
Extend README Preview section with Delete resources by partition key
Browse files Browse the repository at this point in the history
  • Loading branch information
TomMalow committed Oct 16, 2024
1 parent 8ceb09b commit 30e566a
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,37 @@ az cosmosdb update --resource-group $ResourceGroup --name $AccountName --enable

See [MS Learn](https://learn.microsoft.com/en-us/azure/cosmos-db/priority-based-execution) for further details.
### Delete resources by partition key

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.

In order to use this new method the "Delete All Items By Partition Key" feature needs to be enabled on the CosmosDB account.

This can be done through Azure CLI:

```bash
# Delete All Items By Partition Key
az cosmosdb update --resource-group $ResourceGroup --name $AccountName --capabilities DeleteAllItemsByPartitionKey
```

or wih bicep:
```bicep
resource cosmosAccount 'Microsoft.DocumentDB/databaseAccounts@2024-05-15' = {
name: cosmosName
properties: {
databaseAccountOfferType: 'Standard'
locations: location
capabilities: [
{
name: 'DeleteAllItemsByPartitionKey'
}
]
}
}
```

See [MS Learn](https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/how-to-delete-by-partition-key) for further details.
## Unit Testing
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:

Expand Down

0 comments on commit 30e566a

Please sign in to comment.