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

Bar*_*xto 85 asp.net visual-studio-2013 azure-application-insights

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

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

我怎样才能做到这一点?

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

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

Ant*_*ony 94

我只想添加已经给出的答案,刚刚使用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 - 核心API
  • 适用于Web应用程序的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.

  • 清洁和重建所有.


use*_*477 57

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

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

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

  • 这是没有用的答案,卸载"Application Insights Tools for Visual Studio"删除应用程序Insights,现在当我创建asp.net 4.6.1 MVC项目时它不起作用.它告诉我错误. (5认同)
  • OP询问如何从应用程序中删除AI,而不是从VS. (3认同)
  • @ user1393477 Visual Studio 2015怎么样?我看不到任何Application Insights Extension. (2认同)

小智 46

我更愿意这样做:

UnInstall-Package Microsoft.ApplicationInsights.Web -RemoveDependencies
Run Code Online (Sandbox Code Playgroud)

  • 这很棒.有没有办法在创建新项目时不首先添加ApplicationInsights? (2认同)

Dav*_*len 13

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


小智 6

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

  • 删除Microsoft.ApplicationInsights.AspNetCore nuget包
  • inject Microsoft.ApplicationInsights.AspNetCore.JavaScriptSnippet JavaScriptSnippet从_Layout.cshtml页面中删除
  • @Html.Raw(JavaScriptSnippet.FullScript)从_Layout.cshtml中删除
  • .UseApplicationInsights()从program.cs中删除