1
votes

We enabled application insights via azure portal some time ago. Everything worked great and we want to log bit extra custom information. So we will have to include appInsight SDK and create TelemetryClient and RequestTelemetry in our code now.

Ideally, we would like to enable the exact same setting as we enabled in azure portal (e.g. enable profiling, recommended collection level, sql command and disable Snapshot debugger).

However, when I look at the appinsight config file, I realised that this file is way more complicated than what azure portal offers.

Is there a way to convert what we enabled on azure portal to the config file? Or if I delete this config file (just add the custom field in our c# RequestTelemetry instance), will appInsights use settings from azure portal automatically?

2
Just ensure that you are using the same instrumentation key and it should just work.Stephen McDowell
@StephenMcDowell do I need to delete the config file?daxu
Not exactly sure which config file you're talking about. If a special config file got created when you enabled it then I would just leave it. For the application itself when add AppInsights you'll need to go thru the steps to configure it. Typically that involves putting the instrumentation key in a config file.Stephen McDowell

2 Answers

2
votes

If you are using Asp.Net Application, installing SDK by default will generate the full ApplicationInsights.Config file for you, which would do same level of monitoring as Recommended level. https://docs.microsoft.com/en-us/azure/azure-monitor/app/asp-net

And follow this to get full SQL Text: https://docs.microsoft.com/en-us/azure/azure-monitor/app/asp-net-dependencies#advanced-sql-tracking-to-get-full-sql-query

If you are using Asp.Net Core Application, installing SDK by default will automatically configure everything in code (there is no ai.config in asp.net core apps). https://docs.microsoft.com/en-us/azure/azure-monitor/app/asp-net-core You dont need to do anything additional to get full SQL Text in Asp.Net Core apps.

SnapShotCollector is not enabled by default, so you dont need to do anything to disable it.

Profiler: https://docs.microsoft.com/en-us/azure/azure-monitor/app/profiler#enable-profiler-manually-or-with-azure-resource-manager

0
votes

For application insights, maybe you know that there is 2 ways to apply Application Insights to your .NET web applications(For details, please refer to here).

Build time: add application insights sdk

Run time: via azure portal without adding sdk to your project.

And the screenshot below shows the difference of them(you can ignore the Note section about build-time and run-time in this article, this gives users confusion and an issue is tracking that):

enter image description here

And for your issues, I suggest you'd better use both of them: adding sdk and also enable/disable profiler / snapshot debugger / sql command via azure portal.

I did some tracing about sql command before, without enable from azure portal, you cannot get a details sql command info from application insights with just adding sdk. Not make some changes via config file.

And there're also described in docs like below, take profiler for example:

In the profiler doc, it says: Follow these steps even if you've included the App Insights SDK in your application at build time.

enter image description here

And also, it would be more difficult to change appinsight config file to meet your need, there is even no official doc about these for apply profiler / sql command via config file.

I just found a blog about how to configure snapshot debugger via appinsight config file, you can take a look and try it at your side.