問(wèn)題描述
在Azure的 App Service / Function App 服務(wù)中,如果是在Windows系統(tǒng)中牡彻,可以通過(guò)添加Application Setting來(lái)轉(zhuǎn)換為中國(guó)時(shí)間(WEBSITE_TIME_ZONE : China Standard Time)。
但是如果系統(tǒng)是Linux的話出爹,以上設(shè)置無(wú)效庄吼。那如何才能在Linux 系統(tǒng)中設(shè)置時(shí)區(qū)為中國(guó)時(shí)區(qū)呢缎除?
解決辦法
Linux的App Service / Function App 的WEBSITE_TIME_ZONE 配置需要遵循TZ命名規(guī)范,中國(guó)區(qū)的時(shí)間對(duì)應(yīng)的值為:Asia/Shanghai.
如果使用的開(kāi)發(fā)語(yǔ)言為Java总寻“檎遥可以使用以下代碼驗(yàn)證確認(rèn)本地時(shí)間已經(jīng)設(shè)置為中國(guó)區(qū)。
String dt = LocalDateTime.now().toString();
context.getLogger().info("local time: " + dt);
當(dāng)Function App的執(zhí)行日志中顯示與北京時(shí)間相同即表示修改生效废菱。
參考資料
如何修改網(wǎng)站默認(rèn)時(shí)區(qū) :https://docs.azure.cn/en-us/articles/azure-operations-guide/app-service-web/aog-web-apps-howto-set-default-utc
How do I set the server time zone for my web app? https://docs.microsoft.com/en-us/azure/app-service/faq-configuration-and-management#how-do-i-set-the-server-time-zone-for-my-web-app-
Time zones : https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/default-time-zones?view=windows-11#time-zones
當(dāng)在復(fù)雜的環(huán)境中面臨問(wèn)題,格物之道需:濁而靜之徐清抖誉,安以動(dòng)之徐生殊轴。 云中,恰是如此!
分類(lèi): 【Azure 應(yīng)用服務(wù)】
標(biāo)簽: App Service, Azure Function, 系統(tǒng)時(shí)區(qū)修改, WEBSITE_TIME_ZONE : Asia/Shanghai, WEBSITE_TIME_ZONE : China Standard Time