1

I am working on azure functions. I have two azure function one is http Api and the second one is timer trigger function hosted in same function app:

Function.json of timer trigger function :

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

I want to below functionality :

  1. Change schedule : From function A at runtime I want to change the schedule time of timer function.

Ex: In above function.json schedule is "0 */1 * * * *" to "0 */5 * * * *" 2. Enable/Disable : I want to enable/ disable timer function from Function A. 3. Input : provide input also to the request.

Is there any way I can achieve above points programmatically ?

Thank You!

  • I understand that you need to enable/disable the timer trigger schedule and change the schedule value from the HTTP Trigger Function? - Is that your ask? –  Jul 25 '22 at 10:23
  • Yes, Correct that is the ask. – Yadvendra Kumar Jul 25 '22 at 12:33
  • you could have a look at this documentation: https://learn.microsoft.com/en-us/azure/azure-functions/disable-function?tabs=portal – Thomas Jul 26 '22 at 03:29

1 Answers1

1

Change schedule : From function A at runtime I want to change the schedule time of timer function.

  • Firstly, Schedule in functions is used only in Timer Trigger Function you can't use it in HTTP function so you can't change the schedule through HTTP Trigger Function you can refer this SO for further details.

  • Rather you can use Azure logic apps for changing the schedule value using logic apps for complete information here is the document for Azure Scheduler.

  • To enable or disable Azure function programmatically you need to change the format in app setting and add below code.

    AzureWebJobs.<FUNCTION_NAME>.Disabled : True

  • You need to add the above code in Function.JSON file for further details you can refer this document which includes complete information regarding enable/disable azure function.

  • Here is the output after testing in my local environment.

enter image description here

SaiSakethGuduru
  • 2,218
  • 1
  • 5
  • 15
  • Thanks, Point 2 ( using Logic apps with Service Bus ) I was able to complete flow. For Point 1 : I am changing/ want to change the schedule of timer trigger function from a HTTP function. In the question I have mentioned the same. For Point 3 & 4 : I am still not clear that after doing these changes how I change the Environment variable . – Yadvendra Kumar Jul 29 '22 at 07:41