I'm creating an Azure function. While testing on my localhost, I'd like it to execute immediately. But in Prod, it can run every 5 minutes. I'd like to not have to rely on humans to remember to make this change.
public static void Run([TimerTrigger("0 */5 * * * *", RunOnStartup = true)])
I've been playing around with various ways to make the true here somehow variable, but have not found a solution. I was thinking something like:
public static void Run([TimerTrigger("0 */5 * * * *", RunOnStartup = #DEBUG ? true : false)])
But inline #DEBUG is not allowed.
For better readability, you can define a constant bool that denotes whether you're running a DEBUG build:
#if DEBUG
const bool IS_DEBUG = true;
#else
const bool IS_DEBUG = false;
#endif
Then use it in your attribute:
public static void Run([TimerTrigger("0 */5 * * * *", RunOnStartup = IS_DEBUG)])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With