Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does the hard-coded ApplicationInsightsResourceId impact the gathering of AI data from resources in varying production levels?

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)?

edit

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?

like image 347
reidLinden Avatar asked Dec 22 '17 15:12

reidLinden


1 Answers

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.

like image 159
Yulia Safarova Avatar answered Sep 21 '22 18:09

Yulia Safarova