How to configure an Azure custom handler with a timer trigger?

Issue

I’m trying to configure a new function in my Golang custom handler that uses a timer trigger. But I haven’t been able to find any documentation for it.

It’s unclear how the function is executed in main.go on the cron schedule configured in function.json.
The intent is to execute the function once an hour. This is the /functionname/function.json file I’m using:

{
  "bindings": [
    {
      "name": "timer",
      "type": "timerTrigger",
      "direction": "in",
      "schedule": "0 0 * * * *"
    }
  ]
}

Solution

There are a few differences between configuring a custom handler with a timer trigger and an HTTP trigger.

These are the differences that I noticed while figuring out how to get the timer trigger function up and running:

  1. The /local.settings.json file requires a field called "AzureWebJobsStorage" when configuring a timer trigger, it’s not required for the HTTP trigger. If not present it will cause the function app to fail when starting. This field stores the connection string for the storage account being used with the function app. (obviously add this file to .gitignore)
  2. When the function app attempts to call the timer triggered function, it expects it to be at the endpoint /functionName. This is different from the HTTP trigger which executes function handlers at /api/functionName.

Note: Timer trigger functions don’t appear to be able to set an outbound http binding. So even though the function sets a response, it isn’t used and does not get sent back to through the function host. It’s unclear why timer triggers ignore the outbound http binding or how to set a response without using one.

Answered By – Enviy

Answer Checked By – Katrina (GoLangFix Volunteer)

Leave a Reply

Your email address will not be published.