2

I'm trying to set the schedule field at function.json on my "httpTrigger" type function but it seems the timer functionality doesn't run. My goal is to have a function that could be even scheduled and manually started, if needed, without having to add another function just for scheduling.

{
  "disabled": false,
  "bindings": [
    {
      "authLevel": "function",
      "type": "httpTrigger",
      "direction": "in",
      "name": "req",
      "methods": [
        "get"
      ],
      "schedule": "0 0 * * * *"
    },
    {
      "type": "http",
      "direction": "out",
      "name": "res"
    }
  ]
}
Joy Wang
  • 39,905
  • 3
  • 30
  • 54
sogurb
  • 21
  • 4

2 Answers2

2

The only trigger type that you can schedule is timerTrigger.

So, if you need a piece of code to both run on schedule and be runnable from a nice URL, you will have to create two Functions with two trigger types.

If you don't need a nice HTTP URL, you can call a timer Functions manually, see this answer.

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

My goal is to have a function that could be even scheduled and manually started, if needed, without having to add another function just for scheduling.

As other members mentioned that HttpTrigger does not support schedule. For your requirement, you could create another function or manually invoke your function programmatically as Mikhail answered.

Per my understanding, you could leverage Azure Scheduler for a simpler approach to schedule your azure function.

GET https://{your-function-name}.azurewebsites.net/api/HttpTriggerCSharp1?code={your-function-key}

Or

GET https://{your-function-name}.azurewebsites.net/api/HttpTriggerCSharp1
Header x-functions-key:{your-function-key}

enter image description here

Bruce Chen
  • 18,207
  • 2
  • 21
  • 35