last sync: 2020-Jul-14 15:28:17 UTC

Azure Policy

Metric alert rules should be configured on Batch accounts

Policy DisplayName Metric alert rules should be configured on Batch accounts
Policy Id 26ee67a2-f81a-4ba8-b9ce-8550bd5ee1a7
Policy Category Batch
Policy Description Audit configuration of metric alert rules on Batch account to enable the required metric
Policy Mode Indexed
Policy Type BuiltIn
Policy in Preview FALSE
Policy Deprecated FALSE
Policy Effect Default: AuditIfNotExists
Allowed: (AuditIfNotExists,Disabled)
Roles used none
Policy Changes no changes
Used in Policy Initiative(s)
Initiative DisplayName Initiative Id
[Preview]: Motion Picture Association of America (MPAA) 92646f03-e39d-47a9-9e24-58d60ef49af8
Policy Rule
{
  "properties": {
    "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'))]"
              }
            ]
          }
        }
      }
    }
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/26ee67a2-f81a-4ba8-b9ce-8550bd5ee1a7",
  "type": "Microsoft.Authorization/policyDefinitions",
  "name": "26ee67a2-f81a-4ba8-b9ce-8550bd5ee1a7"
}