简体   繁体   English

无法从 Nuget for Azure Function 应用安装 ApplicationInsights

[英]Unable to install ApplicationInsights from Nuget for Azure Function app

I am working on an Azure Function in .NET Core 6 but I'm unable to initialize Application Insights .我正在使用 .NET Core 6 中的 Azure 函数,但无法初始化Application Insights I tried to install `Microsoft.ApplicationInsights.AspNetCore -Version 2.20.0' but I'm unable to do so and get an exception:我尝试安装“Microsoft.ApplicationInsights.AspNetCore -Version 2.20.0”,但无法安装并出现异常:

在此处输入图像描述

Error:错误:

在此处输入图像描述

I tried this command:我试过这个命令:

Install-Package Microsoft.ApplicationInsights.AspNetCore -Version 2.20.0

Please check if the below steps would help to fix the issue:请检查以下步骤是否有助于解决问题:

  1. In Visual Studio - Azure Functions Project Publish Window > Click on Restore Service dependencies and their settings icon and then Install the Microsoft.ApplicationInsights.AspNetCore .在 Visual Studio - Azure Functions Project Publish Window > 单击Restore Service dependencies and their settings图标,然后安装Microsoft.ApplicationInsights.AspNetCore

在此处输入图像描述

  1. Check these options are checked in VS > Tools > NuGet Packet Manager.在 VS > Tools > NuGet Packet Manager 中检查这些选项

Also, please check this workaround given in this SO Thread .另外,请检查此SO Thread中给出的解决方法。

Application Insights is added by Azure Functions automatically. Azure Functions 自动添加 Application Insights。 You should not add the Microsoft.ApplicationInsights.AspNetCore package to an Azure Functions project as there might be incompatibility issues doing it that way.不应将Microsoft.ApplicationInsights.AspNetCore包添加到 Azure Functions 项目,因为这样做可能会出现不兼容问题。 Instead, if you want to write custom telemetry use the Microsoft.Azure.WebJobs.Logging.ApplicationInsights NuGet packages located here as shown by the docs and those docs :相反,如果您想编写自定义遥测,请使用位于此处Microsoft.Azure.WebJobs.Logging.ApplicationInsights NuGet 包,如文档那些文档所示:

There is a Functions-specific version of the Application Insights SDK that you can use to send custom telemetry data from your functions to Application Insights: Microsoft.Azure.WebJobs.Logging.ApplicationInsights Application Insights SDK 有一个特定于函数的版本,可用于将自定义遥测数据从函数发送到 Application Insights:Microsoft.Azure.WebJobs.Logging.ApplicationInsights

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM