Azure Function timer configure through app settings

Palanivelu Samudi picture Palanivelu Samudi · Aug 7, 2017 · Viewed 11.3k times · Source

I am working on Azure functions timer Job , i need to get the cron expression from the appsettings. Please let me know, how can i get the value from the appsettings in the Azure functions. I want to run my azure function starting from 9:00 AM to 12:00 PM for every 30 minutes\

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

Answer

Karthikeyan VK picture Karthikeyan VK · Aug 7, 2017

Set your schedule as "schedule": "%EmailScheduleTriggerTime%" and then in the appsetting.json or local.settings.json you can set EmailScheduleTriggerTime value as "0 30 9-12 * * *"

{
  "IsEncrypted": false,
  "Values": {
    "EmailScheduleTriggerTime": "0 30 9-12 * * *", //Run every  30 minutes from 9:00 to 12:00

  },
  "ConnectionStrings": {
    "DefaultConnection": ""
  }
}

[FunctionName("TimerfunctionApp")] 
public static void Run([TimerTrigger("%EmailScheduleTriggerTime%")] TimerInfo TInfo, TraceWriter log)