I just wanted to add to the answers already given, having just gone through this process with an ASP.NET MVC 5 project.
Uninstall Using NuGet
As the other answers say, the best way to remove Application Insights is through Nuget: Tools -> NuGet Package Manager -> Manage NuGet Packages for Solution.
I found it best to remove Microsoft.ApplicationInsights.Web and all its dependencies first, then Microsoft.ApplicationInsights.Javascript API.
This removed everything except:
- the ApplicationInsights.config file,
- a script snippet in _Layout.cshtml,
both of which I removed manually.
What Microsoft has to say
The Microsoft Azure documentation here: https://azure.microsoft.com/en-gb/documentation/articles/app-insights-troubleshoot-faq/, says:
What does Application Insights modify in my project?
The details depend on the type of project. For a web application:
Adds these files to your project:
- ApplicationInsights.config.
- ai.js
Installs these NuGet packages:
- Application Insights API - the core API
- Application Insights API for Web Applications - used to send telemetry from the server
- Application Insights API for JavaScript Applications - used to send telemetry from the client
The packages include these assemblies:
- Microsoft.ApplicationInsights
- Microsoft.ApplicationInsights.Platform
Inserts items into:
- Web.config
- packages.config (New projects only - if you add Application Insights to an existing project, you have to do this manually.) Inserts
snippets into the client and server code to initialize them with the
Application Insights resource ID. For example, in an MVC app, code is
inserted into the master page Views/Shared/_Layout.cshtml
Remove Manually
To remove Application Insights without NuGet, or if like me you don't trust it and want to know which files are removed, I followed these steps:
Remove application insights from the web.config, under system.webserver.modules, search for ApplicationInsightsWebTracking.
Remove all Microsoft.AI (Application Insights) prefixed references from project references.
Remove all Microsoft.ApplicationInsights packages from package.config.
Delete ApplicationInsights.config file.
Remove script from _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();
Remove ai.0.15.0-build58334.js & ai.0.15.0-build58334.min.js from Scripts directory.
Clean & Rebuild all.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…