How to get and set custom status in the Isolated Worker model?
Is your question related to a specific version? If so, please specify:
Functions 4.x on .NET 8.0, Isolated Worker model
What language does your question apply to? (e.g. C#, JavaScript, Java, All)
C#
Question
We're planning on migrating our .NET 6 in-process functions to .NET 8 with isolated workers. In our current code, we make extensive use of the custom status API to store things like progress percentage. The client can then poll for the latest status and update a progress bar.
For example, we have code like:
int percentComplete = (int)((double)(itemsDone) / itemsTotal * 100);
context.SetCustomStatus(new BackendProcessProgress
{
ProgressPercentage = percentComplete
});
and
DurableOrchestrationStatus status = await client.GetStatusAsync(instanceId);
Is there equivalent functionality in Isolated Worker? If not, what are the best practices/recommendations for doing this sort of thing?
@DeltekDavid Thanks for reporting please share all the repro steps. what you are trying
@bhagyshricompany this isn't a bug, I just want to know how to do the equivalent things in the new Isolated Process model (and whether it's even possible). Thanks
@DeltekDavid the .NET Isolated language worker extension, TaskOrchestrationContext contains a SetCustomStatus method equivalent.
With the DurableTaskClient you can get the Instance metadata and then Read the Custom Status:
var orchestrationMetadata = await client.GestInstanceAsync(instanceId);
var customStatus = orchestrationMetadata.ReadCustomStatusAs<BackendProcessProgress>();
Thank you @cjaliaga , this looks like just the thing. I couldn't find any mention of it in the docs, though. They still refer to the in-process version.
Closing as resolved.