gpt4 book ai didi

azure - 我们能否在 Azure 资源组模板中获取 Application Insights 的连接字符串?

转载 作者:行者123 更新时间:2023-12-05 01:57:47 24 4
gpt4 key购买 nike

我们可以在 Azure 资源组模板中检索 Application Insights 实例的连接字符串吗?

我可以通过下面的代码检索仪器 key ,但是当我尝试使用相同的或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 ":[{"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": []
}

关于azure - 我们能否在 Azure 资源组模板中获取 Application Insights 的连接字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68894055/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com