When I use the "Add Application Insights Telemetry..." menu option available from right-clicking an ASP.NET application in the Solution Explorer in Visual Studio to point an application to an existing Application Insights resource, the resulting file changes include the addition of two items to the .csproj
file:
<ApplicationInsightsResourceId>/subscriptions/$guid/resourcegroups/$rgname>/providers/microsoft.insights/components/$name</ApplicationInsightsResourceId>
<ApplicationInsightsAnnotationResourceId>/subscriptions/$guid/resourcegroups/$rgname/providers/microsoft.insights/components/$name</ApplicationInsightsAnnotationResourceId>
I have elided some information - $guid
is the Azure subscription GUID and $rgname
and $name
are the names given to the Application Insights resource group and resource respectively.
What is the difference between each element? They seem to have the same information.
If I want to send telemetry to different Application Insights resources in difference environments, the documentation tells me I need to set the instrumentation key for each environment in code - which is fine - but what about these settings? Are they used for anything other than driving the context-sensitive menu options in Visual Studio? Do I need to worry about them in other environments?
The Application Insights SDK and instrumentation is designed to be extremely lightweight and have minimal impact on the performance of your application.
As per the FAQ: use one instance: Should I use single or multiple Application Insights resources? Use a single resource for all the components or roles in a single business system. Use separate resources for development, test, and release versions, and for independent applications.
You need the instrumentation keys of all the resources to which your app will send data.
Application Insights is a feature of Azure Monitor that provides extensible application performance management (APM) and monitoring for live web apps. Developers and DevOps professionals can use Application Insights to: Automatically detect performance anomalies. Help diagnose issues by using powerful analytics tools.
These are purely for use inside Visual Studio tools. They are in the csproj so all users who get your project (out of source control) or whatever, all have the values. (if it was stored in the registry or .suo or other non-source places, it wouldn't "travel" with the project)
ApplicationInsightsResourceId
is the resource id of the project which is used to display information in the configuration window about what resource VS thinks you are sending data to. This is also used by default to show data in codelens/etc. You can override this in the configure window to pick a different resource (like if you have data sent to a debug/staging resource when developing, but always want codelens/other tools to show data from prod always) Changing the resource inside the configuration window will set this property (and will update the ikey in your applicationinsights.config file)
ApplicationInsightsAnnotationResourceId
is the resource that VS will try to submit publish release annotations to if you publish your web app from inside Visual Studio. you can change this resource (or turn of this behavior entirely) from inside the configuration window as well. If you don't publish from inside VS, this setting doesn't do anything.
These settings do not affect where the data actually goes at runtime, If you are setting your instrumentation key in code your data will still go there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With