0

Following the documentation for Durable Azure Function - Fan out/fan in

enter image description here

In the diagram above, say we have a static variable like

private static string _staticVar = "DEFAULT";

Some of the F2 instances need to set and then use _staticVar and some need to use its default value. But when we run this setup with await Task.WhenAll(parallelTasks);, the value being set by one instance of F2 is reflected at the next.

Is there a way to say we want each F2 to be in a new context/request?

dushyantp
  • 4,398
  • 7
  • 37
  • 59

1 Answers1

3

No, there isn't. You shouldn't be using static variables anyway to communicate with parts of the process.

You most likely need to pass this value as an input to F2 or record them to an external store from which instances of F2 then read them.

juunas
  • 54,244
  • 13
  • 113
  • 149
  • Sorry pressed enter too quickly! Hi @junnas thanks for your response. The main point I am after is how to create a brand new request every time, but sounds like there isn't a way to do so. Not actually using a static var :-) that is an example. Will wait and see in case someone else has got an idea else might have to do a rest call to function endpoint instead of durable function. – dushyantp Jun 15 '21 at 08:41
  • So if F2 is an activity, it'll be executed through a queue message in the work item queue. The work item queue is listened to by some number of Functions instances. You can't affect which instance runs the activity, it's whichever gets the message from the queue. – juunas Jun 15 '21 at 09:27