opticyclic
opticyclic

Reputation: 8106

How Do I Change The Azure App Service To Display A Different Timezone?

I have deployed my App Service to Canada Central and the webapp is using the F1 Free tier using Linux.

When I go to "Diagnose and solve problems" the time range is in UTC instead of EST.

How do I change the Timezone of the Azure web console to display EST so that I can more easily work out what went wrong and when?

Upvotes: 7

Views: 19583

Answers (3)

Robin De Schepper
Robin De Schepper

Reputation: 6335

My findings are that the Environment Variable WEBSITE_TIME_ZONE controls everything.

To set it go to your Web App, go to Settings > Environment Variables in the sidebar and add the following value for WEBSITE_TIME_ZONE:

  • For Windows images: open PowerShell and run tzutil /l, and pick the timezone you would like. Choose the full text options such as Fiji Standard Time.
  • For Linux images: Choose a value from the TZ identifier column of this table.

For Node.js environments you can run this snippet on your server to debug whether the settings took the desired effect:

    // Log the current timezone and date-time
    const currentTime = new Date();
    const currentTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;

    console.log('Current Time:', currentTime);
    console.log('Current Timezone:', currentTimeZone);

    // Check the environment variable set by Azure
    console.log('WEBSITE_TIME_ZONE:', process.env.WEBSITE_TIME_ZONE);

Upvotes: 0

Justin
Justin

Reputation: 213

For Linux, add an environment variable TZ=[TZ identifier](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) (not WEBSITE_TIME_ZONE). The settings will take effect after restarting your app.

Upvotes: 0

Bryan Lewis
Bryan Lewis

Reputation: 5977

App services default to UTC. You can change that by setting the "WEBSITE_TIME_ZONE" app setting to any valid Windows timezone (under "Configuration" tab / "Application Settings"). So in your case "Eastern Standard Time".

EDIT:

Actually, for Linux (which I rarely use), Microsoft docs (https://learn.microsoft.com/en-us/azure/app-service/faq-configuration-and-management) say you should use the "IANA TZ database timezone" value, such as "America/New_York"

This timezone setting is specific to this app service and is independent of the timezone set in your MS account, which is what is used generally in the portal.

Upvotes: 19

Related Questions