我想限制 azure 函式的執行時間,并在其上添加 TimeoutAttribute 作為以下代碼。
[FunctionName("Func2")]
[Timeout("00:00:02", TimeoutWhileDebugging = true)]
public static void Run([TimerTrigger("*/5 * * * * *")] TimerInfo myTimer, ILogger log)
{
log.LogInformation($"hi...");
int length = 10;
for (int i = 0; i < length; i )
{
log.LogInformation($"looping {i 1}...");
//System.Threading.Thread.Sleep(TimeSpan.FromSeconds(1));
System.Threading.Tasks.Task.Delay(3000).Wait();
}
}
我在本地運行了 Visual Studio 2019 中的代碼。我預計上面的代碼會在 2 秒內超時,但它運行了完整的 10 個回圈,沒有任何錯誤。
上面有問題嗎?
uj5u.com熱心網友回復:
這看起來像一個錯誤并且可以重現,我也可以在本地重現這個
Github 問題 #1900
- 超時屬性對函式不起作用嗎?
目前,這正在通過分類進行,并帶有 Bug 標簽。
注意:在此階段沒有已知的解決方法
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/338031.html
下一篇:在AKS群集上公開非HTTP流量
