|
| 1 | +{ |
| 2 | + "$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#", |
| 3 | + "contentVersion": "1.0.0.0", |
| 4 | + "metadata": { |
| 5 | + "_generator": { |
| 6 | + "name": "bicep", |
| 7 | + "version": "0.4.1272.37030", |
| 8 | + "templateHash": "10564275694562029269" |
| 9 | + } |
| 10 | + }, |
| 11 | + "parameters": { |
| 12 | + "budgetAmount": { |
| 13 | + "type": "int" |
| 14 | + }, |
| 15 | + "budgetActualThreshold": { |
| 16 | + "type": "int" |
| 17 | + }, |
| 18 | + "budgetForecastThreshold": { |
| 19 | + "type": "int" |
| 20 | + }, |
| 21 | + "budgetStartDate": { |
| 22 | + "type": "string" |
| 23 | + } |
| 24 | + }, |
| 25 | + "resources": [ |
| 26 | + { |
| 27 | + "type": "Microsoft.Resources/deployments", |
| 28 | + "apiVersion": "2020-10-01", |
| 29 | + "name": "budgetDeploy", |
| 30 | + "location": "[deployment().location]", |
| 31 | + "properties": { |
| 32 | + "expressionEvaluationOptions": { |
| 33 | + "scope": "inner" |
| 34 | + }, |
| 35 | + "mode": "Incremental", |
| 36 | + "parameters": { |
| 37 | + "amount": { |
| 38 | + "value": "[parameters('budgetAmount')]" |
| 39 | + }, |
| 40 | + "actualThreshold": { |
| 41 | + "value": "[parameters('budgetActualThreshold')]" |
| 42 | + }, |
| 43 | + "forecastThreshold": { |
| 44 | + "value": "[parameters('budgetForecastThreshold')]" |
| 45 | + }, |
| 46 | + "startDate": { |
| 47 | + "value": "[parameters('budgetStartDate')]" |
| 48 | + } |
| 49 | + }, |
| 50 | + "template": { |
| 51 | + "$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#", |
| 52 | + "contentVersion": "1.0.0.0", |
| 53 | + "metadata": { |
| 54 | + "_generator": { |
| 55 | + "name": "bicep", |
| 56 | + "version": "0.4.1272.37030", |
| 57 | + "templateHash": "9897258113487664291" |
| 58 | + } |
| 59 | + }, |
| 60 | + "parameters": { |
| 61 | + "startDate": { |
| 62 | + "type": "string" |
| 63 | + }, |
| 64 | + "amount": { |
| 65 | + "type": "int" |
| 66 | + }, |
| 67 | + "forecastThreshold": { |
| 68 | + "type": "int" |
| 69 | + }, |
| 70 | + "actualThreshold": { |
| 71 | + "type": "int" |
| 72 | + }, |
| 73 | + "contactEmails": { |
| 74 | + "type": "array", |
| 75 | + "defaultValue": [] |
| 76 | + }, |
| 77 | + "contactRoles": { |
| 78 | + "type": "array", |
| 79 | + "defaultValue": [ |
| 80 | + "Owner", |
| 81 | + "Contributor" |
| 82 | + ] |
| 83 | + }, |
| 84 | + "contactGroups": { |
| 85 | + "type": "array", |
| 86 | + "defaultValue": [] |
| 87 | + } |
| 88 | + }, |
| 89 | + "resources": [ |
| 90 | + { |
| 91 | + "type": "Microsoft.Consumption/budgets", |
| 92 | + "apiVersion": "2021-10-01", |
| 93 | + "name": "[format('budget-{0}', subscription().displayName)]", |
| 94 | + "properties": { |
| 95 | + "timePeriod": { |
| 96 | + "startDate": "[parameters('startDate')]" |
| 97 | + }, |
| 98 | + "timeGrain": "Monthly", |
| 99 | + "amount": "[parameters('amount')]", |
| 100 | + "category": "Cost", |
| 101 | + "notifications": { |
| 102 | + "NotificationForExceededBudget1": { |
| 103 | + "enabled": true, |
| 104 | + "operator": "GreaterThan", |
| 105 | + "threshold": "[parameters('forecastThreshold')]", |
| 106 | + "thresholdType": "Forecasted", |
| 107 | + "contactEmails": "[parameters('contactEmails')]", |
| 108 | + "contactRoles": "[parameters('contactRoles')]", |
| 109 | + "contactGroups": "[parameters('contactGroups')]" |
| 110 | + }, |
| 111 | + "NotificationForExceededBudget2": { |
| 112 | + "enabled": true, |
| 113 | + "operator": "GreaterThan", |
| 114 | + "threshold": "[parameters('actualThreshold')]", |
| 115 | + "contactEmails": "[parameters('contactEmails')]", |
| 116 | + "contactRoles": "[parameters('contactRoles')]", |
| 117 | + "contactGroups": "[parameters('contactGroups')]" |
| 118 | + } |
| 119 | + } |
| 120 | + } |
| 121 | + } |
| 122 | + ] |
| 123 | + } |
| 124 | + } |
| 125 | + } |
| 126 | + ] |
| 127 | +} |
0 commit comments