Trey Mack
Trey Mack

Reputation: 4695

How to determine Application Insights instance from connection string?

I have an Application Insights connection string, and want to find my way to the instance in Azure Portal so that I can view logs from my app running with that connection string. We have many instances of Application Insights across several Subscriptions, across a couple Accounts, which means I can't just click into each of them and check the connection string for a match.

The connection string looks like InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://southcentralus.in.applicationinsights.azure.com/

There's a URL, but that's generic for all instances in the region. Only thing that's unique is the InstrumentationKey.

I tried logging into the Portal and entering the InstrumentationKey into the search box, no hits on any Account.

Am I out of luck?

Upvotes: 5

Views: 1212

Answers (1)

silent
silent

Reputation: 16108

You can do it via a Resource Graph Query, for example in Azure CLI

az graph query -q "Resources | where type =~ 'Microsoft.Insights/components' | where properties['ConnectionString'] == 'InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://southcentralus.in.applicationinsights.azure.com/' | project id, resourceGroup, name"

//edit: As suggested in the comments by ZakiMa, a more robust way would be to check against the Instrumentation Key property:

az graph query -q "Resources | where type =~ 'Microsoft.Insights/components' | where 'InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://southcentralus.in.applicationinsights.azure.com/' contains properties['InstrumentationKey'] | project id, resourceGroup, name"

Upvotes: 5

Related Questions