Search code examples
azureazure-application-insightsazure-resource-manager

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


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


Solution

  • 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"
        }
    }