question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sub-orchestration SetCustomStatus

See original GitHub issue

Is it possible to have a sub-orchestration set SetCustomStatus for the parent orchestration? My situation is as follows:

I have a long running Activity - this activity may actually eventually kick off an Azure Container Instance or something, but for now it runs inside an Activity function and can take a while. The long running code itself already has hooks for monitoring, but I can’t seem to get SetCustomStatus to work how I want.

The important code is as follows (some functions/code omitted for brevity):

        [FunctionName(RunOrchestratorFunctionName)]
        public static async Task<BatchProcessorResult> RunOrchestratorAsync(
            [OrchestrationTrigger] DurableOrchestrationContext context)
        {
            var configuration = context.GetInput<DurableImportConfiguration>();

            var importTask = context.CallSubOrchestratorAsync<BatchProcessorResult>(RunImportOrchestratorFunctionName, configuration);
            var monitorTask = context.CallSubOrchestratorAsync(RunMonitorOrchestratorFunctionName, context.InstanceId + ":Monitor", configuration);
            
            await Task.WhenAll(importTask, monitorTask);

            return await importTask;
        }

        [FunctionName(RunMonitorOrchestratorFunctionName)]
        public static async Task RunMonitorOrchestratorAsync(
            [OrchestrationTrigger] DurableOrchestrationContext context)
        {
            var batchImportStatusMessage = await context.WaitForExternalEvent<BatchImportStatusMessage>(BatchImportStatusChangedEventName);

            context.SetCustomStatus(batchImportStatusMessage);
            
            if (batchImportStatusMessage.MaxTicks != batchImportStatusMessage.CurrentTick)
            {
                context.ContinueAsNew(null);
            }
        }

        [FunctionName(BatchImportStatusFunctionName)]
        public static async Task BatchImportStatusChangedAsync(
            [QueueTrigger(BatchImportStatusRepository.QueueName)] BatchImportStatusMessage message,
            [OrchestrationClient] DurableOrchestrationClient client)
        {
            await client.RaiseEventAsync(message.InstanceId, BatchImportStatusChangedEventName, message);
        }

The long-running process updates a queue, which causes BatchImportStatusChangedAsync to raise an event, which is picked up in RunMonitorOrchestratorAsync, which sets the custom status. However, its setting the custom status on the sub-orchestrator context, not the main orchestrator context.

Is there a clean way to do what I’m doing within the confines of how this long-running process already works?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
ConnorMcMahoncommented, Feb 26, 2020

This seems like a scenario that could be solved with Durable Entities. Just spin up a new entity for each parent orchestration, and the sub orchestrations can update the entity state.

1reaction
muratboduroglucommented, Jan 3, 2019

In orchestrations with a large number of activity steps, we are required to segment the steps into sub-orchestrators for performance reasons. Let’s says an orchestrator with 2000 activities will be loading the history data for all those activities into memory during each replay, compared to segmenting them into suborchestrators for each 100 activities in which case the parent orchestrator will only replay the results of suborchestrators.

In this scenario, suborchesrators are really part of the parent orchesrator and I have a similar case of requiring access to parent’s custom status column, both to write and to read.

  1. It would be great to be able to set the custom status for an instance Id, (in this case parents).

  2. It would be great to be able to read the custom status while inside the orchestrator code. The DurableOrchestrationClient has the GetStatusAsync call but currently DurableOrchestrationContext only allows you to write the custom status. There is an internal function GetSerializedCustomStatus(), but it’s internal, not used by any other method, and it returns the serialized value instead of calling deserializer.

Obviously the context should not be able to update a different context’s data (parent’s) but I wonder if there is another elegant way to handle this other than using our own storage table for parent-child relationship.

Also this gets little bit more complicated when a suborchestrator also spawns another suborchestrator.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Track activity and sub-orchestrator progress in Azure ...
How to keep track of which parallel tasks have completed and make it visible in an orchestrator's custom status.
Read more >
SubOrchestrations In Azure Durable Functions - Practical ...
In this article, you will learn about SubOrchestrations in Azure Durable Functions. ... SetCustomStatus("Got source folder's documents.
Read more >
Is there a way to view the status of a Durable Function Sub ...
I'm trying to find a way to view the status of a sub orchestration using statusQueryGetUri. Currently I can only see the custom...
Read more >
Custom orchestration status in Durable Functions - Azure
Custom orchestration status lets you set a custom status value for your orchestrator function. This status is provided via the HTTP GetStatus ...
Read more >
New Features in Durable Functions
The orchestrator function can set this value by calling SetCustomStatus on the DurableOrchestrationContext . When you use the REST API to query ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found