Azure Durable Functions: Calling an activity function that has no input parameters in a dotnet-isolated Durable Function

560 views Asked by At

I have an orchestration where the first step is an activity that consumes a feed. This activity does not require any input since the feed url is read from an environment variable.

The line of code of the orchestrator that invokes my activity looks like this

await context.CallActivityAsync("IngestFeedActivity");

My activity function looks like this:

[Function("IngestFeedActivity")]
public async Task IngestDisruptions([ActivityTrigger] TaskOrchestrationContext activityContext)
{

    // Activity code goes here
}

However I get this error:

Could not populate the value for 'activityContext' parameter. Consider updating the parameter with a default value

I added a default value of null to the activity context and now everything is working fine. However, this does not seem to be a very elegant solution to the problem and the TaskOrchestrationContext will always be null. Is there a better way of doing this?

1

There are 1 answers

0
RithwikBojja On BEST ANSWER

You can use below code to achieve this:

  public static async Task<List<string>> RunOrchestrator(
      [OrchestrationTrigger] TaskOrchestrationContext context)
  {
      ILogger logger = context.CreateReplaySafeLogger(nameof(Function1));
      logger.LogInformation("Saying hello.");
      var outputs = new List<string>();

      outputs.Add(await context.CallActivityAsync<string>("SayHello", null));
  
      return outputs;
  }

  [Function(nameof(SayHello))]
  public static string SayHello([ActivityTrigger] FunctionContext executionContext)
  {
      ILogger logger = executionContext.GetLogger("SayHello");
      logger.LogInformation("Saying hello to Rithwik");
       

Output:

enter image description here

Here i have used null while sending parameter and used FunctionContext executionContext