Azure Function based on Web app sandbox. Web app need you to set the timezone in env settings first. The timetrigger attribute is the declaration part of the function. The environment variables will be checked here. If you do not set the environment variables about the time zone in advance, it will be processed according to the default UTC time.

The env variable comes from different place when run on local and run on azure.

For example, if you want to set EST time.

On local, you need to set it in local.settings.json. like this:

{
    "IsEncrypted": false,
    "Values": {
      "AzureWebJobsStorage": "UseDevelopmentStorage=true",
      "FUNCTIONS_WORKER_RUNTIME": "dotnet",
      "WEBSITE_TIME_ZONE": "Pacific Standard Time"
    }
}

On Azure, set the time zone in this place(dont forget to save the changes):

enter image description here
enter image description here

Sources:

https://blog.maximerouiller.com/post/getting-rid-of-time-zone-issues-within-azure-functions/

https://stackoverflow.com/questions/60442559/how-to-pass-timezone-to-azure-function-with-timer-trigger

Last modified: May 26, 2021

Author

Comments

Write a Reply or Comment