0

I have implemented an Azure durable function which can be triggered using a timer trigger. Also this same azure durable function needs to trigger manually as well. I was able to trigger the timer trigger manually as explained in the official documentation here.

My azure durable function looks like below.

[FunctionName("Weekly_HttpStart")]
    public static async Task HttpStart(
        [TimerTrigger("0 0 10 * * 3")] TimerInfo timerInfo,
        [DurableClient] IDurableOrchestrationClient starter,
        ILogger log)
    {             
        string instanceId = await starter.StartNewAsync("ProcessWeeklyBatch", null);
        log.LogInformation($"Started 'ProcessWeeklyBatch' orchestration with ID = '{instanceId}'.");            
    }

The issue I’m having now is I need to pass parameters to this timer triggering azure durable function when I triggering it manually.

According to the official documentation here, we can add body parameters to the request. (as below image), But I don’t see any way to read them inside the azure function.

enter image description here Has anybody come across how to read request payload inside timer triggering azure durable functions?

Ashan
  • 37
  • 1
  • 9
  • Have you tried adding a `HttpRequest` or `HttpRequestMessage` method parameter to `HttpStart()` and then deserialize that parameters `Body` or `Content` property? ` ... HttpRequestMessage req, ...` You'll want to guard about it being `null` in the event of being triggered by the timer though. – phil Apr 27 '22 at 10:20
  • Yes. I Have tried that. But it gives and exception s follows. - "Cannot bind parameter type HttpRequestMessage. Make sure the parameter Type is supported by the binding. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.)." – Ashan Apr 27 '22 at 20:57

1 Answers1

1

I'm not sure why would you pass something to a timer job but a workaround would be to create separate functions one HTTP-triggered and one Timer-triggered that just share underlaying logic like in this example.

Grekkq
  • 679
  • 6
  • 14