Pri*_*ngh 3 instrumentation azure azure-resource-manager azure-application-insights
我们可以在 Azure 资源组模板中检索 Application Insights 实例的连接字符串吗?
我可以通过下面的代码检索仪器密钥,但是当我尝试使用相同的或 Listkey 获取连接字符串时,它会给出错误。
"outputs": {
"MyAppInsightsInstrumentationKey": {
"value": "[reference(resourceId('Microsoft.Insights/components', variables('myAppInsightsInstanceName')), '2014-04-01').connectionString]",
"type": "string"
}
}
Run Code Online (Sandbox Code Playgroud)
错误:{“error”:{“code”:“InvalidTemplate”,“message”:“部署模板验证失败:'找不到模板变量'myAppInsightsInstanceName'。请参阅https://aka.ms/arm-template /#变量用于使用详细信息。'.","additionalInfo":[{"type":"TemplateViolation","info":{"lineNumber":95,"linePosition":40,"path":"properties.template .outputs.MyAppInsightsInstrumentationKey"}}]}}
正如@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": []
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3402 次 |
| 最近记录: |