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

不想你离开。 提交于 2021-01-28 20:10:05

问题


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.

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.


回答1:


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

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).

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.

Update

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.

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



来源:https://stackoverflow.com/questions/57524500/is-there-a-way-to-change-date-of-azure-app-service-which-had-a-linux-based-conta

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!