Skip to content

Instantly share code, notes, and snippets.

@fRanK45jPm
Last active February 16, 2021 00:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fRanK45jPm/dece088373c61149fb513b63816ca22e to your computer and use it in GitHub Desktop.
Save fRanK45jPm/dece088373c61149fb513b63816ca22e to your computer and use it in GitHub Desktop.
{
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"budgetName": {
"defaultValue": "Allowed Budget 2021",
"type": "String",
"metadata": {
"description": "Name of the Budget. It should be unique within a resource group."
}
},
"amount": {
"defaultValue": "25",
"type": "String",
"metadata": {
"description": "The total amount of cost or usage to track with the budget"
}
},
"timeGrain": {
"defaultValue": "Annually",
"allowedValues": [
"Monthly",
"Quarterly",
"Annually"
],
"type": "String",
"metadata": {
"description": "The time covered by a budget. Tracking of the amount will be reset based on the time grain."
}
},
"startDate": {
"defaultValue": "2021-01-01",
"type": "String",
"metadata": {
"description": "The start date must be first of the month in YYYY-MM-DD format. Future start date should not be more than three months. Past start date should be selected within the timegrain preiod."
}
},
"endDate": {
"defaultValue": "2021-12-31",
"type": "String",
"metadata": {
"description": "The end date for the budget in YYYY-MM-DD format. If not provided, we default this to 10 years from the start date."
}
},
"firstThreshold": {
"defaultValue": "90",
"type": "String",
"metadata": {
"description": "Threshold value associated with a notification. Notification is sent when the cost exceeded the threshold. It is always percent and has to be between 0 and 1000."
}
},
"secondThreshold": {
"defaultValue": "110",
"type": "String",
"metadata": {
"description": "Threshold value associated with a notification. Notification is sent when the cost exceeded the threshold. It is always percent and has to be between 0 and 1000."
}
},
"contactRoles": {
"defaultValue": [
"Owner",
"Contributor"
],
"type": "Array",
"metadata": {
"description": "The list of contact roles to send the budget notification to when the threshold is exceeded."
}
},
"contactEmails": {
"defaultValue": [
"johnm@cloudswyft.com"
],
"type": "Array",
"metadata": {
"description": "The list of email addresses to send the budget notification to when the threshold is exceeded."
}
},
"contactGroups": {
"defaultValue": [],
"type": "Array",
"metadata": {
"description": "The list of action groups to send the budget notification to when the threshold is exceeded. It accepts array of strings."
}
},
"resourceGroupFilterValues": {
"defaultValue": [],
"type": "Array",
"metadata": {
"description": "The set of values for the first filter"
}
},
"meterCategoryFilterValues": {
"defaultValue": [],
"type": "Array",
"metadata": {
"description": "The set of values for the second filter"
}
}
},
"variables": {},
"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')]",
"contactRoles": "[parameters('contactRoles')]",
"contactGroups": "[parameters('contactGroups')]"
},
"NotificationForExceededBudget2": {
"enabled": true,
"operator": "GreaterThan",
"threshold": "[parameters('secondThreshold')]",
"contactEmails": "[parameters('contactEmails')]",
"contactRoles": "[parameters('contactRoles')]",
"contactGroups": "[parameters('contactGroups')]"
}
},
"filter": {
"and": [{
"dimensions": {
"name": "ResourceGroupName",
"operator": "In",
"values": "[parameters('resourceGroupFilterValues')]"
}
},
{
"dimensions": {
"name": "MeterCategory",
"operator": "In",
"values": "[parameters('meterCategoryFilterValues')]"
}
}
]
}
}
}]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment