Search code examples
c#azuredatetimeconsole-applicationazure-webjobs

Setting Azure Webjob Time Zones


I have a C# console App job set as a Azure WebJob. This honors UTC time zone for the trigger and runtime. I have updated the Server Application Config to "Eastern Standard Time" as in the picture.

enter image description here

The Webjob still does not honor the EST time zone. I can see there is a disconnect between the Web App server and the Webjob service as hosts. I wanted to ask if there is a non-code change way to fix this, so that DateTime.Now = EST and Not UTC. I can fix it in the code but try to find a way to fix this in a non-coding way.

NOTE: OS is Windows


Solution

  • By default, the Azure App service displays UTC.

    Thanks @Thomas for the Comment.

    We can see the timezone in Debug Console =>Powershell with timezone.

    enter image description here

    • In Visual Studio, I have created a sample Console App.

    My Program.cs:

    Console.WriteLine("Hello, World!");
    DateTime dt = DateTime.Now;
    Console.WriteLine("The current time is: " + dt.ToString());
    
    • Build and run the Application.
    • Create a new Azure App Service in Azure Portal and create a new Web Job.
    • Zip the files into a new folder from your local folder ****\bin\Debug\net6.0.

    enter image description here

    • Upload the newly zipped folder while creating web job in portal.

    enter image description here

    • Now, Check the running job Logs. enter image description here

    enter image description here

    I have set the WEBSITE_TIME_ZONE values to Eastern Standard Time same as you have shown.

    enter image description here

    • Now check the updated time zone in KUDU Console, Debug Console =>Powershell with timezone.

    enter image description here

    • Now check the same in the running job Logs. enter image description here