问题
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
回答1:
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"
}
}
回答2:
Instrumentation Key belongs to resource, you can find it in Azure Resource manager template. If you want to find Instrumentation Key, you need to define ResourceType to Microsoft.Insights/components. Try the below code:
$resourcevalue=Get-AzureRmResource -ResourceGroupName Default-ApplicationInsights-*** -ResourceType Microsoft.Insights/components -ResourceName **hdinsights -ApiVersion 2015-05-01
$resourcevalue.Properties.InstrumentationKey
回答3:
Just so that later I can find this answer ... I built upon @lily-user4045
's answer and was able to dump all the properties this way:
$resourceDump=Get-AzureRmResource -ResourceGroupName myResourceGroupName*** -ResourceType Microsoft.Insights/components -ResourceName myResourceName***
来源:https://stackoverflow.com/questions/36659193/how-can-i-retrieve-the-instrumentation-key-for-an-application-insights-instance