Reputation: 784
I created an azure function that I need to run at 11 AM EST time. I understand the timer triggers use UTC however is there a way to pass in 11 AM to the run function for readability purposes?
For example here is my run method, is it possible to pass 11 AM where the X sits and specify a timezone?:
public static void Run([TimerTrigger("0 0 X * * *")]TimerInfo myTimer, TraceWriter log)
Upvotes: 8
Views: 12073
Reputation: 14108
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": "US Eastern Standard Time"
}
}
On Azure, set the time zone in this place(dont forget to save the changes):
From this doc, EST = GMT - 5. So in your case, if you are in default time zone, you can set the CRON as 0 0 6 * * *
. Since the hour cannot be negative. So it is valid for your situation, but not necessarily applicable to other situations. I suggest you use the method I recommended at the beginning.
Upvotes: 14