{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "workspace": {
      "type": "String"
    }
  },
  "resources": [
    {
      "apiVersion": "2024-01-01-preview",
      "id": "[concat(resourceId('Microsoft.OperationalInsights/workspaces/providers', parameters('workspace'), 'Microsoft.SecurityInsights'),'/alertRules/5acbe4cb-a379-4acc-9ad3-28dc48ad33d3')]",
      "kind": "Scheduled",
      "name": "[concat(parameters('workspace'),'/Microsoft.SecurityInsights/5acbe4cb-a379-4acc-9ad3-28dc48ad33d3')]",
      "properties": {
        "alertRuleTemplateName": "5acbe4cb-a379-4acc-9ad3-28dc48ad33d3",
        "customDetails": null,
        "description": "Identifies identity management actions whereby a user is added to a set of monitored privileged role collections.",
        "displayName": "BTP - User added to sensitive privileged role collection",
        "enabled": true,
        "entityMappings": [
          {
            "entityType": "Account",
            "fieldMappings": [
              {
                "columnName": "AccountName",
                "identifier": "Name"
              },
              {
                "columnName": "UPNSuffix",
                "identifier": "UPNSuffix"
              }
            ]
          },
          {
            "entityType": "CloudApplication",
            "fieldMappings": [
              {
                "columnName": "CloudApp",
                "identifier": "Name"
              }
            ]
          }
        ],
        "eventGroupingSettings": {
          "aggregationKind": "SingleAlert"
        },
        "OriginalUri": "https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/SAP%20BTP/Analytic%20Rules/BTP%20-%20User%20added%20to%20sensitive%20privileged%20role%20collection.yaml",
        "query": "let monitored_rolecollections = dynamic([\"Subaccount Service Administrator\", \"Subaccount Administrator\", \"Connectivity and Destination Administrator\", \"Destination Administrator\", \"Cloud Connector Administrator\"]);\nSAPBTPAuditLog_CL\n| where Message.object has \"xs_rolecollection2user\"\n| extend ObjectId = parse_json((Message.object).id)\n| where ObjectId.crudType == \"CREATE\"\n| extend RoleCollection = ObjectId.rolecollection_name, TargetUserId = ObjectId.user_id\n| where RoleCollection in (monitored_rolecollections)\n| project UpdatedOn, UserName, RoleCollection, TargetUserId, Tenant, SpaceId, CloudApp = \"SAP BTP\"\n| extend AccountName = split(UserName, \"@\")[0], UPNSuffix = split(UserName, \"@\")[1]\n",
        "queryFrequency": "PT15M",
        "queryPeriod": "PT15M",
        "severity": "Low",
        "status": "Available",
        "subTechniques": [],
        "suppressionDuration": "PT1H",
        "suppressionEnabled": false,
        "tactics": [
          "LateralMovement",
          "PrivilegeEscalation"
        ],
        "techniques": [
          "T1078"
        ],
        "templateVersion": "3.0.5",
        "triggerOperator": "GreaterThan",
        "triggerThreshold": 0
      },
      "type": "Microsoft.OperationalInsights/workspaces/providers/alertRules"
    }
  ]
}
