I’ve just been sat here, scratching my big bald head wondering why there is such a delay in my timer triggered Azure Functions completing. They were being executed a good hour later than expected!

It was only having spoken to my colleague Dave that it became apparent my issues were all down to the recent time zone change from Greenwich Mean Time (GMT) to British Summer Time (BST) - I’m based in the United Kingdom.

Face Palm!

Contents

The Problem

The default time zone for Azure Functions is UTC.

BST is 1 hour ahead of UTC. So there’s my issue!

The Solution

The solution turned out to be a fairly simple one.

First thing to do: take note on whether your Azure Function App (or Azure Web App) is running on a Windows on Linux based host.

If you can’t remember this from when you deployed it, you can see the Operating System listed on the Overview blade in the Azure portal.

To solve this problem, you need to go to the Functions Application Settings and added a new setting called ‘WEBSITE_TIME_ZONE’.

If your Function App host is Windows based, get your time zone from here.

If your Function App host Linux based, get your time zone from here.

There is currently no documentation (as of 4th June 2020) on setting the time zone for Linux based apps. I’ve raised a support request with the correct product group to get this sorted. Thanks to Finbar Ryan @ Microsoft for helping me solve this one.

So if I was running a Windows based app, and I live in the UK, I would create an app setting as:

Name: WEBSITE_TIME_ZONE
Value: GMT Standard Time

For Linux, this would be:

Name: WEBSITE_TIME_ZONE
Value: GB

This setting will adjust your app time zone and will include automatic correction for daylight saving.


WARNING: Any changes to applications settings will restart your application!

Testing

I found that a really quick way to test this was to open up my Function App in the Azure portal, and go to the ‘Advanced Tools’ blade. Clicking ‘Go’ will launch a new (Kudu) browser tab.

If your host is Windows based, you can head over to the ‘Debug console’ menu dropdown and select PowerShell. If your host is Linux based, you can head over to the ‘Bash’ menu option. You will then be presented with a console.

Entering the command date in Bash or Get-Date -format r in PowerShell will tell you what the App thinks it’s current date, time and time zone is. Here is mine (which is Linux based) before and after changing the application setting:

Problem solved!

Local Functions Host

If, like me you use the Function Apps local functions host for dev/test, you can change the time zone by adding the "WEBSITE_TIME_ZONE" setting to your local.settings.json file.

Example:

{
  "IsEncrypted": false,
  "Values": {
    "FUNCTIONS_WORKER_RUNTIME": "python",
    "AzureWebJobsStorage": "{AzureWebJobsStorage}",
    "WEBSITE_TIME_ZONE": "GB"
  }
}

If your local functions host is running you will need to restart it in order to apply the changes.

Note - your local function host should be running your systems time zone anyway, but the above is handy for testing other time zones if you need to!

TL;DR;

To solve this problem, you need to go to the Functions Application Settings and added a new setting called ‘WEBSITE_TIME_ZONE’.

If your Function App host is Windows based, get your time zone from here.

If your Function App host Linux based, get your time zone from here.

Examples for UK based Function Apps:

Name: WEBSITE_TIME_ZONE
Value: GMT Standard Time

For Linux, this would be:

Name: WEBSITE_TIME_ZONE
Value: GB

WARNING: Any changes to applications settings will restart your application!