是否可以更改已部署基于Linux的容器的Azure App Service的日期 [英] Is there a way to change date of Azure App Service which had a linux based container deployed

查看:104
本文介绍了是否可以更改已部署基于Linux的容器的Azure App Service的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要更改Azure应用服务的日期/时间.这将帮助我及时将API迁移到过去的日期.我使用了基于Linux的.Net Core API映像,该映像作为Azure App Service中的容器进行了部署.在此API中,我有一个当前返回系统日期和时间的方法.

I need to change the date / time of my Azure App Service. This will help me in time travelling the API to a past date. I have used linux based image of .Net Core API, deployed as container in Azure App Service. In this API I have a method which currently returns the system date and time.

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

I know there is a way to set the timezone. This can be part of the dockerfile. I am trying to look for a similar way to change the date.

推荐答案

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

There are multiple ways to get the current time. You can set the right time zone then get the system current time.

您可以按照以下方法在Docker容器或Dockerfile中设置时区此处.此外,在其中部署应用程序时,可以在Azure Web App中设置时区.Azure Web App使用环境变量 WEBSITE_TIME_ZONE 设置时区.有关更多详细信息,请参见

You can follow the ways to set the time zone in the docker container or 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时间,然后在代码中以正确的时区计算您的时间.这是我认为最好的打发时间的方法.

But I would suggest you just get the current UTC time and then calculate your time with the right time zone in your code. This is the best way to get the time as I think.

更新

我认为,您需要在自定义映像中配置SSH服务器,然后将映像部署到Azure Web App时,可以将其放入容器中进行调试.因此,您可以按照

As I think, what you need is to configure the SSH server in the custom image and then when you deploy the image to Azure Web App, you can ssh into the container to debug. So, you could follow the steps in SSH support for Azure App Service on Linux to configure the SSH server.

您还可以在从Dockerfile创建映像时设置日期.这是一个示例.

You can also set the date when you create the image from Dockerfile. Here is an example.

这篇关于是否可以更改已部署基于Linux的容器的Azure App Service的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆