Azure / azure-functions-durable-js

JavaScript library for using the Durable Functions bindings
https://www.npmjs.com/package/durable-functions
MIT License
132 stars 48 forks source link

Orchestrator Instance ID not accessible from Activity function #242

Open richardweaver opened 3 years ago

richardweaver commented 3 years ago

Describe the bug I have a process that runs on Durable Functions that consists of a couple of Orchestrators, with some Sub-Orchestrators and a series of Activity functions. Within the Activity functions I am writing to Table storage with any data exceptions that can be used as a report. I'd like to group these reports by specifying the parent Orchestrator's InstanceId as the PartitionKey on the table.

Investigative information

To Reproduce Steps to reproduce the behavior:

  1. Set a debugger break point inside a function with an activityTrigger
  2. Inspect the context parameter

While not required, providing your orchestrator's source code in anonymized form is often very helpful when investigating unexpected orchestrator behavior.

Expected behavior Data regarding the calling orderstrator's instanceId and parentInstanceId to be included in the context object, much as it is part of the bindingData for a sub-orchestrator.

Actual behavior Context includes the activity function's invocation ID but nothing related to the parent orchestrator,

Screenshots subOrchestrationContext activity

davidmrdavid commented 3 years ago

Hi @richardweaver,

Thank you for reaching out! This is an interesting use-case. I think this isn't a bug, just a currently unsupported use-case, but this would be good to have! I can investigate ways to make this happen during our next sprint, although that might take a few weeks since our current sprint just started.

In the meantime, I do want to provide you with a workaround. Technically, the orchestrator function could pass, as input to their activities, their instanceID. I believe the context object of the orchestrator function has an instanceID property as defined here. So, while we investigate adding this functionality, would this workaround satisfy your use-case?

Thanks! ⚡ ⚡

richardweaver commented 3 years ago

Thanks, yes I'd worked out that I can pass the orchestration ID as part of the input to activities. It's just a bit repetitive to do (I have about 20 functions that need to take this input) and I guess I'd just assumed that as an activity function is intrinsically a "child" of an orchestrator it would be there somewhere.

davidmrdavid commented 3 years ago

That's good to hear, I do think your intuition makes sense, and we should probably provide that metadata anyways. As I mentioned, I'll look to prioritizing this in the near future, but I'm glad to hear we at least have a workaround