Gallery › Batch › Azure built-in policies
[Deprecated]: Metric alert rules should be configured on Batch accounts
Converted Policy AuditIfNotExists Disabled Mode Indexed Version 1.1.0-deprecated Deprecated
The Microsoft.Insights/alertRules resource type was deprecated.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONAuditMetricAlerts_Audit.json · 70 lines
{
"properties": {
"displayName": "[Deprecated]: Metric alert rules should be configured on Batch accounts",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "The Microsoft.Insights/alertRules resource type was deprecated.",
"metadata": {
"version": "1.1.0-deprecated",
"category": "Batch",
"deprecated": true
},
"version": "1.1.0",
"parameters": {
"effect": {
"type": "string",
"defaultValue": "Disabled",
"allowedValues": [
"AuditIfNotExists",
"Disabled"
],
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
}
},
"metricName": {
"type": "String",
"metadata": {
"displayName": "Metric name",
"description": "The metric name that an alert rule must be enabled on"
}
}
},
"policyRule": {
"if": {
"field": "type",
"equals": "Microsoft.Batch/batchAccounts"
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.Insights/alertRules",
"existenceScope": "Subscription",
"existenceCondition": {
"allOf": [
{
"field": "Microsoft.Insights/alertRules/isEnabled",
"equals": "true"
},
{
"field": "Microsoft.Insights/alertRules/condition.dataSource.metricName",
"equals": "[parameters('metricName')]"
},
{
"field": "Microsoft.Insights/alertRules/condition.dataSource.resourceUri",
"equals": "[concat('/subscriptions/', subscription().subscriptionId, '/resourcegroups/', resourceGroup().name, '/providers/Microsoft.Batch/batchAccounts/', field('name'))]"
}
]
}
}
}
},
"versions": [
"1.1.0",
"1.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/26ee67a2-f81a-4ba8-b9ce-8550bd5ee1a7",
"name": "26ee67a2-f81a-4ba8-b9ce-8550bd5ee1a7"
}Bylaw26ee67a2-f81a-4ba8-b9ce-8550bd5ee1a7.bylaw.ps1 · 36 lines
# Converted from AuditMetricAlerts_Audit.json by ConvertTo-Bylaw.
Policy '26ee67a2-f81a-4ba8-b9ce-8550bd5ee1a7' {
Properties @{
DisplayName = '[Deprecated]: Metric alert rules should be configured on Batch accounts'
Description = 'The Microsoft.Insights/alertRules resource type was deprecated.'
Version = '1.1.0-deprecated'
Category = 'Batch'
Deprecated = $true
PolicyVersion = '1.1.0'
Mode = 'Indexed'
}
Parameter Effect @{
Type = 'string'
AllowedValues = @('AuditIfNotExists', 'Disabled')
Default = 'Disabled'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Parameter MetricName @{
Type = 'String'
DisplayName = 'Metric name'
Description = 'The metric name that an alert rule must be enabled on'
}
Resource 'Microsoft.Batch/batchAccounts'
AuditIfNotExists 'Microsoft.Insights/alertRules' -ExistenceScope Subscription -Effect (Param Effect) {
Require 'isEnabled, condition.dataSource.metricName, condition.dataSource.resourceUri and 1 more are as required' {
Field 'Microsoft.Insights/alertRules/isEnabled' -AllowUnknownAlias | Must -Be 'true'
Field 'Microsoft.Insights/alertRules/condition.dataSource.metricName' -AllowUnknownAlias | Must -Be (Param MetricName)
Field 'Microsoft.Insights/alertRules/condition.dataSource.resourceUri' -AllowUnknownAlias | Must -Be (Arm '[concat(''/subscriptions/'', subscription().subscriptionId, ''/resourcegroups/'', resourceGroup().name, ''/providers/Microsoft.Batch/batchAccounts/'', field(''name''))]')
}
}
}Source: built-in-policies/policyDefinitions/Batch/AuditMetricAlerts_Audit.json in Azure/azure-policy, under the MIT licence.
Bylaw