TimeZone plays an important role for time crucial applications. In that case, you must have to set a proper timezone for the running operating system. One of our users asked about setting up the Timezone in Azure App Services.
In this tutorial, you will learn how to set the Timezone for an application running on Azure App Services. All the screenshots of this tutorial are made for Windows-based Azure App Service.
Identify the OS
You can easily set the Timezone to Windows app service using environment variables but the settings are different for an app service hosted in Linux or Windows.
To identify the OS type, follow:
- Log in to the Azure Portal
- Open the Azure app service
- Go to Console
- On the console Window you will either get a Windows prompt or a Linux shell.
Find The TimeZone
The Windows and Linux platforms followed some different string formats for different-2 Timezones. So first you need to find the correct string for the required timezone based on the Azure App Service OS type: To find the string follow:
- Windows based App Service – Open a PowerShell terminal on a Windows system and run the following command. It will list the Timezone.
Get-ChildItem -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones' | Select-Object PSChildName
- Linux based App Service – Visit https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
Change TimeZone on Azure App Service
Now, go through the following steps and configure the application setting with the correct name and value.
- Log in to the Azure Portal
- Open Azure App Service
- On the left-hand sidebar click on Configuration under Settings.
- Click on “+ New Application Setting”
- Set the environment variables based on OS type:
- For Windows App Service type Name and Value as:
Name=WEBSITE_TIME_ZONE
Value=Eastern Standard Time - For Linux App Service type Name and Value as:
Name=TZ
Value=America/New_York
- For Windows App Service type Name and Value as:
- Click Ok
- Click Save to confirm and save the change.
That’s it. You have changed the Timezone of the Windows Azure App Service successfully.
Verify TimeZone
Now, make sure that the timezone is applied correctly to the Azure app service. Open the app console and check the current date and time of the service. Match the current date and time with the actual time of the configured Timezone.
Conclusion
In this tutorial, You have learned to configure the Timezone of a running App Service on the Azure cloud platform. Now all the date and time-related activities will use the new Timezone as default for that Azure App Service.
2 Comments
Thanks so much
Many thanks, I was looking for this