output/20260723_081532/govviz/ALZ_20260723_081601/Enterprise-Scale/src/resources/Microsoft.Authorization/policyDefinitions/Deploy-ASC-SecurityContacts.json

{
  "name": "Deploy-ASC-SecurityContacts",
  "type": "Microsoft.Authorization/policyDefinitions",
  "apiVersion": "2021-06-01",
  "scope": null,
  "properties": {
    "policyType": "Custom",
    "mode": "All",
    "displayName": "Deploy Microsoft Defender for Cloud Security Contacts",
    "description": "Deploy Microsoft Defender for Cloud Security Contacts",
    "metadata": {
      "version": "3.0.0",
      "category": "Security Center",
      "source": "https://github.com/Azure/Enterprise-Scale/",
      "alzCloudEnvironments": [
        "AzureCloud",
        "AzureChinaCloud",
        "AzureUSGovernment"
      ]
    },
    "parameters": {
      "emailSecurityContact": {
        "type": "String",
        "metadata": {
          "displayName": "Security contacts email address",
          "description": "Provide email addresses (semi-colon separated) for Defender for Cloud contact details"
        }
      },
      "effect": {
        "type": "String",
        "defaultValue": "DeployIfNotExists",
        "allowedValues": [
          "DeployIfNotExists",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        }
      },
      "minimalSeverity": {
        "type": "String",
        "defaultValue": "High",
        "allowedValues": [
          "High",
          "Medium",
          "Low"
        ],
        "metadata": {
          "displayName": "Minimal severity",
          "description": "Defines the minimal alert severity which will be sent as email notifications"
        }
      },
      "attackPathSeverity": {
        "type": "String",
        "defaultValue": "Critical",
        "allowedValues": [
          "Critical",
          "High",
          "Medium",
          "Low"
        ],
        "metadata": {
          "displayName": "Attack path severity",
          "description": "Defines the minimal attack path risk level which will be sent as email notifications"
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Resources/subscriptions"
          }
        ]
      },
      "then": {
        "effect": "[[parameters('effect')]",
        "details": {
          "type": "Microsoft.Security/securityContacts",
          "deploymentScope": "subscription",
          "existenceScope": "subscription",
          "roleDefinitionIds": [
            "/providers/Microsoft.Authorization/roleDefinitions/fb1c8493-542b-48eb-b624-b4c8fea62acd"
          ],
          "existenceCondition": {
            "allOf": [
              {
                "field": "Microsoft.Security/securityContacts/email",
                "contains": "[[parameters('emailSecurityContact')]"
              },
              {
                "field": "Microsoft.Security/securityContacts/isEnabled",
                "equals": true
              },
              {
                "count": {
                  "field": "Microsoft.Security/securityContacts/notificationsSources[*]",
                    "where": {
                      "allOf": [
                        {
                          "field": "Microsoft.Security/securityContacts/notificationsSources[*].sourceType",
                          "equals": "Alert"
                        },
                        {
                          "field": "Microsoft.Security/securityContacts/notificationsSources[*].Alert.minimalSeverity",
                          "equals": "[[parameters('minimalSeverity')]"
                        }
                      ]
                    }
                  },
                  "greaterOrEquals": 1
              },
              {
                "count": {
                  "field": "Microsoft.Security/securityContacts/notificationsSources[*]",
                    "where": {
                      "allOf": [
                        {
                          "field": "Microsoft.Security/securityContacts/notificationsSources[*].sourceType",
                          "equals": "AttackPath"
                        },
                        {
                          "field": "Microsoft.Security/securityContacts/notificationsSources[*].AttackPath.minimalRiskLevel",
                          "equals": "[[parameters('attackPathSeverity')]"
                        }
                      ]
                    }
                  },
                  "greaterOrEquals": 1
              }
            ]
          },
          "deployment": {
            "location": "northeurope",
            "properties": {
              "mode": "incremental",
              "parameters": {
                "emailSecurityContact": {
                  "value": "[[parameters('emailSecurityContact')]"
                },
                "minimalSeverity": {
                  "value": "[[parameters('minimalSeverity')]"
                },
                "attackPathSeverity": {
                  "value": "[[parameters('attackPathSeverity')]"
                }
              },
              "template": {
                "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
                "contentVersion": "1.0.0.0",
                "parameters": {
                  "emailSecurityContact": {
                    "type": "string",
                    "metadata": {
                      "description": "Security contacts email address"
                    }
                  },
                  "minimalSeverity": {
                    "type": "string",
                    "metadata": {
                      "description": "Minimal severity level reported"
                    }
                  },
                  "attackPathSeverity": {
                    "type": "string",
                    "metadata": {
                      "description": "Attack path severity level reported"
                    }
                  }
                },
                "variables": {},
                "resources": [
                  {
                    "type": "Microsoft.Security/securityContacts",
                    "name": "default",
                    "apiVersion": "2023-12-01-preview",
                    "properties": {
                      "emails": "[[parameters('emailSecurityContact')]",
                      "isEnabled": true,
                      "notificationsByRole": {
                        "state": "On",
                        "roles": [
                          "Owner"
                        ]
                      },
                      "notificationsSources": [
                        {
                          "sourceType": "Alert",
                          "minimalSeverity": "[[parameters('minimalSeverity')]"
                        },
                        {
                          "sourceType": "AttackPath",
                          "minimalRiskLevel": "[[parameters('attackPathSeverity')]"
                        }
                      ]
                    }
                  }
                ],
                "outputs": {}
              }
            }
          }
        }
      }
    }
  }
}