组合 2 个 ARM 模板(行动组和预算警报)
Combining 2 ARM templates ( Action Group and Budget Alert)
我在合并两个 ARM 模板时遇到了一些问题。我想创建一个操作组,然后创建一个 Azure 预算警报。我可以单独完成它们,但我想创建一个 Arm 模板来完成任务。
工作正常 - 这是创建操作组的代码(获取 select 资源组的选项或创建一个)
{
"type": "microsoft.insights/actionGroups",
"apiVersion": "2019-06-01",
"name": "OG",
"location": "Global",
"properties": {
"groupShortName": "OG",
"enabled": true,
"emailReceivers": [
{
"name": "[concat('Test','OG')]",
"emailAddress": "someemailID@xxx.com",
"useCommonAlertSchema": true
}
]
}
工作正常 - 这是创建预算警报的代码(获取 select 订阅的选项)
"resources": [
{
"type": "Microsoft.Consumption/budgets",
"apiVersion": "2019-10-01",
"name": "[parameters('budgetName')]",
"properties": {
"timePeriod": {
"startDate": "[parameters('startDate')]",
"endDate": "[parameters('endDate')]"
},
"timeGrain": "[parameters('timeGrain')]",
"amount": "[parameters('amount')]",
"category": "Cost",
"notifications": {
"NotificationForExceededBudget1": {
"enabled": true,
"operator": "GreaterThan",
"threshold": "[parameters('firstThreshold')]",
"contactEmails": "[parameters('contactEmails')]",
"contactGroups": "[parameters('contactGroups')]"
}
}
}
}
]
这是我想出的组合代码 - 没有获得 select 资源组
的选项
问题 - 在部署组合模板时,我没有获得我需要的select“资源组”选项让“资源组”创建行动组但不用于预算警报。
如何合并这两个模板?
无法正常工作
"resources": [
{
"type": "microsoft.insights/actionGroups",
"apiVersion": "2019-06-01",
"name": "OG",
"location": "Global",
"properties": {
"groupShortName": "OG",
"enabled": true,
"emailReceivers": [
{
"name": "[concat('Test','OG')]",
"emailAddress": "someemailID@xxx.com",
"useCommonAlertSchema": true
}
]
}
},
{
"type": "Microsoft.Consumption/budgets",
"apiVersion": "2019-10-01",
"name": "[parameters('budgetName')]",
"dependsOn": [
"[resourceId('microsoft.insights/actionGroups','OG')]"
],
"properties": {
"timePeriod": {
"startDate": "[parameters('startDate')]",
"endDate": "[parameters('endDate')]"
},
"timeGrain": "[parameters('timeGrain')]",
"amount": "[parameters('amount')]",
"category": "Cost",
"notifications": {
"NotificationForExceededBudget1": {
"enabled": true,
"operator": "GreaterThan",
"threshold": "[parameters('firstThreshold')]",
"contactEmails": "[parameters('contactEmails')]",
"contactGroups": "[resourceId('microsoft.insights/actionGroups','OG')]"
}
}
}
}
]
请将预算嵌套在嵌套模板中并将其定位到订阅级别(或管理组级别)
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
your action group resource
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2020-06-01",
"name": "nestedDeployment",
"location": "centralus",
"subscriptionId": "0000000-0000-0000-0000-000000000000",
"properties": {
"mode": "Incremental",
"template": {
your budget resource goes here
}
}
}
],
"outputs": {}
}
我在合并两个 ARM 模板时遇到了一些问题。我想创建一个操作组,然后创建一个 Azure 预算警报。我可以单独完成它们,但我想创建一个 Arm 模板来完成任务。
工作正常 - 这是创建操作组的代码(获取 select 资源组的选项或创建一个)
{
"type": "microsoft.insights/actionGroups",
"apiVersion": "2019-06-01",
"name": "OG",
"location": "Global",
"properties": {
"groupShortName": "OG",
"enabled": true,
"emailReceivers": [
{
"name": "[concat('Test','OG')]",
"emailAddress": "someemailID@xxx.com",
"useCommonAlertSchema": true
}
]
}
工作正常 - 这是创建预算警报的代码(获取 select 订阅的选项)
"resources": [
{
"type": "Microsoft.Consumption/budgets",
"apiVersion": "2019-10-01",
"name": "[parameters('budgetName')]",
"properties": {
"timePeriod": {
"startDate": "[parameters('startDate')]",
"endDate": "[parameters('endDate')]"
},
"timeGrain": "[parameters('timeGrain')]",
"amount": "[parameters('amount')]",
"category": "Cost",
"notifications": {
"NotificationForExceededBudget1": {
"enabled": true,
"operator": "GreaterThan",
"threshold": "[parameters('firstThreshold')]",
"contactEmails": "[parameters('contactEmails')]",
"contactGroups": "[parameters('contactGroups')]"
}
}
}
}
]
这是我想出的组合代码 - 没有获得 select 资源组
的选项问题 - 在部署组合模板时,我没有获得我需要的select“资源组”选项让“资源组”创建行动组但不用于预算警报。 如何合并这两个模板?
无法正常工作
"resources": [
{
"type": "microsoft.insights/actionGroups",
"apiVersion": "2019-06-01",
"name": "OG",
"location": "Global",
"properties": {
"groupShortName": "OG",
"enabled": true,
"emailReceivers": [
{
"name": "[concat('Test','OG')]",
"emailAddress": "someemailID@xxx.com",
"useCommonAlertSchema": true
}
]
}
},
{
"type": "Microsoft.Consumption/budgets",
"apiVersion": "2019-10-01",
"name": "[parameters('budgetName')]",
"dependsOn": [
"[resourceId('microsoft.insights/actionGroups','OG')]"
],
"properties": {
"timePeriod": {
"startDate": "[parameters('startDate')]",
"endDate": "[parameters('endDate')]"
},
"timeGrain": "[parameters('timeGrain')]",
"amount": "[parameters('amount')]",
"category": "Cost",
"notifications": {
"NotificationForExceededBudget1": {
"enabled": true,
"operator": "GreaterThan",
"threshold": "[parameters('firstThreshold')]",
"contactEmails": "[parameters('contactEmails')]",
"contactGroups": "[resourceId('microsoft.insights/actionGroups','OG')]"
}
}
}
}
]
请将预算嵌套在嵌套模板中并将其定位到订阅级别(或管理组级别)
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
your action group resource
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2020-06-01",
"name": "nestedDeployment",
"location": "centralus",
"subscriptionId": "0000000-0000-0000-0000-000000000000",
"properties": {
"mode": "Incremental",
"template": {
your budget resource goes here
}
}
}
],
"outputs": {}
}