3

I have a durable function that has inputs determined by a previous activity function For each activity function I have multiple awaitable tasks where each task is dependent on the previous task's output.

This is my structure as follows:

Orchestrator

[FunctionName("MessageController")]
public static async void Run(
    [OrchestrationTrigger] DurableOrchestrationContext context,
    TraceWriter log)
{
    if (!context.IsReplaying) log.Warning("MessageController started");

    var Input1= context.CallActivityAsync<ResultMessage>("Function_1", new InputMessage());
    var Input2= context.CallActivityAsync<ResultMessage>("Function_2", Input1);
    var Input3= context.CallActivityAsync<ResultMessage>("Function_2", Input2);

}

Activity Function

[FunctionName("Function_1")]
public static ResultMessage Run(
    [ActivityTrigger] DurableActivityContext activityContext,
    TraceWriter log)
{
    //Awaitable task
    var taskOutput= await DoSomething();

    //Awaitable task
    var token = await DoAnotherThing(taskOutput);
}

I have tested this and all works fine. But i ma wondering if this is good practice? Is it normal to have awaitable tasks within an activity function for a durable function?

Stanza
  • 485
  • 1
  • 4
  • 17

1 Answers1

5

Yes, that's totally fine. In fact, you can do pretty much anything you like in activity functions, as long as they complete in reasonable time (below 5 minutes on Consumption Plan). You can do async calls, switch threads, and do non-deterministic operations.

Constraints apply only to orchestrator functions.

Mikhail Shilkov
  • 34,128
  • 3
  • 68
  • 107