设置 Azure Webjob 时区

问题描述 投票:0回答:1

我将 C# 控制台应用程序作业设置为 Azure WebJob。这尊重触发器和运行时的 UTC 时区。如图所示,我已将服务器应用程序配置更新为“东部标准时间”。

Webjob 仍然不支持 EST 时区。我可以看到 Web App 服务器和作为主机的 Webjob 服务之间存在断开连接。我想问一下是否有非代码更改方法来解决此问题,以便DateTime.Now = EST 而不是UTC。我可以在代码中修复它,但尝试找到一种以非编码方式修复它的方法。

注意: 操作系统是 Windows

c# azure datetime console-application azure-webjobs
1个回答
0
投票

默认情况下,

Azure App service
显示
UTC

感谢@Thomas 的评论。

我们可以看到

Debug Console
=>
Powershell
timezone
的时区。

enter image description here

  • Visual Studio
    中,我创建了一个示例
    Console App
    .

我的

Program.cs

Console.WriteLine("Hello, World!");
DateTime dt = DateTime.Now;
Console.WriteLine("The current time is: " + dt.ToString());
  • 构建并运行应用程序。
  • 在 Azure 门户中创建一个新的
    Azure App Service
    并创建一个新的 Web 作业。
  • 将文件从本地文件夹压缩到一个新文件夹
    ****\bin\Debug\net6.0
    .

enter image description here

  • 在门户中创建网络作业时上传新压缩的文件夹。

enter image description here

  • 现在,检查正在运行的作业日志。 enter image description here

enter image description here

我已将

WEBSITE_TIME_ZONE
值设置为
Eastern Standard Time
与您显示的相同。

enter image description here

  • 现在在 KUDU 控制台中检查更新的时区,
    Debug Console
    =>
    Powershell
    timezone
    .

enter image description here

  • 现在在运行的作业日志中检查相同的内容。 enter image description here
© www.soinside.com 2019 - 2024. All rights reserved.