我们是否可以在Azure资源组模板中检索Application Insights实例的连接字符串?
我可以通过下面的代码来检索仪表键,但是当我尝试使用same或Listkey获取connectionString时,它会给出错误。
"outputs": {
"MyAppInsightsInstrumentationKey": {
"value": "[reference(resourceId('Microsoft.Insights/components', variables('myAppInsightsInstanceName')), '2014-04-01').connectionString]",
"type": "string"
}
}错误:{" Error ":{"code":"InvalidTemplate",“message”:“部署模板验证失败:‘找不到模板变量'myAppInsightsInstanceName’。有关用法,请参阅https://aka.ms/arm-template/#variables。‘。”,“additionalInfo”:{“TemplateViolation”,"info":{"lineNumber":95,"linePosition":40,Info.
发布于 2021-08-24 06:20:35
正如@ZakiMa所评论的那样,您需要使用更新的API版本。
像这样的东西应该是有效的:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"variables": {
"MyAppInsightsInstanceName": "<My App Insights Instance Name>"
},
"outputs": {
"MyAppInsightsConnectionString": {
"value": "[reference(resourceId('Microsoft.Insights/components', variables('MyAppInsightsInstanceName')), '2020-02-02').ConnectionString]",
"type": "string"
}
},
"resources": []
}https://stackoverflow.com/questions/68894055
复制相似问题