简体   繁体   中英

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 . I tried to install `Microsoft.ApplicationInsights.AspNetCore -Version 2.20.0' but I'm unable to do so and get an exception:

在此处输入图像描述

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 .

在此处输入图像描述

  1. Check these options are checked in VS > Tools > NuGet Packet Manager.

Also, please check this workaround given in this SO Thread .

Application Insights is added by Azure Functions automatically. You should not add the Microsoft.ApplicationInsights.AspNetCore package to an Azure Functions project as there might be incompatibility issues doing it that way. 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 :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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