我已將 Azure 函式配置為使用系結中的 datetime 函式將檔案輸出到具有當前日期的 Blob 容器,但它正在創建一個 UTC 日期檔案夾。
我什至將 WEBSITE_TIME_ZONE 更改為本地時間,參考此處的串列,但當我想要本地時間時,仍然在 blob 中創建 UTC 日期檔案夾。
我的系結代碼是:
{
"connection": "AzureWebJobsStorage",
"name": "Blobstr3",
"path": "outcontainer/{datetime:ddMMyyyy}/{rand-guid}.txt",
"direction": "out",
"type": "blob"
}
如果有人可以在這里幫助我,那就太好了?
uj5u.com熱心網友回復:
本地時間沒有系結運算式。
官方Azure Functions 系結運算式模式指出:
系結運算式 DateTime 決議為 DateTime.UtcNow。
要使用本地時間,您必須自己保存 blob 或在運行時使用系結(同樣來自Azure Functions 系結運算式模式):
運行時系結
在 C# 和其他 .NET 語言中,您可以使用命令式系結模式,而不是 function.json 和屬性中的宣告式系結。當系結引數需要在運行時而不是設計時計算時,命令式系結很有用。要了解更多資訊,請參閱C# 開發人員參考或C# 腳本開發人員參考。
下面是如何使用 Azure Functions 開發 C# 類別庫函式的示例
單屬性示例
以下示例代碼使用在運行時定義的 blob 路徑創建存盤 blob 輸出系結,然后將字串寫入 blob。
public static class IBinderExample { [FunctionName("CreateBlobUsingBinder")] public static void Run( [QueueTrigger("myqueue-items-source-4")] string myQueueItem, IBinder binder, ILogger log) { log.LogInformation($"CreateBlobUsingBinder function processed: {myQueueItem}"); using (var writer = binder.Bind<TextWriter>(new BlobAttribute( $"samples-output/{myQueueItem}", FileAccess.Write))) { writer.Write("Hello World!"); }; } }
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/436872.html
上一篇:如何修復字符日期并在R中添加零?
