Azure Functions time zone issue
    • Dark
    • PDF

    Azure Functions time zone issue

    • Dark
    • PDF

    Article Summary

    You might often face time zone issues upon using Timer Trigger in your Azure Functions. For instance, if you want to do a clean-up task of your database once a day (consider 9 AM) for maintanence. As this is a periodic task, you would use the out-of-the-box capability which Azure Functions provides (Timer Trigger). Get to know about scheduling in Azure Functions here.

    //Timer is set to trigger the function at 9Am
    public static void Run([TimerTrigger("0 0 9 * * *")]TimerInfo myTimer, ILogger log)
        // todo: clean up the database

    But, on running the function, you might end up with time zone issues as the default time zone of Azure Functions is UTC. This might differ from your time zone (say IST). The function which must be executed at 9am IST would get delayed to 2.30pm IST. Because, IST is 5.30 hours ahead of UTC. This might severally affect the users if they use the application during maintenance.


    We have couple of workarounds here;

    Solution 1

    To have your timer trigger fire at 5pm, use the following CRON expression that accounts for UTC time zone:

    "schedule": "0 30 14 * * *"

    Solution 2

    The most efficient and recommended way to play around this issue is;

    1. Select Configuration option in your Function App

    2. Add new “application settings”

    3. Fill the fields with the following value
      • Value: India Standard Time

    4. Click Ok
      App settings.png

    Now, you can use this "schedule": "0 0 9 * * *" CRON Expression to trigger the Function at the desired time.

    With this method, there is no necessity to make any manual conversions for time. When you use WEBSITE_TIME_ZONE, the time will get adjust with regards to the configured local time zone. Also note that the scope of this solution lies within the particular Function App.


    Was this article helpful?