Is there any way to retrieve the Instrumentation Key for an Application Insights (which resides in another resource group) in an ARM template ?
I have already created an appInsights using ARM template using the below code,
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"AppInsightsName": { "type": "string" },
"Location": { "type": "string", "defaultValue": "westeurope" }
},
"variables": {
//"apiVersion": "2018-02-01-preview",
"apiVersion": "2016-08-01",
"location": "[parameters('Location')]",
"ApplicationInsightsName": "[parameters('AppInsightsName')]"
},
"resources": [
{
"apiVersion": "2014-04-01",
"type": "Microsoft.Insights/components",
"name": "[variables('ApplicationInsightsName')]",
"location": "[variables('location')]",
"kind": "other",
"properties": {
"applicationId": "[variables('ApplicationInsightsName')]"
}
}
]
}
Now i am trying to link azure function app which runs in another resource group with this appInsights.
Below is the code i have tried,
{
"name": "APPINSIGHTS_INSTRUMENTATIONKEY",
"value": "[reference(resourceId(variables('AppInsightsResourceGroup'),'Microsoft.Insights/components', variables('ApplicationInsightsName'))).InstrumentationKey]"
}
But i am getting the below error,
Can someone give some idea how to crack this?