Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/EmptyTag/159.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Azure资源组模板中检索Application Insights实例的检测密钥?_Azure_Azure Application Insights_Azure Resource Manager - Fatal编程技术网

如何在Azure资源组模板中检索Application Insights实例的检测密钥?

如何在Azure资源组模板中检索Application Insights实例的检测密钥?,azure,azure-application-insights,azure-resource-manager,Azure,Azure Application Insights,Azure Resource Manager,是否有任何方法可以检索Azure资源组模板中Application Insights实例的检测密钥 我已尝试按照说明检索Azure资源上可用的列表*操作列表,但Microsoft.Insights/components不会出现在列表中的任何位置。这让我觉得在模板中检索检测密钥目前不可能检测密钥属于资源,您可以在Azure资源管理器模板中找到它。如果要查找检测密钥,需要将ResourceType定义为Microsoft.Insights/components。请尝试以下代码: $resourcev

是否有任何方法可以检索Azure资源组模板中Application Insights实例的检测密钥


我已尝试按照说明检索Azure资源上可用的列表*操作列表,但
Microsoft.Insights/components
不会出现在列表中的任何位置。这让我觉得在模板中检索检测密钥目前不可能

检测密钥属于资源,您可以在Azure资源管理器模板中找到它。如果要查找检测密钥,需要将ResourceType定义为Microsoft.Insights/components。请尝试以下代码:

$resourcevalue=Get-AzureRmResource-ResourceGroupName默认应用程序名称-***-ResourceType Microsoft.Insights/components-ResourceName**hdinsights-ApiVersion 2015-05-01

$resourcevalue.Properties.InstrumentationKey

经过一些挖掘和实验,我发现这是有效的:

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

只是为了以后我能找到这个答案。。。我以
@lily-user4045
的答案为基础,能够以这种方式转储所有属性:

$resourceDump=Get-AzureRmResource-ResourceGroupName myResourceGroupName***-ResourceType Microsoft.Insights/components-ResourceName myResourceName***

试试看(使用azure cli)


谢谢,但我希望在模板本身中检索密钥,以便它可以自动填充到门户中的应用程序设置中。您的代码段返回了一个空的
Properties
属性。对我来说,以下方法很有效:
(获取AzApplicationInsights)。InstrumentationKey
您还可以使用指向Insights实例名称的
listKeys()
函数:我对日志分析/OMS/OpsInsight工作区主和次共享密钥有类似的问题,虽然resourceProvider没有包含和列出该博客所指出的必需的*操作,但它仍然能够返回我的密钥。@Alex Marshall,这很有帮助。您是否有可能解决这个问题:这将混淆Azure资源管理器的一些新模板。问题是如何从ARM模板中而不是通过PowerShell脚本检索instrumentation密钥。太棒了!尤其是由于az monitor app insights api key show…没有公开它。
az resource show -g $RESOURCE_GROUP -n $APP_INSIGHTS --resource-type "microsoft.insights/components" --query properties.InstrumentationKey