6
votes

It's possible to install Application Insights via the extensions section in Azure App Services, but it's also possible to just install the packages via NuGet and define the APPINSIGHTS_INSTRUMENTATIONKEY application setting. You can also do both.

What is the difference?

Edit:

I have found what the differences are between installing the extension or the NuGet packages:

You can configure monitoring by instrumenting the app in either of two ways:

Run-time - You can select a performance monitoring extension when your web app is already live. It isn't necessary to rebuild or re-install your app. You get a standard set of packages that monitor response times, success rates, exceptions, dependencies, and so on.

Build time - You can install a package in your app in development. This option is more versatile. In addition to the same standard packages, you can write code to customize the telemetry or to send your own telemetry. You can log specific activities or record events according to the semantics of your app domain.

Source: https://docs.microsoft.com/en-us/azure/application-insights/app-insights-azure-web-apps#run-time-or-build-time

But what if you do both? Will there be anything beneficial about it?

2

2 Answers

6
votes

But what if you do both? Will there be anything beneficial about it?

  • The extension detects that your app has already brought Application Insights with it and won't do anything, except dropping a profiler, which helps collect full SQL Statement in Dependencies. Without the profiler full SQL Statement won't be collected but everything else should just work fine. (If you are using 2.3.0 or earlier of SDK or if you application is targeting old .NET Framework like 4.0, then profiler does better correlation of dependencies as well.

In short, Starting with 2.4.0 of SDK, the only advantage of installing extension on top on nuget installation is to get full SQL Statements in Dependency Telemetry.

1
votes

But what if you do both? Will there be anything beneficial about it?

As you know we could install the packages via NuGet to use Application Insights .For this way, we could add custom telemetry data in my code,and monitor the telemetry data in application insights tools in Visual Studio. This will be very convenient. You could also refer to this article to add custom telemetry data.

Code in MVC Porject:

 public ActionResult Index()
        {
            Trace.TraceInformation("my trace info Home/Index");
            var telemetry = new Microsoft.ApplicationInsights.TelemetryClient();
            RequestTelemetry requestTelemetry = new RequestTelemetry();
            telemetry.TrackTrace("Home/Index Main");
            telemetry.TrackPageView("Home/Index");
            return View();
        }

The telemetry data in Application insight tool:

enter image description here

The application insights in App Service,you can only see limited data and trends in past 24 hours. This is very convenient for you to view the main telemetry data in the app service directly. But if you want to know more details, that is not a good choose.

enter image description here

The most comprehensive monitor data and services are in application insight service. You could click 'View more in application insights' in App Service monitor extension to go. Or you could go to application insight service directly.

enter image description here

Time Range in application insight service(include custom time range).

enter image description here