问题
I have 2 applications (asp.net) with Application Insights integrated. In the portal I have created 2 tags: App1 = 1, App2 = 1 (one tag for each app). But what is the next step? How do I add the tags into the ApplicationInsights.config, so that each app sends its tag?
回答1:
That's not where tags are for. They are there to organize your Azure resources, see https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-using-tags.
Resource Manager enables you to logically organize resources by applying tags. The tags consist of key/value pairs that identify resources with properties that you define. To mark resources as belonging to the same category, apply the same tag to those resources.
If you want to make a distinction between the two apps you need to use different instrumentation keys, meaning two distinct Application Insights environments.
From https://docs.microsoft.com/en-us/azure/application-insights/app-insights-create-new-resource:
The instrumentation key identifies the resource that you created. You'll need it to give to the SDK.
As an alternative you could add custom properties to your SDK calls to make a distinction if that is what you need as outlined here: https://blogs.msdn.microsoft.com/visualstudioalm/2015/01/07/application-insights-support-for-multiple-environments-stamps-and-app-versions/ and Adding custom properties for each request in Application Insights metrics
So it depends on the web application differences. If they are unrelated I would suggest using different instrumentation keys. If one app is a staging/test app and the other is the production app then you can consider using custom properties so you can compare the gathered data based on the custom property.
来源:https://stackoverflow.com/questions/41417656/application-insights-and-tags