How can I retrieve the instrumentation key for an Application Insights instance in an Azure Resource Group Template?

Alex Marshall picture Alex Marshall · Apr 16, 2016 · Viewed 11.4k times · Source

Is there any way to retrieve the Instrumentation Key for an Application Insights instance in an Azure Resource Group template ?

I've tried the instructions here to retrieve the list of list* operations available on Azure resources, but Microsoft.Insights/components doesn't appear in the list anywhere. It's making me think that retrieving an Instrumentation Key in the template isn't currently possible

Answer

Alex Marshall picture Alex Marshall · Apr 19, 2016

After some digging and experimenting, this is what I found works:

"outputs": {
    "MyAppInsightsInstrumentationKey": {
        "value": "[reference(resourceId('Microsoft.Insights/components', variables('myAppInsightsInstanceName')), '2014-04-01').InstrumentationKey]",
        "type": "string"
    }
}