你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
本指南帮助你了解、构建和部署用于 Microsoft Sentinel 的基于推送的无代码连接器,该连接器使用无代码连接器框架 (CCF) 推送(预览版)功能。
什么是 CCF 推送?
CCF 推送连接器使应用程序能够实时将安全事件直接发送到 Microsoft Sentinel。 与定期从 API 提取数据的传统基于轮询的连接器不同,推送连接器允许在系统中发生事件时将数据推送到 Sentinel。
CCF 推送提供了几个关键优势:
- 应用程序控制的数据流: 应用程序控制何时以及如何发送数据、启用智能批处理策略和优化网络使用情况。
- 实时引入: 在事件发生时立即发送数据,而无需等待轮询间隔。
- 简化的体系结构:无需为 Sentinel 轮询维护 API 端点。
- 基于模板的预配: 部署为 DCR、自定义表、Entra 应用程序注册和客户端机密创建 ARM 模板 - 你会收到在发送应用程序中配置的连接详细信息。
- 安全身份验证: 将 Microsoft Entra 应用程序与 OAuth 2.0 配合使用来保护数据提交。
先决条件
Important
CCF Push 连接器部署目前需要在 Azure 门户中使用 Microsoft Sentinel 体验。 通过 Microsoft Defender 门户进行的托管部署在创建连接器所需的标识资源时可能会失败。 如果发生这种情况,请在Azure门户中安装并连接Microsoft Sentinel的连接器,然后使用Microsoft Defender门户进行持续的Microsoft Sentinel操作。
- 在开始之前,必须有权访问用于打包工具的 Azure-Sentinel GitHub 存储库。
- Microsoft Entra 权限:
- 在 Microsoft Entra ID 中创建应用注册的权限。 通常需要 Entra ID 应用程序开发人员角色或更高级别的角色。
- 创建带有密钥的应用程序的权限。 如果未授予此权限,连接器会因安全原因而失败。
- 发布者必须具有适当的角色才能从 Microsoft Entra 应用程序中检索令牌。 这些令牌用于对发送至数据收集端点(DCE)的请求进行身份验证,该端点是连接器最终推送数据的目的地。 如果提供程序无法检索令牌,则无法将数据发送到 DCE。
- Microsoft Azure 权限:
- 在数据收集规则(DCR)上分配监视指标发布者角色的权限。 通常需要Azure RBAC 所有者或用户访问管理员角色。
CCF 推送的工作原理
推送模型与拉取模型
了解推送和拉取数据引入模型之间的差异有助于为方案选择合适的连接器类型。
CCF 拉取连接器 - 轮询式:
在拉取模型中,Microsoft Sentinel 会定期轮询您的 API,以检索数据:
- Microsoft Sentinel 按配置的计划启动与数据源 API 的连接。
- 数据按定期轮询间隔到达,例如每五分钟一次。
- 必须维护可公开访问的 API 终结点。
- Sentinel 的轮询基础结构管理数据收集过程。
CCF 推送连接器 - 事件驱动:
在推送模型中,应用程序将数据直接发送到Microsoft Sentinel:
- 应用程序在事件发生时启动数据提交。
- 生成事件时,数据会近乎实时地到达。
- 无需维护 API 终结点。
- 应用程序控制批处理、计时和数据流优化。
推送数据流
CCF 推送数据流由五个主要步骤组成:
在 Microsoft Sentinel 中部署连接器。
Azure 会自动创建以下资源:
- 带有凭据的 Microsoft Entra 应用程序
- 数据收集规则 (DCR) - 定义如何处理数据
- 数据收集终结点 (DCE) - 发送数据的 URL
- 自定义日志表 - 存储数据的位置
- 角色分配 - Entra 应用的权限
会收到以下连接详细信息:
- 租户 ID
- 应用程序(客户端)ID
- 客户端密码
- DCE URI (终结点 URL)
- DCR 不可变 ID
- 流名称
应用程序发送以下数据:
- 使用 CCF 生成的 Entra 应用凭据获取 OAuth 2.0 令牌。 有关详细信息,请参阅 OAuth 2.0 客户端凭据流
- 将事件的格式设置为与表架构匹配的 JSON
- 将数据 POST 到 DCE 终结点
Azure 处理和存储数据:
- DCRs 对数据进行转换(包括可选的 KQL 转换)
- 数据写入 Log Analytics 中的自定义表
- 数据可用于 Sentinel 中的查询、分析和警报
CCF 推送工件
CCF 推送连接器解决方案由四个主要组件组成:
- 自定义表定义
- 数据收集规则 (DCR)
- 连接器定义(UI)
- 推送连接器配置
自定义表定义
它是什么: 定义 Log Analytics 中数据结构的架构。
关键要求:
- 表名必须以(自定义日志后缀)结尾
_CL。 - 必须包含一个
TimeGenerated列(日期时间类型)。 - 列类型:字符串、int、long、real、bool、datetime、dynamic、guid。
- 使用 API 版本
2025-07-01或更高版本。 - 有关详细信息,请参阅 Azure Monitor 日志中的自定义表。
Example:
{
"name": "ContosoSecurityAlerts_CL",
"type": "Microsoft.OperationalInsights/workspaces/tables",
"apiVersion": "2025-07-01",
"properties": {
"schema": {
"name": "ContosoSecurityAlerts_CL",
"columns": [
{
"name": "TimeGenerated",
"type": "datetime"
},
{
"name": "EventSeverity",
"type": "string"
},
{
"name": "EventType",
"type": "string"
},
{
"name": "UserName",
"type": "string"
},
{
"name": "SourceIP",
"type": "string"
},
{
"name": "DeviceId",
"type": "string"
},
{
"name": "AlertMessage",
"type": "string"
}
]
}
}
}
数据收集规则 (DCR)
它是什么: 定义 Azure Monitor 如何引入和处理数据。 有关详细信息,请参阅 Azure Monitor 中的数据收集规则。
功能:
- 指定输入流名称(发送数据时应用使用的名称)
- 定义可选的 KQL 转换以调整和扩充数据
- 将数据路由到目标表
- 链接到数据收集终结点 (DCE)
关键组件:
-
streamDeclarations:定义传入数据的结构(必须与应用发送的内容匹配) -
destinations:数据所在的位置(Log Analytics 工作区) -
dataFlows:从输入流到输出表的转换管道 -
dataCollectionEndpointId:指向用于数据引入的 DCE 的链接
Example:
{
"name": "ContosoSecurityAlertsPushDCR",
"apiVersion": "2021-09-01-preview",
"type": "Microsoft.Insights/dataCollectionRules",
"location": "[parameters('workspace-location')]",
"properties": {
"streamDeclarations": {
"Custom-ContosoSecurityAlerts": {
"columns": [
{
"name": "EventSeverity",
"type": "string"
},
{
"name": "EventType",
"type": "string"
},
{
"name": "UserName",
"type": "string"
},
{
"name": "SourceIP",
"type": "string"
},
{
"name": "DeviceId",
"type": "string"
},
{
"name": "AlertMessage",
"type": "string"
}
]
}
},
"destinations": {
"logAnalytics": [
{
"workspaceResourceId": "[variables('workspaceResourceId')]",
"name": "clv2ws1"
}
]
},
"dataFlows": [
{
"streams": [
"Custom-ContosoSecurityAlerts"
],
"destinations": [
"clv2ws1"
],
"transformKql": "source | extend TimeGenerated = now()",
"outputStream": "Custom-ContosoSecurityAlerts_CL"
}
],
"dataCollectionEndpointId": "[concat('/subscriptions/',parameters('subscription'),'/resourceGroups/',parameters('resourceGroupName'),'/providers/Microsoft.Insights/dataCollectionEndpoints/',parameters('workspace'))]"
}
}
Important
- 流名称必须以
Custom-前缀开头。 -
transformKql可以是简单的"source"(用于直通),也可以包含用于数据转换的 KQL 逻辑。 -
outputStream必须与表名匹配,并同时具有Custom-前缀和_CL后缀。
连接器定义(UI)
连接器定义控制连接器在 Microsoft Sentinel 数据连接器库中的显示方式。 有关详细信息,请参阅 数据连接器定义 API 参考。
连接器定义包括:
- 连接器标题、说明和品牌塑造
- 所需的先决条件和权限,例如工作区访问和 Entra 权限
- 部署步骤说明
- 用于向用户显示连接详细信息的 UI 控件
关键 UI 元素:
-
DeployPushConnectorButton:触发自动资源部署 -
CopyableLabel:在部署后显示连接详细信息(使用fillWith参数) -
Markdown:提供格式化说明和上下文 -
IsConnectedQuery:基于最近的数据验证连接器连接性
示例结构(为了清楚起见,缩写):
{
"name": "ContosoSecurityAlertsPush",
"apiVersion": "2022-09-01-preview",
"type": "Microsoft.SecurityInsights/dataConnectorDefinitions",
"location": "[parameters('workspace-location')]",
"kind": "Customizable",
"properties": {
"connectorUiConfig": {
"id": "ContosoSecurityAlertsPush",
"title": "Contoso Security Alerts (Push)",
"publisher": "Contoso Corporation",
"descriptionMarkdown": "The [Contoso Security Alerts](https://www.contoso.com/) connector provides the capability to push real-time security alerts from your Contoso application directly into Microsoft Sentinel using the Codeless Connector Framework (CCF) Push pattern. This connector ingests alert severity, event types, user information, and network details into a custom Log Analytics table for analysis, alerting, and visualization.",
"graphQueries": [
{
"metricName": "Security Alerts",
"legend": "ContosoSecurityAlerts_CL",
"baseQuery": "ContosoSecurityAlerts_CL"
}
],
"sampleQueries": [
{
"description": "All security alerts",
"query": "ContosoSecurityAlerts_CL\n | sort by TimeGenerated desc"
},
{
"description": "Critical and High severity alerts",
"query": "ContosoSecurityAlerts_CL\n | where EventSeverity in ('Critical', 'High')\n | sort by TimeGenerated desc"
}
],
"dataTypes": [
{
"name": "ContosoSecurityAlerts_CL",
"lastDataReceivedQuery": "ContosoSecurityAlerts_CL\n| summarize Time = max(TimeGenerated)\n| where isnotempty(Time)"
}
],
"connectivityCriteria": [
{
"type": "IsConnectedQuery",
"value": [
"ContosoSecurityAlerts_CL\n| summarize LastLogReceived = max(TimeGenerated)\n| project IsConnected = LastLogReceived > ago(7d)"
]
}
],
"availability": {
"status": 1
},
"permissions": {
"resourceProvider": [
{
"provider": "Microsoft.OperationalInsights/workspaces",
"permissionsDisplayText": "read and write permissions are required.",
"providerDisplayName": "Workspace",
"scope": "Workspace",
"requiredPermissions": {
"write": true,
"read": true,
"delete": true
}
}
],
"customs": [
{
"name": "Microsoft Entra",
"description": "Permission to create an app registration in Microsoft Entra ID. Typically requires Entra ID Application Developer role or higher."
},
{
"name": "Microsoft Azure",
"description": "Permission to assign Monitoring Metrics Publisher role on data collection rule (DCR). Typically requires Azure RBAC Owner or User Access Administrator role."
}
]
},
"instructionSteps": [
{
"title": "1. Create ARM Resources and Provide the Required Permissions",
"description": "This connector enables your Contoso application to push security alerts directly to Microsoft Sentinel via the Azure Monitor Ingestion API.",
"instructions": [
{
"type": "Markdown",
"parameters": {
"content": "#### Automated Configuration and Secure Data Ingestion with Entra Application \nClicking on \"Deploy\" will trigger the creation of a Log Analytics table and a Data Collection Rule (DCR). \nIt will then create an Entra application, link the DCR to it, and set the entered secret in the application. This setup enables data to be sent securely to the DCR using an Entra token."
}
},
{
"type": "DeployPushConnectorButton",
"parameters": {
"label": "Deploy Contoso Push connector resources",
"applicationDisplayName": "Contoso Security Alerts Push Connector Application"
}
}
]
},
{
"title": "2. Configure Your Contoso Application",
"description": "Use the following parameters to configure your Contoso application to push security alerts to the workspace.",
"instructions": [
{
"type": "CopyableLabel",
"parameters": {
"label": "Tenant ID (Directory ID)",
"fillWith": [
"TenantId"
]
}
},
{
"type": "CopyableLabel",
"parameters": {
"label": "Entra App Registration Application ID",
"fillWith": [
"ApplicationId"
],
"placeholder": "Deploy push connector to get the App Registration Application ID"
}
},
{
"type": "CopyableLabel",
"parameters": {
"label": "Entra App Registration Secret",
"fillWith": [
"ApplicationSecret"
],
"placeholder": "Deploy push connector to get the App Registration Secret"
}
},
{
"type": "CopyableLabel",
"parameters": {
"label": "Data Collection Endpoint Uri",
"fillWith": [
"DataCollectionEndpoint"
],
"placeholder": "Deploy push connector to get the Data Collection Endpoint Uri"
}
},
{
"type": "CopyableLabel",
"parameters": {
"label": "Data Collection Rule Immutable ID",
"fillWith": [
"DataCollectionRuleId"
],
"placeholder": "Deploy push connector to get the Data Collection Rule Immutable ID"
}
},
{
"type": "CopyableLabel",
"parameters": {
"label": "Stream Name",
"value": "Custom-ContosoSecurityAlerts"
}
},
{
"type": "Markdown",
"parameters": {
"content": "#### Configure Contoso Application\nUpdate your Contoso application configuration with the above credentials to enable security alert push to Microsoft Sentinel.\n\nExample configuration:\njson\n{\n \"azure\": {\n \"tenant_id\": \"<Tenant ID>\",\n \"client_id\": \"<Application ID>\",\n \"client_secret\": \"<Application Secret>\",\n \"dce_endpoint\": \"<Data Collection Endpoint Uri>\",\n \"dcr_immutable_id\": \"<Data Collection Rule Immutable ID>\",\n \"stream_name\": \"Custom-ContosoSecurityAlerts\"\n }\n}\n"
}
}
]
}
]
}
}
}
Important
- 在
id中,connectorUiConfig必须是唯一的,并且与数据连接器配置中的引用匹配。 - 使用
IsConnectedQuery进行生产连接器的验证(验证最近的数据),或者hasDataConnectors进行更简单的验证。 - 部署
fillWith后会自动填充其中CopyableLabel的参数。 - 固定的值(如流名称)使用
value参数而不是fillWith。
推送连接器配置
推送连接器配置是将连接器定义链接到已部署资源的数据连接器实例。
推送连接器配置
- 将连接器定义(UI)链接到已部署的 DCR 和 Entra 应用
- 存储身份验证详细信息(应用 ID、服务主体 ID)
- 记录 DCR 配置(终结点、不可变 ID、流名称)
- 使 UI 能够检索和显示用户的连接详细信息
关键属性:
-
connectorDefinitionName:必须与连接器定义中的id匹配 -
dcrConfig:包含 DCR 终结点、规则 ID 和流名称 -
auth:包含 Entra 应用程序 ID 和服务主体 ID -
kind:推送连接器必须设置为“推送”
例:
{
"name": "ContosoSecurityAlertsPushDCR",
"apiVersion": "2021-09-01-preview",
"type": "Microsoft.Insights/dataCollectionRules",
"location": "[parameters('workspace-location')]",
"properties": {
"streamDeclarations": {
"Custom-ContosoSecurityAlerts": {
"columns": [
{
"name": "EventSeverity",
"type": "string"
},
{
"name": "EventType",
"type": "string"
},
{
"name": "UserName",
"type": "string"
},
{
"name": "SourceIP",
"type": "string"
},
{
"name": "DeviceId",
"type": "string"
},
{
"name": "AlertMessage",
"type": "string"
}
]
}
},
"destinations": {
"logAnalytics": [
{
"workspaceResourceId": "[variables('workspaceResourceId')]",
"name": "clv2ws1"
}
]
},
"dataFlows": [
{
"streams": [
"Custom-ContosoSecurityAlerts"
],
"destinations": [
"clv2ws1"
],
"transformKql": "source | extend TimeGenerated = now()",
"outputStream": "Custom-ContosoSecurityAlerts_CL"
}
],
"dataCollectionEndpointId": "[concat('/subscriptions/',parameters('subscription'),'/resourceGroups/',parameters('resourceGroupName'),'/providers/Microsoft.Insights/dataCollectionEndpoints/',parameters('workspace'))]"
}
}
Important
-
connectorDefinitionName必须与连接器定义id完全匹配。 -
streamName必须匹配您在 DCR 中声明的流。 - 当用户选择 DeployPushConnector 按钮时,会在部署期间自动创建此资源。
构建你的第一个推送连接器
在此示例中,你将生成一个简单的推送连接器,用于将安全警报从应用程序发送到 Sentinel。
目标: 将安全警报从应用程序实时发送到 Sentinel
应用程序发送事件结构:
{
"TimeGenerated": "2025-11-21T10:30:00Z",
"EventSeverity": "Medium",
"EventType": "LoginAlert",
"UserName": "alice@contoso.com",
"SourceIP": "192.168.1.100",
"DeviceId": "device-12345",
"AlertMessage": "Multiple failed login attempts detected"
}
创建推送连接器的分步指南
克隆 Azure-Sentinel 存储库
复刻并克隆 Azure-Sentinel 官方存储库到本地计算机。 此存储库包含打包工具并提供标准解决方案结构。
克隆存储库
git clone https://github.com/<YOUR_FORK>/Azure-Sentinel.git导航到解决方案目录
cd Azure-Sentinel/Solutions
存储库结构包括:
- 工具/创建-Azure-Sentinel-解决方案/V3/
- 包含 createSolutionV3.ps1 打包脚本
- 解决方案/将在何处创建连接器解决方案
创建解决方案文件夹结构,按照标准命名约定在解决方案/文件夹中创建新的解决方案目录。 创建解决方案目录(从 Azure-Sentinel/Solutions/)
mkdir ContosoSecurityAlerts cd ContosoSecurityAlerts mkdir Data mkdir "Data Connectors" mkdir "Data Connectors/ContosoSecurityAlerts_ccf"文件夹结构如下所示:
Azure-Sentinel/
~~ 解决方案/
~~ ContosoSecurityAlerts/
├── 数据/
~~ 数据连接器/
└── ContosoSecurityAlerts_ccf/定义你的表
在ContosoSecurityAlerts_ccf文件夹中,使用自定义表定义创建名为 table.json 的文件:
{ "name": "ContosoSecurityAlerts_CL", "type": "Microsoft.OperationalInsights/workspaces/tables", "apiVersion": "2025-07-01", "properties": { "schema": { "name": "ContosoSecurityAlerts_CL", "columns": [ { "name": "TimeGenerated", "type": "datetime" }, { "name": "EventSeverity", "type": "string" }, { "name": "EventType", "type": "string" }, { "name": "UserName", "type": "string" }, { "name": "SourceIP", "type": "string" }, { "name": "DeviceId", "type": "string" }, { "name": "AlertMessage", "type": "string" } ] } } }创建 DCR
在ContosoSecurityAlerts_ccf文件夹中,创建一个名为 DCR.json 的文件,该文件定义输入流并将数据路由到表:
{ "name": "ContosoSecurityAlertsPushDCR", "apiVersion": "2021-09-01-preview", "type": "Microsoft.Insights/dataCollectionRules", "location": "[parameters('workspace-location')]", "properties": { "streamDeclarations": { "Custom-ContosoSecurityAlerts": { "columns": [ { "name": "EventSeverity", "type": "string" }, { "name": "EventType", "type": "string" }, { "name": "UserName", "type": "string" }, { "name": "SourceIP", "type": "string" }, { "name": "DeviceId", "type": "string" }, { "name": "AlertMessage", "type": "string" } ] } }, "destinations": { "logAnalytics": [ { "workspaceResourceId": "[variables('workspaceResourceId')]", "name": "clv2ws1" } ] }, "dataFlows": [ { "streams": [ "Custom-ContosoSecurityAlerts" ], "destinations": [ "clv2ws1" ], "transformKql": "source | extend TimeGenerated = now()", "outputStream": "Custom-ContosoSecurityAlerts_CL" } ], "dataCollectionEndpointId": "[concat('/subscriptions/',parameters('subscription'),'/resourceGroups/',parameters('resourceGroupName'),'/providers/Microsoft.Insights/ dataCollectionEndpoints/',parameters('workspace'))]" } }创建连接器定义
在ContosoSecurityAlerts_ccf文件夹中,创建一个名为 connectorDefinition.json 的文件,用于定义用户在 Sentinel 中与连接器交互的方式:
{ "name": "ContosoSecurityAlertsPush", "apiVersion": "2022-09-01-preview", "type": "Microsoft.SecurityInsights/dataConnectorDefinitions", "location": "[parameters('workspace-location')]", "kind": "Customizable", "properties": { "connectorUiConfig": { "id": "ContosoSecurityAlertsPush", "title": "Contoso Security Alerts (Push)", "publisher": "Contoso Corporation", "descriptionMarkdown": "The [Contoso Security Alerts](https://www.contoso.com/) connector provides the capability to push real-time security alerts from your Contoso application directly into Microsoft Sentinel using the Codeless Connector Framework (CCF) Push pattern. This connector ingests alert severity, event types, user information, and network details into a custom Log Analytics table for analysis, alerting, and visualization.", "graphQueries": [ { "metricName": "Security Alerts", "legend": "ContosoSecurityAlerts_CL", "baseQuery": "ContosoSecurityAlerts_CL" } ], "sampleQueries": [ { "description": "All security alerts", "query": "ContosoSecurityAlerts_CL\n | sort by TimeGenerated desc" }, { "description": "Critical and High severity alerts", "query": "ContosoSecurityAlerts_CL\n | where EventSeverity in ('Critical', 'High')\n | sort by TimeGenerated desc" } ], "dataTypes": [ { "name": "ContosoSecurityAlerts_CL", "lastDataReceivedQuery": "ContosoSecurityAlerts_CL\n| summarize Time = max(TimeGenerated)\n| where isnotempty(Time)" } ], "connectivityCriteria": [ { "type": "IsConnectedQuery", "value": [ "ContosoSecurityAlerts_CL\n| summarize LastLogReceived = max(TimeGenerated)\n| project IsConnected = LastLogReceived > ago(7d)" ] } ], "availability": { "status": 1 }, "permissions": { "resourceProvider": [ { "provider": "Microsoft.OperationalInsights/workspaces", "permissionsDisplayText": "read and write permissions are required.", "providerDisplayName": "Workspace", "scope": "Workspace", "requiredPermissions": { "write": true, "read": true, "delete": true } } ], "customs": [ { "name": "Microsoft Entra", "description": "Permission to create an app registration in Microsoft Entra ID. Typically requires Entra ID Application Developer role or higher." }, { "name": "Microsoft Azure", "description": "Permission to assign Monitoring Metrics Publisher role on data collection rule (DCR). Typically requires Azure RBAC Owner or User Access Administrator role." } ] }, "instructionSteps": [ { "title": "1. Create ARM Resources and Provide the Required Permissions", "description": "This connector enables your Contoso application to push security alerts directly to Microsoft Sentinel via the Azure Monitor Ingestion API.", "instructions": [ { "type": "Markdown", "parameters": { "content": "#### Automated Configuration and Secure Data Ingestion with Entra Application \nClicking on \"Deploy\" will trigger the creation of a Log Analytics table and a Data Collection Rule (DCR). \nIt will then create an Entra application, link the DCR to it, and set the entered secret in the application. This setup enables data to be sent securely to the DCR using an Entra token." } }, { "type": "DeployPushConnectorButton", "parameters": { "label": "Deploy Contoso Push connector resources", "applicationDisplayName": "Contoso Security Alerts Push Connector Application" } } ] }, { "title": "2. Configure Your Contoso Application", "description": "Use the following parameters to configure your Contoso application to push security alerts to the workspace.", "instructions": [ { "type": "CopyableLabel", "parameters": { "label": "Tenant ID (Directory ID)", "fillWith": [ "TenantId" ] } }, { "type": "CopyableLabel", "parameters": { "label": "Entra App Registration Application ID", "fillWith": [ "ApplicationId" ], "placeholder": "Deploy push connector to get the App Registration Application ID" } }, { "type": "CopyableLabel", "parameters": { "label": "Entra App Registration Secret", "fillWith": [ "ApplicationSecret" ], "placeholder": "Deploy push connector to get the App Registration Secret" } }, { "type": "CopyableLabel", "parameters": { "label": "Data Collection Endpoint Uri", "fillWith": [ "DataCollectionEndpoint" ], "placeholder": "Deploy push connector to get the Data Collection Endpoint Uri" } }, { "type": "CopyableLabel", "parameters": { "label": "Data Collection Rule Immutable ID", "fillWith": [ "DataCollectionRuleId" ], "placeholder": "Deploy push connector to get the Data Collection Rule Immutable ID" } }, { "type": "CopyableLabel", "parameters": { "label": "Stream Name", "value": "Custom-ContosoSecurityAlerts" } }, { "type": "Markdown", "parameters": { "content": "#### Configure Contoso Application\nUpdate your Contoso application configuration with the above credentials to enable security alert push to Microsoft Sentinel.\n\nExample configuration:\njson\n{\n \"azure\": {\n \"tenant_id\": \"<Tenant ID>\",\n \"client_id\": \"<Application ID>\",\n \"client_secret\": \"<Application Secret>\",\n \"dce_endpoint\": \"<Data Collection Endpoint Uri>\",\n \"dcr_immutable_id\": \"<Data Collection Rule Immutable ID>\",\n \"stream_name\": \"Custom-ContosoSecurityAlerts\"\n }\n}\n" } } ] } ] } } }创建数据连接器配置
在ContosoSecurityAlerts_ccf文件夹中,创建一个名为 dataConnector.json 的文件,该文件将连接器定义链接到已部署的资源:
{ "name": "ContosoSecurityAlertsPushConnectorPolling", "apiVersion": "2024-09-01", "type": "Microsoft.SecurityInsights/dataConnectors", "kind": "Push", "properties": { "connectorDefinitionName": "ContosoSecurityAlertsPush", "dcrConfig": { "streamName": "Custom-ContosoSecurityAlerts", "dataCollectionEndpoint": "[[parameters('dcrConfig').dataCollectionEndpoint]", "dataCollectionRuleImmutableId": "[[parameters('dcrConfig').dataCollectionRuleImmutableId]" }, "auth": { "type": "Push", "AppId": "[[parameters('auth').appId]", "ServicePrincipalId": "[[parameters('auth').servicePrincipalId]" }, "request": { "RetryCount": 1 }, "response": { "eventsJsonPaths": [ "$" ] } } }创建解决方案元数据文件
Solution_ContosoSecurityAlerts.json 在“数据”文件夹中,创建包含解决方案详细信息的
Solution_ContosoSecurityAlerts.json:{ "Name": "ContosoSecurityAlerts", "Author": "Contoso Corporation - support@contoso.com", "Logo": "<svg width=\"75px\" height=\"75px\" viewBox=\"0 0 75 75\" xmlns=\"http://www.w3.org/2000/svg\"><rect width=\"75\" height=\"75\" fill=\"#FF6B35\"/><text x=\"37. 5\" y=\"45\" font-family=\"Arial\" font-size=\"18\" fill=\"white\" text-anchor=\"middle\" font-weight=\"bold\">CONTOSO</text></svg>", "Description": "The Contoso Security Alerts solution provides real-time security alert ingestion from your Contoso application into Microsoft Sentinel using the Codeless Connector Framework (CCF) Push pattern. Your application pushes alert severity, event types, user information, and network details directly to Azure Monitor for analysis, alerting, and visualization.", "Data Connectors": [ "Data Connectors/ContosoSecurityAlerts_ccf/connectorDefinition.json" ], "BasePath": "C:\\GitHub\\Azure-Sentinel\\Solutions\\ContosoSecurityAlerts", "Version": "1.0.0", "Metadata": "SolutionMetadata.json", "TemplateSpec": true, "Is1PConnector": false }Important
关键字段要求:
-
BasePath:更新为 Azure-Sentinel 存储库的实际本地路径 -
Metadata:必须引用SolutionMetadata.json(在步骤 6B 中创建) -
Version:语义版本控制,例如3.0.0 -
TemplateSpec:内容中心解决方案始终true -
Is1Pconnector:将其设置为false用于合作伙伴/自定义连接器
-
在解决方案根目录中创建 SolutionMetadata.json
在 ContosoSecurityAlerts 文件夹中,在解决方案根目录(与数据文件夹相同的级别)创建 SolutionMetadata.json:
{ "publisherId": "contoso", "offerId": "contoso-security-alerts", "firstPublishDate": "2025-01-01", "lastPublishDate": "2025-01-01", "providers": [ "Contoso" ], "categories": { "domains": [ "Security - Threat Protection", "Security - Cloud Security" ] }, "support": { "name": "Contoso Corporation", "tier": "Partner", "link": "https://www.contoso.com/support" } }您需要用于内容中心打包的 SolutionMetadata.json 文件。
- 打包工具需要此文件位于解决方案根目录
- 它包含用于内容中心分发的市场元数据
在解决方案根目录中创建 ReleaseNotes.md
版本 修改日期(DD-MM-YYYY) 更改历史记录 3.0.0 DD-MM-YYYY 示例解决方案
验证清单
在继续执行下一步之前,请验证:
- 文件夹名称没有空格,例如
ContosoSecurityAlerts -
NameSolution_ContosoSecurityAlerts.json 中的字段与文件夹名称完全匹配 -
SolutionMetadata.json存在于解决方案根目录(不在数据文件夹中) -
BasePath指向您本地 Azure-Sentinel 代码库的实际路径 -
Metadata字段引用“SolutionMetadata.json” - 两个文件中的
publisherId和offerId必须匹配
验证解决方案结构
确认文件夹结构与所需布局匹配,并确保所有文件都已就位。
Azure-Sentinel/ └── Solutions/ └── ContosoSecurityAlerts/ Folder name (no spaces) ├── Data/ │ └── Solution_ContosoSecurityAlerts.json From Step 7A ├── SolutionMetadata.json From Step 7B (at root) ├── ReleaseNotes.md From Step 7C └── Data Connectors/ └── ContosoSecurityAlerts_ccf/ ├── table.json From Step 3 ├── DCR.json From Step 4 ├── connectorDefinition.json From Step 5 └── dataConnector.json From Step 6打包解决方案
使用 createSolutionV3.ps1 打包工具生成 ARM 部署模板。
# Navigate to the packaging tools directory (from Azure-Sentinel repository root) cd Tools/Create-Azure-Sentinel-Solution/V3 # Run the packaging tool # When prompted for "Enter solution data folder path:", provide: # <REPO_ROOT>Solutions/ContosoSecurityAlerts/Data (Note! This path is absolute) .\createSolutionV3.ps1脚本将自动执行:
- 验证“数据”文件夹结构是否正确
- 处理连接器构件
预期输出:
打包脚本显示 arm-ttk (Azure 资源管理器 Template Toolkit) 验证失败。 CCF 推送连接器的此故障是预期的,也是正常的。
Failed arm-ttk (Test-AzTemplate): Package Failed arm-ttk (Test-AzTemplate) on solutions: Package ************Validating if Package Json files are valid or not*************** File Solutions\ContosoSecurityAlerts\Package\createUiDefinition.json is a valid Json file! File Solutions\ContosoSecurityAlerts\Package\mainTemplate.json is a valid Json file! File Solutions\ContosoSecurityAlerts\Package\testParameters.json is a valid Json file!如果看到确认有效文件的三条 JSON 验证消息,则打包成功。 可以忽略 CCF 推送连接器的
arm-ttk失败提示。有关详细信息,请参阅 Azure-Sentinel 解决方案工具文档。
部署解决方案包
将生成的 ARM 模板(包/mainTemplate.json)部署到 Azure 订阅。
- 在 Azure 门户中,搜索“部署自定义模板”
- 在编辑器中选择“生成自己的模板”
- 选择“加载文件”,然后从输出文件夹中进行选择
Package/mainTemplate.json - 选择“保存”
- 填写部署参数:
- 订阅: Azure 订阅
- 资源组: 包含 Sentinel 工作区的资源组
- 地区: 与 Sentinel 工作区相同的区域
- 工作区: Log Analytics 工作区名称
- 选择 “审阅 + 创建”,然后选择 “创建”
此部署使连接器在 Microsoft Sentinel 数据连接器库中可用。
有关详细步骤,请参阅[快速入门:使用 Azure 门户创建和部署 ARM 模板](/azure/azure-resource-manager/templates/ quickstart-create-templates-use-the-portal)。
启用数据连接器
部署解决方案包后,使连接器能够预配资源和生成凭据。
- 在 Azure 门户中,导航到 Microsoft Sentinel 工作区
- 转到 配置>数据连接器
- 搜索并选择“Contoso 安全警报(推送)”
- 选择打开连接器页
- 选择 “部署 Contoso 安全警报连接器 ”按钮
- 等待部署完成(创建自定义表、DCR、DCE、带凭据的 Entra 应用程序)
- 复制显示的连接详细信息:
- 租户 ID
- 应用程序(客户端)ID
- 客户端密码
- 数据收集终结点 URI
- 数据收集规则不可变标识符
- 流名称:
Custom-ContosoSecurityAlerts
配置应用程序
使用步骤 10 中的凭据和资源详细信息更新应用程序代码。 该代码使用 OAuth 2.0 客户端凭据流通过 Azure Monitor 进行身份验证。
注意
保护凭据:从不直接在应用程序代码中硬编码凭据(租户 ID、应用程序 ID、客户端密码),或将其提交到源代码管理。 使用安全凭据存储解决方案,例如:
- 用于生产应用程序的 Azure 密钥保管库
- 环境变量或配置文件(从源代码管理中排除)
- 适用场景下的托管标识
- 静态加密凭据的密钥管理工具
Python 示例应用程序代码:
以下示例使用占位符值,如 <Your-Tenant-ID>。 将这些值替换为对实际凭据的安全引用。
import requests import json from datetime import datetime, timezone # Connection details from Step 11 tenant_id = "<Your-Tenant-ID>" app_id = "<Your-Application-ID>" app_secret = "<Your-Client-Secret>" dce_uri = "<Your-DCE-URI>" dcr_immutable_id = "<Your-DCR-Immutable-ID>" stream_name = "Custom-ContosoSecurityAlerts" **Get OAuth token** token_url = f"https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token" token_data = { "client_id": app_id, "scope": "https://monitor.azure.com//.default", "client_secret": app_secret, "grant_type": "client_credentials" } token_response = requests.post(token_url, data=token_data) access_token = token_response.json()["access_token"] # Create event matching your table schema event = [{ "TimeGenerated": datetime.now(timezone.utc).isoformat(), "EventSeverity": "Medium", "EventType": "LoginAlert", "UserName": "alice@contoso.com", "SourceIP": "192.168.1.100", "DeviceId": "device-12345", "AlertMessage": "Multiple failed login attempts detected" }] # Send to Sentinel headers = { "Authorization": f"Bearer {access_token}", "Content-Type": "application/json" } upload_url = f"{dce_uri}/dataCollectionRules/{dcr_immutable_id}/streams/{stream_name}?api-version=2023-01-01" response = requests.post(upload_url, headers=headers, json=event) print(f"Status: {response.status_code}") print("Security alert sent to Sentinel!")查询数据
发送警报后,在 Sentinel 中查询。 首次数据引入需等待 5-10 分钟。
// View all recent alerts ContosoSecurityAlerts_CL | where TimeGenerated > ago(1h) | order by TimeGenerated desc // High severity alerts ContosoSecurityAlerts_CL | where EventSeverity == "High" | project TimeGenerated, EventType, UserName, SourceIP, AlertMessage // Alert summary by severity ContosoSecurityAlerts_CL | where TimeGenerated > ago(7d) | summarize Count=count() by EventSeverity
相关内容
现在您已了解 CCF 推送连接器,请按照以下步骤进行操作:
- 设计数据架构 - 标识要发送的事件及其字段。
- 创建连接器项目 - 生成四个 JSON 文件(表、DCR、连接器定义、数据连接器)。
- 组织解决方案结构 - 设置具有正确命名的数据/和数据连接器/文件夹。
-
打包解决方案 - 用于
createSolutionV3.ps1生成部署模板。 - 部署和测试 - 部署到 Sentinel 工作区并验证数据流。
- 与应用程序集成 - 添加代码以实时发送事件。
- 创建警报和工作簿 - 使用数据进行安全监视。
其他资源
CCF 文档
- 创建无代码连接器(CCF 拉取)- 基于轮询的连接器。
- 数据连接器定义 API 参考 - UI 配置指南。
- 数据连接器连接规则参考 - 轮询连接器的连接规则。
Azure Monitor 和数据收集
- Azure Monitor 日志引入 API - 用于发送数据的核心 API。
- Azure Monitor 中的数据收集规则 - 了解 DCR。
- 数据收集规则的结构 - DCR 结构详细信息。
- Azure Monitor 中的数据收集终结点 - DCE 配置。
- 教程:使用日志引入 API 将数据发送到 Azure Monitor 日志 - 分步教程。
- 创建自定义表 - 自定义表创建指南。
身份验证和安全性
- OAuth 2.0 客户端凭据流 - 应用到服务身份验证的工作原理。
- Microsoft 标识平台访问令牌 - 了解 OAuth 令牌。
- 在 Microsoft Entra ID 中注册应用程序 - 如何在 Microsoft Entra ID 中注册应用程序。
- Azure AD 应用程序注册的最佳做法 - Entra 应用安全性。
- 使用 Azure 资源管理器 (ARM) 模板分配 Azure 角色 - 使用模板分配角色。
- ARM 模板安全建议 - 保护部署模板。
- Azure Monitor 服务限制 - 速率限制和配额。
Microsoft Sentinel
- 关于Microsoft Sentinel 解决方案 - 将连接器打包为解决方案。
- 监视数据连接器的运行状况 - 运行状况监视。
- 数据连接器的 ARM 模板参考 - 完整的 API 参考。
获取帮助
- 对于构建集成的 ISV 合作伙伴,请联系:azuresentinelpartner@microsoft.com
- 有关技术问题,请使用带有标记“azure-sentinel” 的 Microsoft Q&A 。