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

老子叫甜甜 提交于 2019-12-10 00:44:46

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!