使用 ARM 模板部署时如何获取 Application Insights 应用程序 ID?
How to get Application Insights Application ID when deploying using ARM template?
我有一个将 Application Insights 部署到 Azure 的 ARM 模板。
我需要从那里获取“应用程序 ID”
“正在监视您在发布流程中部署的服务的 Application Insights 资源的应用程序 ID。在 API 访问 blade”中找到它
将这样的输出添加到您的模板:
"outputs": {
"AppInsightAppId": {
"type": "String",
"value": "[reference(resourceId('Microsoft.Insights/components', variables('appInsightsName')), '2014-04-01').AppId]"
}
}
例如:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"appInsightsNamePrefix": {
"defaultValue": "",
"type": "String"
}
},
"variables": {
"appInsightsName": "[concat(parameters('appInsightsNamePrefix'), uniqueString(resourceGroup().id))]"
},
"resources": [
{
"type": "Microsoft.Insights/components",
"apiVersion": "2014-04-01",
"name": "[variables('appInsightsName')]",
"location": "[resourceGroup().location]",
"kind": "web",
"properties": {
"ApplicationId": "[variables('appInsightsName')]"
}
}
],
"outputs": {
"AppInsightAppId": {
"type": "String",
"value": "[reference(resourceId('Microsoft.Insights/components', variables('appInsightsName')), '2014-04-01').AppId]"
}
}
}
我有一个将 Application Insights 部署到 Azure 的 ARM 模板。
我需要从那里获取“应用程序 ID”
“正在监视您在发布流程中部署的服务的 Application Insights 资源的应用程序 ID。在 API 访问 blade”中找到它
将这样的输出添加到您的模板:
"outputs": {
"AppInsightAppId": {
"type": "String",
"value": "[reference(resourceId('Microsoft.Insights/components', variables('appInsightsName')), '2014-04-01').AppId]"
}
}
例如:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"appInsightsNamePrefix": {
"defaultValue": "",
"type": "String"
}
},
"variables": {
"appInsightsName": "[concat(parameters('appInsightsNamePrefix'), uniqueString(resourceGroup().id))]"
},
"resources": [
{
"type": "Microsoft.Insights/components",
"apiVersion": "2014-04-01",
"name": "[variables('appInsightsName')]",
"location": "[resourceGroup().location]",
"kind": "web",
"properties": {
"ApplicationId": "[variables('appInsightsName')]"
}
}
],
"outputs": {
"AppInsightAppId": {
"type": "String",
"value": "[reference(resourceId('Microsoft.Insights/components', variables('appInsightsName')), '2014-04-01').AppId]"
}
}
}