durabletask-dotnet: DurableTaskClient.PurgeAllInstancesAsync: NotSupportedException and RpcException for .net 8 isolated
I am periodically purging instances and old history of my durable function runs. We noticed that this logic stopped working some time ago.
Runtime: .net 8 isolated azure function
Dependencies:
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.21.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.DurableTask" Version="1.1.2" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.2" />
My TimerTrigger Azure Function which is implemented next to my durable function looks likes this:
[Function(nameof(OrchestrationCleanupFunction))]
public async Task Run(
[TimerTrigger("0 */1 * * * *")] TimerInfo myTimer,
[DurableClient] DurableTaskClient orchestrationClient)
{
var createdTimeFrom = DateTime.UtcNow.Subtract(TimeSpan.FromDays(365 * 5));
var createdTimeTo = DateTime.UtcNow.Subtract(TimeSpan.FromDays(5));
var runtimeStatus = new List<OrchestrationRuntimeStatus>
{
OrchestrationRuntimeStatus.Completed
};
await orchestrationClient.PurgeAllInstancesAsync(new PurgeInstancesFilter(createdTimeFrom, createdTimeTo, runtimeStatus));
}
This code worked at some point and was initially developed as .Net 7 isolated function.
Now i am getting a System.NotSupportedException: Microsoft.Azure.Functions.Worker.FunctionsDurableTaskClient does not support purging of orchestration instances.
The implementation of DurableTaskClient.PurgeAllInstancesAsync is very confusing.
- DurableTaskClient is abstract and has multiple virtual overloads of PurgeAllInstancesAsync with a default implementation that throws a System.NotSupportedException.
- Each derived type does not override all “virtual” variations of PurgeAllInstancesAsync. (GrpcDurableTaskClient & FunctionsDurableTaskClient)
Example:
FunctionsDurableTaskClient implements: Task<PurgeResult> PurgeAllInstancesAsync(PurgeInstancesFilter filter, CancellationToken cancellation)
but not public virtual Task<PurgeResult> PurgeAllInstancesAsync( PurgeInstancesFilter filter, PurgeInstanceOptions? options = null, CancellationToken cancellation = default)
So calling:
client.PurgeAllInstancesAsync(new PurgeInstancesFilter(...), CancellationToken.None); and
client.PurgeAllInstancesAsync(new PurgeInstancesFilter(...));
makes an unexpected difference.
On top, i am getting a RpcException with {“Status(StatusCode="Unknown", Detail="Exception was thrown by handler.")”} locally and on Azure.
I would greatly appreciate some help getting this purge implementation up and running.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 5
- Comments: 20 (6 by maintainers)
I’ve encountered this issue as well. Rolling back
Microsoft.Azure.Functions.Worker.Extensions.DurableTaskto 1.1.0 fixes the issue, it appears to be a regression in v1.1.2 of that package.Thanks all, sorry we did not catch this. I’ll see if we can fix this in our upcoming releae.
Thanks for letting us know. @andystaples - please make sure this is tracked, thanks 😃
@davidmrdavid yes correct.
Here is my code sample:
Which results in:
@andystaples let’s take a closer look at the issues mentioned here as part of the e2e testing work that you’re doing.
Still getting the error in Net 8 (Isolated):
Dependencies
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" /> <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.22.0" /> <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.2" /> <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.DurableTask" Version="1.1.4" />we are getting this issue when executing:
` var filter = new PurgeInstancesFilter( DateTime.MinValue, createdToTimeResult, new List<OrchestrationRuntimeStatus> { OrchestrationRuntimeStatus.Completed, OrchestrationRuntimeStatus.Failed, OrchestrationRuntimeStatus.Terminated });
`
is there a fix for this?, thanks in advance
@gfgw I’m currently using
TerminateInstanceAsync(string instanceId, object? output, CancellationToken cancellation = default(CancellationToken))as a temporary fix, it is onlyTask TerminateInstanceAsync(string instanceId, TerminateInstanceOptions? options = null, CancellationToken cancellation = default(CancellationToken))that is throwing the unintended exception in the latest versionThis fix doesn’t appear to have made it into 1.1.3, any idea when we’ll get it? (unless
Microsoft.Azure.Functions.Worker.FunctionsDurableTaskClient does not support orchestration termination.is strictly speaking a different issue).Edit: just had a look at the
NotSupportedExceptions are still there for Purge tooEdit 2: Just seen 1.2.3 release notes
For me it was enough to downgrade package
Microsoft.Azure.Functions.Worker.Extensions.DurableTaskfrom1.1.2to1.1.1.