How To: Set Azure App Service Time Zone

Background

We recently migrated a legacy .NET web service running on-premise to an Azure App Service. During testing we identified an issue with DateTime translations. Our application had a reference to DateTime.Now.

Previously, our app was running on-premise and therefore using Western Australia Standard Time (+8). However, following the migration to Azure, it was using UTC time by default, so we therefore needed to change the default time zone configuration.

In this post I’ll explain how you can update the time zone of your Azure App Service.

Azure App Service Logo

Check Baseline Configuration

First, let’s verify the current time zone configuration through the Kudu PowerShell command line.

Open your app service and navigate to Advanced Tools. Open the PowerShell console and execute command Get-Timezone to view the current server time zone configuration.

Azure Kudu Screenshot
Azure Kudu Screenshot
Azure Kudu Screenshot

Update Server Configuration

Now, head into the Azure Portal and navigate to your App Service. Click Application Settings and scroll down to the Application Settings section.

Create a new setting called WEBSITE_TIME_ZONE. Set the value to the name of the time zone you require. A full list of acceptable time zone values are available below

https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/default-time-zones.

Note: If you check the Slot Setting option, the updated timezone configuration will ‘stick’ to the staging slot when swapped, otherwise it will remain with the active slot.

Azure Portal Screenshot

Verification

Now it’s time to verify the change we have made …

Open the Kudu PowerShell console for your App Service and execute command Get-Timezone to view the current server time zone configuration.

It should have changed to the new time zone configuration.

Azure Kudu Screenshot

Final Thoughts

Well that’s it folks. If you have any additional tips, feel free to share them in the comments below.

Shane Bartholomeusz

G’day, I’m a technical solutions consultant based in Perth, Australia that specialises in the Microsoft technology stack, including .NET, Dynamics 365, Azure and general web development etc.

This blog is my place to share my thoughts, helpful solutions and just random nerdy stuff.
Shane Bartholomeusz

Latest posts by Shane Bartholomeusz (see all)

Leave a Reply