首页 文章

从Visual Studio 2013上的应用程序中删除Application Insight

提问于
浏览
80

在Visual Studio中,我将应用程序洞察添加到项目中,该项目创建ApplicationInsights.config并且不确定将哪些其他文件添加到项目中 .

事实是,右键单击并按Add Application Insight非常简单 . 现在我看起来没有成功的方法来删除该项目的应用程序洞察力 .

我怎样才能做到这一点?

在 生产环境 服务器上,使用DebugView,即使关闭服务器上的Application Monitor Services,我也会看到遥测日志 .

任何帮助表示赞赏,我想彻底摆脱对该应用程序的应用程序洞察力 .

6 回答

  • 13

    我首先从(工具 - > NuGet包管理器 - >管理NuGet包解决方案)中卸载所有Application Insight包解决了这个问题 .

    然后跑了

    卸载 - 包Microsoft.AspNet.TelemetryCorrelation -Version 1.0.0 -RemoveDependencies

    在Nuget控制台中 .

    那为我修好了 .

  • 5

    我更愿意这样做:

    UnInstall-Package Microsoft.ApplicationInsights.Web -RemoveDependencies
    
  • 0

    如果您使用NuGet软件包管理器来获得解决方案(工具 - > NuGet软件包管理器 - >管理NuGet软件包以获得解决方案),您可以搜索ApplicationInsights并卸载软件包,并且可以选择删除依赖项 . 可能有几个 . 这是清除所有依赖项的最简单方法,而不仅仅是一些依赖项 .

  • 91

    使用新的ASP.Net Core 1.1项目:

    • 删除Microsoft.ApplicationInsights.AspNetCore nuget包

    • 从_Layout.cshtml页面删除 inject Microsoft.ApplicationInsights.AspNetCore.JavaScriptSnippet JavaScriptSnippet

    • 从_Layout.cshtml中删除 @Html.Raw(JavaScriptSnippet.FullScript)

    • 从program.cs中删除 .UseApplicationInsights()

  • 55

    我只想添加已经给出的答案,刚刚使用ASP.NET MVC 5项目完成了这个过程 .

    使用NuGet卸载

    正如其他答案所说,删除Application Insights的最佳方法是通过Nuget:Tools - > NuGet Package Manager - > Manage NuGet Packages for Solution .

    我发现最好先删除 Microsoft.ApplicationInsights.Web 及其所有依赖项,然后再删除 Microsoft.ApplicationInsights.Javascript API .

    除去了以下内容:

    • ApplicationInsights.config文件,

    • _Layout.cshtml中的脚本片段,

    我手动删除了这两个 .

    微软有什么话要说

    这里的Microsoft Azure文档:https://azure.microsoft.com/en-gb/documentation/articles/app-insights-troubleshoot-faq/,说:

    Application Insights在我的项目中修改了什么?细节取决于项目类型 . 对于Web应用程序:将这些文件添加到项目中:ApplicationInsights.config . ai.js安装这些NuGet包:Application Insights API - 用于Web应用程序的核心API Application Insights API - 用于从服务器发送遥测用于JavaScript应用程序的Application Insights API - 用于从客户端发送遥测程序包包括以下程序集:Microsoft .ApplicationInsights Microsoft.ApplicationInsights.Platform将项插入到:Web.config packages.config(仅限新项目 - 如果将Application Insights添加到现有项目,则必须手动执行此操作 . )将片段插入客户端和服务器代码以进行初始化它们带有Application Insights资源ID . 例如,在MVC应用程序中,代码被插入到母版页面Views / Shared / _Layout.cshtml中

    手动删除

    要在没有NuGet的情况下删除Application Insights,或者如果像我一样你不相信它并想知道删除了哪些文件,我按照以下步骤操作:

    • 从web.config中删除应用程序洞察,在system.webserver.modules下,搜索ApplicationInsightsWebTracking .

    • 从项目引用中删除所有Microsoft.AI(Application Insights)带前缀的引用 .

    • 从package.config中删除所有Microsoft.ApplicationInsights包 .

    • 删除ApplicationInsights.config文件 .

    • 从_Layout.cshtml中删除脚本:

    var appInsights=window.appInsights||function(config){
        function r(config){t[config]=function(){var i=arguments;t.queue.push(function(){t[config].apply(t,i)})}}var t={config:config},u=document,e=window,o="script",s=u.createElement(o),i,f;for(s.src=config.url||"//az416426.vo.msecnd.net/scripts/a/ai.0.js",u.getElementsByTagName(o)[0].parentNode.appendChild(s),t.cookie=u.cookie,t.queue=[],i=["Event","Exception","Metric","PageView","Trace"];i.length;)r("track"+i.pop());return r("setAuthenticatedUserContext"),r("clearAuthenticatedUserContext"),config.disableExceptionTracking||(i="onerror",r("_"+i),f=e[i],e[i]=function(config,r,u,e,o){var s=f&&f(config,r,u,e,o);return s!==!0&&t["_"+i](config,r,u,e,o),s}),t
    }({
        instrumentationKey:"RemovedKey"
    });
    
    window.appInsights=appInsights;
    appInsights.trackPageView();
    
    • 从Scripts目录中删除ai.0.15.0-build58334.js&ai.0.15.0-build58334.min.js .

    • 清理并重建所有 .

  • 41

    除非我误解了这个问题,否则你只需删除一个扩展名和一个nuget包 .

    卸载 Application Insights Tools for Visual Studio 扩展名并删除 Application Telemetry SDK for Services nuget包 . 遥测包与Application Insights一起安装,但必须单独删除 .

    根据我的经验,如果您希望继续使用Application Insights的其他功能,则不需要遥测包 . 删除遥测包将停止所有遥测记录,但Application Insights将继续报告非遥测信息 .

相关问题