Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notification-hubs-namespaces-diagnostics #408

Merged
merged 17 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,254 @@
{
"name": "6bd66aff-f8f2-4e98-a276-619a78b00e79",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Deploy subscription budget in MG",
"description": "Deploy a budget for a subscription that will notify the owner once a threshold of 50%, 90%, and 100% of the actual cost of budget is reached. Use the tags 'Owner-Email' and 'Technical-Contact-Email' with email addresses to send emails to those emails.",
"metadata": {
"category": "Budget",
"version": "1.0.0"
},
"mode": "All",
"parameters": {
"amount": {
"defaultValue": "1000",
"metadata": {
"description": "The total amount of cost or usage to track with the budget",
"displayName": "amount"
},
"type": "String"
},
"budgetName": {
"defaultValue": "budget-set-by-policy",
"metadata": {
"description": "The name for the budget to be created",
"displayName": "budgetName"
},
"type": "String"
},
"contactRoles": {
"defaultValue": [
"Contributor"
],
"metadata": {
"description": "The list of contact RBAC roles, in an array, to send the budget notification to when the threshold is exceeded.",
"displayName": "contactRoles"
},
"type": "Array"
},
"firstThreshold": {
"defaultValue": "50",
"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.",
"displayName": "firstThreshold"
},
"type": "String"
},
"secondThreshold": {
"defaultValue": "90",
"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.",
"displayName": "secondThreshold"
},
"type": "String"
},
"thirdThreshold": {
"defaultValue": "100",
"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.",
"displayName": "thirdThreshold"
},
"type": "String"
},
"timeGrain": {
"allowedValues": [
"Monthly",
"Quarterly",
"Annually",
"BillingMonth",
"BillingQuarter",
"BillingAnnual"
],
"defaultValue": "BillingMonth",
"metadata": {
"description": "The time covered by a budget. Tracking of the amount will be reset based on the time grain.",
"displayName": "timeGrain"
},
"type": "String"
},
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "DeployIfNotExists, AuditIfNotExists or Disabled the execution of the Policy"
},
"allowedValues": [
"DeployIfNotExists",
"AuditIfNotExists",
"Disabled"
],
"defaultValue": "DeployIfNotExists"
}
},
"policyRule": {
"if": {
"allOf": [
{
"equals": "Microsoft.Resources/subscriptions",
"field": "type"
}
]
},
"then": {
"details": {
"deployment": {
"location": "westeurope",
"properties": {
"mode": "Incremental",
"parameters": {
"amount": {
"value": "[parameters('amount')]"
},
"budgetName": {
"value": "[parameters('budgetName')]"
},
"contactEmails": {
"value": [
"[field(concat('tags[','Owner-Email', ']'))]",
"[field(concat('tags[','Technical-Contact-Email', ']'))]"
]
},
"contactRoles": {
"value": "[parameters('contactRoles')]"
},
"firstThreshold": {
"value": "[parameters('firstThreshold')]"
},
"secondThreshold": {
"value": "[parameters('secondThreshold')]"
},
"thirdThreshold": {
"value": "[parameters('thirdThreshold')]"
},
"timeGrain": {
"value": "[parameters('timeGrain')]"
}
},
"template": {
"$schema": "http://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json",
"contentVersion": "1.0.0.0",
"parameters": {
"amount": {
"type": "String"
},
"budgetName": {
"type": "String"
},
"contactEmails": {
"type": "Array"
},
"contactRoles": {
"type": "Array"
},
"firstThreshold": {
"type": "String"
},
"secondThreshold": {
"type": "String"
},
"thirdThreshold": {
"type": "String"
},
"startDate": {
"defaultValue": "[concat(utcNow('MM'), '/01/', utcNow('yyyy'))]",
"type": "String"
},
"timeGrain": {
"type": "String"
}
},
"resources": [
{
"apiVersion": "2021-10-01",
"name": "[parameters('budgetName')]",
"properties": {
"amount": "[parameters('amount')]",
"category": "Cost",
"notifications": {
"NotificationForExceededBudget1": {
"contactEmails": "[parameters('contactEmails')]",
"contactRoles": "[parameters('contactRoles')]",
"enabled": true,
"operator": "GreaterThan",
"threshold": "[parameters('firstThreshold')]"
},
"NotificationForExceededBudget2": {
"contactEmails": "[parameters('contactEmails')]",
"contactRoles": "[parameters('contactRoles')]",
"enabled": true,
"operator": "GreaterThan",
"threshold": "[parameters('secondThreshold')]"
},
"NotificationForExceededBudget3": {
"contactEmails": "[parameters('contactEmails')]",
"contactRoles": "[parameters('contactRoles')]",
"enabled": true,
"operator": "GreaterThan",
"threshold": "[parameters('thirdThreshold')]"
},
"NotificationForExceededBudget4": {
"contactEmails": "[parameters('contactEmails')]",
"contactRoles": "[parameters('contactRoles')]",
"enabled": true,
"operator": "GreaterThan",
"threshold": "[parameters('firstThreshold')]",
"thresholdType": "Forecasted"
},
"NotificationForExceededBudget5": {
"contactEmails": "[parameters('contactEmails')]",
"contactRoles": "[parameters('contactRoles')]",
"enabled": true,
"operator": "GreaterThan",
"threshold": "[parameters('thirdThreshold')]",
"thresholdType": "Forecasted"
}
},
"timeGrain": "[parameters('timeGrain')]",
"timePeriod": {
"startDate": "[parameters('startDate')]"
}
},
"type": "Microsoft.Consumption/budgets"
}
]
}
}
},
"deploymentScope": "subscription",
"existenceCondition": {
"allOf": [
{
"equals": "[parameters('amount')]",
"field": "Microsoft.Consumption/budgets/amount"
},
{
"equals": "[parameters('timeGrain')]",
"field": "Microsoft.Consumption/budgets/timeGrain"
},
{
"equals": "Cost",
"field": "Microsoft.Consumption/budgets/category"
}
]
},
"existenceScope": "subscription",
"roleDefinitionIds": [
"/providers/Microsoft.Authorization/roleDefinitions/434105ed-43f6-45c7-a02f-909b2ba83430"
],
"type": "Microsoft.Consumption/budgets"
},
"effect": "[parameters('effect')]"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"amount": {
"defaultValue": "1000",
"metadata": {
"description": "The total amount of cost or usage to track with the budget",
"displayName": "amount"
},
"type": "String"
},
"budgetName": {
"defaultValue": "budget-set-by-policy",
"metadata": {
"description": "The name for the budget to be created",
"displayName": "budgetName"
},
"type": "String"
},
"contactRoles": {
"defaultValue": [
"Contributor"
],
"metadata": {
"description": "The list of contact RBAC roles, in an array, to send the budget notification to when the threshold is exceeded.",
"displayName": "contactRoles"
},
"type": "Array"
},
"firstThreshold": {
"defaultValue": "50",
"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.",
"displayName": "firstThreshold"
},
"type": "String"
},
"secondThreshold": {
"defaultValue": "90",
"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.",
"displayName": "secondThreshold"
},
"type": "String"
},
"thirdThreshold": {
"defaultValue": "100",
"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.",
"displayName": "thirdThreshold"
},
"type": "String"
},
"timeGrain": {
"allowedValues": [
"Monthly",
"Quarterly",
"Annually",
"BillingMonth",
"BillingQuarter",
"BillingAnnual"
],
"defaultValue": "BillingMonth",
"metadata": {
"description": "The time covered by a budget. Tracking of the amount will be reset based on the time grain.",
"displayName": "timeGrain"
},
"type": "String"
},
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "DeployIfNotExists, AuditIfNotExists or Disabled the execution of the Policy"
},
"allowedValues": [
"DeployIfNotExists",
"AuditIfNotExists",
"Disabled"
],
"defaultValue": "DeployIfNotExists"
}
}
Loading