last sync: 2021-Sep-22 19:36:51 UTC

Azure Policy definition

Metric alert rules should be configured on Batch accounts

Name Metric alert rules should be configured on Batch accounts
Azure Portal
Id 26ee67a2-f81a-4ba8-b9ce-8550bd5ee1a7
Version 1.0.0
details on versioning
Category Batch
Microsoft docs
Description Audit configuration of metric alert rules on Batch account to enable the required metric
Mode Indexed
Type BuiltIn
Preview FALSE
Deprecated FALSE
Effect Default: AuditIfNotExists
Allowed: (AuditIfNotExists, Disabled)
Used RBAC Role none
History none
Used in Initiatives
Initiative DisplayName Initiative Id Initiative Category State
[Preview]: Motion Picture Association of America (MPAA) 92646f03-e39d-47a9-9e24-58d60ef49af8 Regulatory Compliance Preview
JSON
{
  "displayName": "Metric alert rules should be configured on Batch accounts",
  "policyType": "BuiltIn",
  "mode": "Indexed",
  "description": "Audit configuration of metric alert rules on Batch account to enable the required metric",
  "metadata": {
    "version": "1.0.0",
    "category": "Batch"
  },
  "parameters": {
    "effect": {
      "type": "String",
      "metadata": {
        "displayName": "Effect",
        "description": "Enable or disable the execution of the policy"
      },
      "allowedValues": [
        "AuditIfNotExists",
        "Disabled"
      ],
      "defaultValue": "AuditIfNotExists"
    },
    "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'))]"
            }
          ]
        }
      }
    }
  }
}