0

I have a doubt and before programming a solution I would like to know if it is right.

We use durable entities and we want to delete the records that are saved in the "history" table storage (and I don't want to delete the table vía Storage Explorer, this is the more hardcore choice). So, I'm afraid because with sometime later I will have a lot of empty records and perhaps the performance will not be the better.

We have tried several solutions but all are the same: A schedule signal of delete the entity

Entity.Current.DeleteState();

or even a powershell to delete all the entities.

function DeleteEntities 
{
    param (
        [string[]]$keys
    )
    foreach ($key in $keys) { 
        $signalEntityUri = "$baseUrl/runtime/webhooks/durabletask/entities/VoiceCallEntity/$key`?op=Delete&code=$code"
        Write-Output $signalEntityUri
        Invoke-WebRequest -Uri $signalEntityUri -Method POST
    }
}

function GetEntities 
{
    param (
        [string]$continuationToken
    )
    $baseUrl = "your_base_url_goes_here"
    $code = "your_code_goes_here"
    $listEntitiesUri = "$baseUrl/runtime/webhooks/durabletask/entities/VoiceCallEntity?code=$code"
    $response = Invoke-WebRequest -Uri $listEntitiesUri -Method GET -Headers @{'x-ms-continuation-token' = $continuationToken}
    $body = $response | ConvertFrom-Json
    $continuationToken = $response.Headers['x-ms-continuation-token']
    $keys = $body | select -ExpandProperty entityId | select -ExpandProperty key | where { $_ -ne '' }
    return @{ 'continuationToken' = $continuationToken; 'keys' = $keys }
}

$result = GetEntities('')
DeleteEntities($result.keys)
while($result.continuationToken -ne '') 
{
    $result = GetEntities($result.continuationToken)
    DeleteEntities($result.keys)
}

I have not found a way of delete the entire record vía API, so my last intent will be to create an azure function with a timer trigger and with the help of API table storage, delete definitely the records in this table with null state.

Am I missing anything more simple to achieve this result?

Thank you so much.

1 Answers1

1

The solution is here How to purge durable entity history with record deletion I was wrong and I didn't know that you can purge history of a durable entity and the only difference is that {instanceId} is in the format @entityName@entityKey.