有没有办法更改部署了基于 linux 的容器的 Azure App Service 的日期

Is there a way to change date of Azure App Service which had a linux based container deployed

我需要更改我的 Azure 应用服务的日期/时间。这将帮助我及时穿越 API 到过去的日期。我使用了基于 linux 的 .Net Core API 图像,作为容器部署在 Azure App Service 中。在这个 API 中,我有一个当前 returns 系统日期和时间的方法。

我知道有一种方法可以设置时区。这可以是 dockerfile 的一部分。我正在尝试寻找一种类似的方法来更改日期。

有多种方法可以获取当前时间。您可以设置正确的时区然后获取系统当前时间。

您可以按照docker容器或Dockerfile here. Also, you can set the time zone in Azure Web App while you deploy your application in it. Azure Web App uses the environment variable WEBSITE_TIME_ZONE to set the time zone. For more details, see AppService: Setting a time-zone with a WEBSITE_TIME_ZONE App Setting (and many more).

中的方法设置时区

但我建议您只获取当前的 UTC 时间,然后在您的代码中使用正确的时区计算您的时间。这是我认为最好的打发时间的方法。

更新

按照我的想法,你需要的是在自定义镜像中配置SSH服务器,然后当你将镜像部署到Azure Web App时,你可以ssh到容器中进行调试。因此,您可以按照 SSH support for Azure App Service on Linux 中的步骤配置 SSH 服务器。

您还可以在从 Dockerfile 创建镜像时设置日期。这是一个 example.