{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "metadata": {
    "description": "Bluedeer Activity for Microsoft Sentinel: the BluedeerActivity_CL table and a data collection rule (kind Direct, with its own logs ingestion endpoint) whose stream Custom-BluedeerActivity_CL Bluedeer sends to. After deploying, give the app Bluedeer signs in as the Monitoring Metrics Publisher role on the rule. Not yet tried against a live Azure subscription (siem-api, 25 Nov 2026)."
  },
  "parameters": {
    "workspaceName": {
      "type": "string",
      "metadata": {
        "description": "The Log Analytics workspace Sentinel uses."
      }
    },
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]"
    },
    "ruleName": {
      "type": "string",
      "defaultValue": "bluedeer-activity"
    }
  },
  "resources": [
    {
      "type": "Microsoft.OperationalInsights/workspaces/tables",
      "apiVersion": "2022-10-01",
      "name": "[concat(parameters('workspaceName'), '/BluedeerActivity_CL')]",
      "properties": {
        "schema": {
          "name": "BluedeerActivity_CL",
          "columns": [
            {
              "name": "TimeGenerated",
              "type": "datetime"
            },
            {
              "name": "EventTime",
              "type": "datetime"
            },
            {
              "name": "EventTimeMs",
              "type": "long"
            },
            {
              "name": "EventId",
              "type": "string"
            },
            {
              "name": "Record",
              "type": "string"
            },
            {
              "name": "EventType",
              "type": "string"
            },
            {
              "name": "Category",
              "type": "string"
            },
            {
              "name": "Outcome",
              "type": "string"
            },
            {
              "name": "WorkspaceId",
              "type": "string"
            },
            {
              "name": "WorkspaceName",
              "type": "string"
            },
            {
              "name": "ActorKind",
              "type": "string"
            },
            {
              "name": "ActorId",
              "type": "string"
            },
            {
              "name": "ActorEmail",
              "type": "string"
            },
            {
              "name": "ActorName",
              "type": "string"
            },
            {
              "name": "Targets",
              "type": "dynamic"
            },
            {
              "name": "SourceIp",
              "type": "string"
            },
            {
              "name": "UserAgent",
              "type": "string"
            },
            {
              "name": "Channel",
              "type": "string"
            },
            {
              "name": "RequestId",
              "type": "string"
            },
            {
              "name": "Summary",
              "type": "string"
            },
            {
              "name": "Changes",
              "type": "dynamic"
            },
            {
              "name": "Details",
              "type": "dynamic"
            },
            {
              "name": "Count",
              "type": "int"
            },
            {
              "name": "RepeatOf",
              "type": "string"
            },
            {
              "name": "ChainFormat",
              "type": "string"
            },
            {
              "name": "ChainSeq",
              "type": "long"
            },
            {
              "name": "PrevHash",
              "type": "string"
            },
            {
              "name": "ContentHash",
              "type": "string"
            },
            {
              "name": "RowHash",
              "type": "string"
            },
            {
              "name": "Checkpoint",
              "type": "dynamic"
            },
            {
              "name": "CountStep",
              "type": "dynamic"
            }
          ]
        },
        "retentionInDays": 90
      }
    },
    {
      "type": "Microsoft.Insights/dataCollectionRules",
      "apiVersion": "2023-03-11",
      "name": "[parameters('ruleName')]",
      "location": "[parameters('location')]",
      "kind": "Direct",
      "dependsOn": [
        "[resourceId('Microsoft.OperationalInsights/workspaces/tables', parameters('workspaceName'), 'BluedeerActivity_CL')]"
      ],
      "properties": {
        "streamDeclarations": {
          "Custom-BluedeerActivity_CL": {
            "columns": [
              {
                "name": "TimeGenerated",
                "type": "datetime"
              },
              {
                "name": "EventTime",
                "type": "datetime"
              },
              {
                "name": "EventTimeMs",
                "type": "long"
              },
              {
                "name": "EventId",
                "type": "string"
              },
              {
                "name": "Record",
                "type": "string"
              },
              {
                "name": "EventType",
                "type": "string"
              },
              {
                "name": "Category",
                "type": "string"
              },
              {
                "name": "Outcome",
                "type": "string"
              },
              {
                "name": "WorkspaceId",
                "type": "string"
              },
              {
                "name": "WorkspaceName",
                "type": "string"
              },
              {
                "name": "ActorKind",
                "type": "string"
              },
              {
                "name": "ActorId",
                "type": "string"
              },
              {
                "name": "ActorEmail",
                "type": "string"
              },
              {
                "name": "ActorName",
                "type": "string"
              },
              {
                "name": "Targets",
                "type": "dynamic"
              },
              {
                "name": "SourceIp",
                "type": "string"
              },
              {
                "name": "UserAgent",
                "type": "string"
              },
              {
                "name": "Channel",
                "type": "string"
              },
              {
                "name": "RequestId",
                "type": "string"
              },
              {
                "name": "Summary",
                "type": "string"
              },
              {
                "name": "Changes",
                "type": "dynamic"
              },
              {
                "name": "Details",
                "type": "dynamic"
              },
              {
                "name": "Count",
                "type": "int"
              },
              {
                "name": "RepeatOf",
                "type": "string"
              },
              {
                "name": "ChainFormat",
                "type": "string"
              },
              {
                "name": "ChainSeq",
                "type": "long"
              },
              {
                "name": "PrevHash",
                "type": "string"
              },
              {
                "name": "ContentHash",
                "type": "string"
              },
              {
                "name": "RowHash",
                "type": "string"
              },
              {
                "name": "Checkpoint",
                "type": "dynamic"
              },
              {
                "name": "CountStep",
                "type": "dynamic"
              }
            ]
          }
        },
        "destinations": {
          "logAnalytics": [
            {
              "workspaceResourceId": "[resourceId('Microsoft.OperationalInsights/workspaces', parameters('workspaceName'))]",
              "name": "sentinel"
            }
          ]
        },
        "dataFlows": [
          {
            "streams": [
              "Custom-BluedeerActivity_CL"
            ],
            "destinations": [
              "sentinel"
            ],
            "transformKql": "source",
            "outputStream": "Custom-BluedeerActivity_CL"
          }
        ]
      }
    }
  ],
  "outputs": {
    "dcrImmutableId": {
      "type": "string",
      "value": "[reference(resourceId('Microsoft.Insights/dataCollectionRules', parameters('ruleName'))).immutableId]"
    },
    "logsIngestionEndpoint": {
      "type": "string",
      "value": "[reference(resourceId('Microsoft.Insights/dataCollectionRules', parameters('ruleName'))).endpoints.logsIngestion]"
    },
    "streamName": {
      "type": "string",
      "value": "Custom-BluedeerActivity_CL"
    }
  }
}
