我正在使用 .NET Core 6 中的 Azure 函式,但無法初始化Application Insights. 我嘗試安裝“Microsoft.ApplicationInsights.AspNetCore -Version 2.20.0”,但無法安裝并出現例外:

錯誤:

我試過這個命令:
Install-Package Microsoft.ApplicationInsights.AspNetCore -Version 2.20.0
uj5u.com熱心網友回復:
請檢查以下步驟是否有助于解決問題:
- 在 Visual Studio - Azure Functions 專案發布視窗 > 單擊
Restore Service dependencies and their settings圖示,然后安裝Microsoft.ApplicationInsights.AspNetCore.

- 在 VS > Tools > NuGet Packet Manager 中檢查這些選項。
另外,請檢查此SO Thread中給出的解決方法。
uj5u.com熱心網友回復:
Azure Functions 自動添加 Application Insights。不應將Microsoft.ApplicationInsights.AspNetCore包添加到 Azure Functions 專案,因為這樣做可能會出現不兼容問題。相反,如果您想撰寫自定義遙測,請使用位于此處Microsoft.Azure.WebJobs.Logging.ApplicationInsights的NuGet 包,如檔案和那些檔案所示:
Application Insights SDK 有一個特定于函式的版本,可用于將自定義遙測資料從函式發送到 Application Insights:Microsoft.Azure.WebJobs.Logging.ApplicationInsights
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/482564.html
