[英]Azure functions V3 logging exceptions in startup file
目前我們正在准備一組azure functions
來觸發blob storage
。 function 應用程序 V3 應該在啟動時進行某種檢查。 所以我在VS解決方案中添加了Startup.cs
文件。 我遇到的問題是有時在啟動文件中執行這些檢查時會發生異常。 但我從未在 azure 門戶(application insights/exceptions)
中找到這些異常。 我嘗試了很多方法來實現那里的日志記錄,但不幸的是,應用程序一直說Host is not running
而沒有任何日志記錄:
我不是在談論特定 function 的日志,我的意思是 function 應用程序在啟動時的日志。
這是它在startup.cs
中引發異常的代碼:
try
{
// async method CheckSomeBlobsFiles
CheckSomeBlobsFiles(connectionString,
blobContainerName, blobDirectoryName).GetAwaiter().GetResult();
}
catch (Exception e)
{
throw new Exception($"Error while checking database schemas: {e.Message}");
}
您可以嘗試使用HttpRequestException
,如下面的代碼所示?
catch (HttpRequestException ex)
{
throw new Exception($"Error while checking database schemas: {e.Message}");
}
經過一番研究,對於Startup.cs
的異常,您可以在 azure 門戶 ->診斷和解決問題刀片中找到它。
步驟如下:
1.Nav to azure portal -> your function app -> on the left side, click on Diagnose and solve problems -> then input function app down in the search box -> then click on the Function App Down or Reporting Errors . 截圖如下:
2.在Function App Down or Reporting Errors的新頁面中,展開Function Executions and Errors -> 然后在 ZC1C425268E68385D14AB5074C17A9 應用程序中展開 Detected host offline 。 然后你可以看到startup.cs中的異常記錄在那里(如果沒有,請在此頁面上指定適當的時間范圍)。 截圖如下:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.