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.
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.
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.
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.
Final Thoughts
Well that’s it folks. If you have any additional tips, feel free to share them in the comments below.
- Solved: Build Errors Not Showning in VS 2022 - 21st November 2024
- How To: Configure VSCode to Trust Self-Signed Certs - 16th August 2024
- Solved: GitHub Actions – HTTP 403: Resource not accessible by integration - 13th June 2024
16th July 2021 at 10:25 am
This really helped me today. Thanks a bunch Shane!!