0

I would like to add an Azure Function (Timer triggered) to my Azure Data Factory pipeine. When adding the function to the pipeline, there is a mandatory field to select the HTTP trigger and when I try to debug the function predictably fails as there is no HTTP interface/trigger. Is there a mechanism to add a Timer Triggered Function to the Data Factory pipeline?

I could implement a 2nd version of my function with an HTTP interface but I was hoping to avoid this.

Thx

user1843591
  • 1,074
  • 3
  • 17
  • 37
  • The answers here provide a couple of methods: https://stackoverflow.com/questions/51735928/manually-trigger-azure-function-time-triggered – Scott Mildenberger Sep 29 '22 at 15:14
  • Thanks Scott, the 2nd option on that thread is what I was hoping to avoid but ultimately what i did. I didn't need to implement a new version of my fucntion just aded a second interface/trigger – user1843591 Sep 30 '22 at 09:05

1 Answers1

0

I couldn't see a way to get the "timer trigger" triggered in the Data Factory pipeline so I just did what I was hoping to avoid.

  1. I added an extra HTTPTrigger and the rest of my function code remained the same. I could then reference that HTTP Function Trigger in my Data Factory pipeline

  2. I could then add a "recurring trigger" from the Data Factory/Data Studio/Manage page that triggered the new HTTP interface/trigger

HTTP TRIGGER

...
FunctionController controller=null;
...
@FunctionName("MyFnHTTPTrigger")
public HttpResponseMessage run(
        @HttpTrigger(name = "req", methods = {HttpMethod.GET, HttpMethod.POST}, authLevel = AuthorizationLevel.FUNCTION) HttpRequestMessage<Optional<String>> request,
        final ExecutionContext context) {

    controller = new FunctionController();

    try {
        controller.execute(context);
    } catch (Exception e) {
       
        context.getLogger().logp(Level.WARNING, "MyFnHTTPTrigger", "run", e.getMessage());
    }

TIMER TRIGGER

   ...
     FunctionController controller=null;
    ...
     @FunctionName("MyFnTimer")
        public void run(
            @TimerTrigger(name = "timerInfo", schedule = "0 */1 * * * *") String timerInfo,
            final ExecutionContext context
        ) {
            context.getLogger().info("Java Timer trigger function executed at: " + LocalDateTime.now());
            controller = new FunctionController();
    
            try {
                controller.execute(context);
            } catch (Exception e) {
                
                context.getLogger().logp(Level.WARNING, "MyFnTimer", "run", e.getMessage());
            }
user1843591
  • 1,074
  • 3
  • 17
  • 37