I have an application to which I am trying to add in Azure Application Insights telemetry. I've been reading how I can modify the InstrumentationKey at runtime, to select a different telemetry target. But, none of the documents I've been reading explain how to also select a different ApplicationInsightsResourceId, which seems to contain something like a path, with my subscriptionID, the resource group, and the the insights component. This value is stored in the csproj file when I first add AI to the project.
But, in my application, we have 4 main environments... CI, Test, Stage, Prod. Each of those environments in in a different resource group, and, in fact, "Prod" is even in a different azure subscription altogether.
So my question is, how can I make sure my telemetry data is sent to the correct environment, base on start-up values read from configuration (App Settings, etc)? Is the instrumentationKey sufficient to locate other AI targets, despite them being in different resource groups (and hopefully subscriptions)?
So, there's nothing like doing something to learn, right? I just tried out a few different instrumentationKeys from insights resources in my various resource groups and subscriptions, and, evidently, "it just works"; the only change required to send telemetry data anywhere seems to be the iKey, regardless of subscription or other organizational structures. Perhaps we can amend the question to clarify any points in which my conclusions are incorrect or misleading, and perhaps a link to a resource which explains this?
Yes, you're absolutely right - InstrumentationKey is the only required thing for sending data to the right Application Insights resource. ApplicationInsightsResourceId is only used for navigating to the portal from Visual Studio.
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