你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

为 Microsoft Sentinel 创建无代码连接器(公共预览版)

无代码连接器平台 (CCP) 为合作伙伴、高级用户和开发人员提供创建自定义连接器以将数据引入 Microsoft Sentinel 的功能。

使用 CCP 创建的连接器完全是 SaaS,对服务安装没有任何要求。 其中还包括运行状况监视以及对 Microsoft Sentinel 的完全支持。

重要

无代码连接器平台 (CCP) 目前以预览版提供。 Azure 预览版补充条款包含适用于 beta 版、预览版或其他尚未正式发布的 Azure 功能的其他法律条款。

使用以下步骤创建 CCP 连接器并将数据源连接到 Microsoft Sentinel

  • 生成数据连接器
  • 创建 ARM 模板
  • 部署连接器
  • 将 Microsoft Sentinel 连接到数据源并开始引入数据

本文介绍如何完成每个步骤,并提供在此过程中生成的示例无代码连接器

此 CCP 与之前的版本有何区别?

CCP 的最初版本于 2022 年 1 月宣布推出。 在这之后,我们对该平台进行了改进,并且不再推荐使用旧版本。 这个新版的 CCP 主要具有以下改进:

  1. 更好地支持各种身份验证和分页类型。

  2. 支持标准数据收集规则 (DCR)。

  3. 无代码连接器的用户界面和连接配置部分现在是分开的。 这使得可创建具有多个连接的连接器,而这在以前是不可能的。

先决条件

在生成连接器之前,请了解数据源以及 Microsoft Sentinel 需要如何连接。

  1. 数据收集终结点 (DCE)

    DCR 需要 DCE。 每个 Log Analytics 工作区 DCR 部署仅创建一个 DCE。 为 Microsoft Sentinel 工作区部署的每个 DCR 都使用相同的 DCE。 有关如何创建终结点或是否需要新终结点的详细信息,请参阅 Azure Monitor 中的数据收集终结点

  2. 输出表的架构。

    请务必了解数据流的形状以及要在输出表中包括的字段。 引用数据源文档或分析足够的输出示例。

研究以下组件并验证数据连接器 API 参考中对它们的支持:

  1. 对数据源的 HTTP 请求和响应结构

  2. 数据源所需的身份验证。
    例如,如果数据源需要使用证书签名的令牌,则数据连接器 API 参考将指定不支持证书身份验证。

  3. 数据源的分页选项

我们还建议使用 Postman 之类的工具来验证数据连接器组件。 有关详细信息,请参阅将 Postman 与 Microsoft Graph API 配合使用

生成数据连接器

生成 CCP 数据连接器需要 4 个组件。

  1. 输出表定义
  2. 数据收集规则 (DCR)
  3. 数据连接器用户界面
  4. 数据连接器连接规则

每个组件都有一个部分,详细说明要创建和验证的过程。 从每个组件获取 JSON,以获取 ARM 模板的最终打包。

输出表定义

提示

如果数据仅引入到标准 Log Analytics 表,请跳过此步骤。 标准表的示例包括 CommonSecurityLog 和 ASimDnsActivityLogs。 若要详细了解受支持的标准数据类型的完整列表,请参阅自定义数据连接器的数据转换支持

如果数据源不符合标准表的架构,则有两种选择:

  • 为所有数据创建自定义表
  • 为某些数据创建自定义表,并将一致性数据拆分为标准表

使用 Log Analytics UI 作为直接方法来创建自定义表和 DCR。 如果使用表 API 或其他编程方法创建自定义表,请向表名中手动添加 _CL 后缀。 有关详细信息,请参阅创建自定义表

有关将数据拆分为多个表的详细信息,请参阅示例数据,以及为该数据创建的示例自定义表

数据收集规则

数据收集规则 (DCR) 定义 Azure Monitor 中的数据收集过程。 DCR 指定应收集哪些数据、如何转换该数据以及将该数据发送到哪里。

  • 每个数据连接器只部署一个 DCR。
  • DCR 必须在同一区域中具有相应的 DCE。
  • 部署 CCP 数据连接器时,如果 DCR 尚不存在,则会创建一个。

请参阅以下文章中有关 DCR 的最新信息:

有关演示如何创建 DCE 的教程(包括使用示例数据创建自定义表和 DCR),请参阅教程:使用日志引入 API(Azure 门户)将数据发送到 Azure Monitor 日志。 使用本教程中过程验证数据是否已通过 DCR 正确引入到表中。

若要了解如何创建具有多个数据流的复杂 DCR,请参阅 DCR 示例部分

数据连接器用户界面

此组件呈现 Microsoft Sentinel 数据连接器库中数据连接器的 UI。 每个数据连接器可能只有一个 UI 定义。

使用数据连接器定义 API 生成数据连接器用户界面。 使用数据连接器定义参考作为补充来更详细地解释 API 元素。

注意:

  1. API 轮询连接器的 kind 属性应始终为 Customizable
  2. 由于这是一种 API 轮询连接器,因此请将 connectivityCriteria 类型设置为 hasDataConnectors
  3. 示例 instructionsSteps 包含 ConnectionToggleButton 类型的按钮。 此按钮用于根据指定的连接参数触发数据连接器规则的部署。

使用 Postman 调用数据连接器定义 API 来创建数据连接器 UI,以便在数据连接器库中对其进行验证。

若要从示例中学习,请参阅数据连接器定义参考示例部分

数据连接规则

本部分定义连接规则,包括:

  • 轮询
  • authentication
  • paging

有关生成本部分的详细信息,请参阅数据连接器连接规则参考

若要从示例中学习,请参阅数据连接器连接规则参考示例

使用 Postman 调用数据连接器 API 来创建合并连接规则和以前的组件的数据连接器。 验证连接器是否已在 UI 中连接。

保护机密输入

无论 CCP 数据连接器使用哪种身份验证,都请按照以下步骤确保机密信息的安全。 目标是将凭据从 ARM 模板传递到 CCP,而不在部署历史记录中保留可读的机密对象。

创建标签

数据连接器定义创建一个 UI 元素来提示输入安全凭据。 例如,如果数据连接器使用 OAuth 向日志源进行身份验证,则数据连接器定义部分在说明中包含 OAuthForm 类型。 这会设置 ARM 模板以提示输入凭据。

"instructions": [
    {
        "type": "OAuthForm",
        "parameters": {
        "UsernameLabel": "Username",
        "PasswordLabel": "Password",
        "connectButtonLabel": "Connect",
        "disconnectButtonLabel": "Disconnect"
        }
    }
],

存储机密输入

ARM 部署模板有一个部分让管理员能够部署数据连接器来输入密码。 使用 securestring 将机密信息保存在部署后不可读的对象中。 有关详细信息,请参阅关于参数的安全建议

"mainTemplate": {
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "[variables('dataConnectorCCPVersion')]",
    "parameters": {
        "Username": {
            "type": "securestring",
            "minLength": 1,
            "metadata": {
                "description": "Enter the username to connect to your data source."
        },
        "Password": {
            "type": "securestring",
            "minLength": 1,
            "metadata": {
                "description": "Enter the API key, client secret or password required to connect."
            }
        },
    // more deployment template information
    }
}

使用 securestring 对象

最后,CCP 利用数据连接器部分中的凭据对象。

"auth": {
    "type": "OAuth2",
    "ClientSecret": "[[parameters('Password')]",
    "ClientId": "[[parameters('Username')]",
    "GrantType": "client_credentials",
    "TokenEndpoint": "https://api.contoso.com/oauth/token",
    "TokenEndpointHeaders": {
        "Content-Type": "application/x-www-form-urlencoded"
    },
    "TokenEndpointQueryParameters": {
        "grant_type": "client_credentials"
    }
},

注意

凭据对象的语法看起来很奇怪 - "ClientSecret": "[[parameters('Password')]",,这不是拼写错误! 若要创建同时使用参数的部署模板,需要通过额外的起始 [ 对该部分的参数进行转义。 这样,参数可以根据用户与连接器的交互来分配值。

有关详细信息,请参阅模板表达式转义字符

创建部署模板

使用示例模板作为指导,手动打包 Azure 资源管理 (ARM) 模板。

除了示例模板,Microsoft Sentinel 内容中心提供且已发布的解决方案使用 CCP 作为其数据连接器。 查看以下解决方案,了解更多有关如何将组件组合到 ARM 模板的示例。

部署连接器

将无代码连接器部署为自定义模板。

提示

删除在前面的步骤中创建的资源。 DCR 和自定义表随部署一起创建。 如果在部署之前不删除这些资源,则验证模板会更加困难。

  1. 复制 ARM 部署模板的内容。
  2. 按照快速入门:使用 Azure 门户创建和部署 ARM 模板文章中的编辑和部署模板说明进行操作。

维护日志记录源的网络隔离

如果日志记录源需要网络隔离,请配置 CCP 使用的公共 IP 地址的允许列表。

Azure 虚拟网络使用服务标记来定义网络访问控制。 对于 CCP 来说,该服务标记是一个水肺

要查找与水肺服务标记关联的当前 IP 范围,请参阅使用服务标记发现 API

验证无代码连接器

在数据连接器库中查看无代码连接器。 打开数据连接器并填写连接所需的任何身份验证参数。 成功连接后,将创建 DCR 和自定义表。 查看资源组中的 DCR 资源以及 Log Analytics 工作区中的任何自定义表。

注意

最多可能需要 30 分钟才能看到数据开始引入。

示例

以下示例部分介绍了生成无代码连接器的每个步骤。

为了演示引入到多个表的复杂数据源,本示例采用了输出表架构和具有多个输出流的 DCR。 DCR 示例将这些内容及其 KQL 转换组合在一起。 数据连接器 UI 定义和连接规则示例继续来自同一示例数据源。 最后,解决方案模板使用以上所有示例组件来端到端地展示如何创建示例 CCP 数据连接器。

示例数据

数据源在连接到其终结点时返回以下 JSON。

[
        {
        "ts": "3/6/2023 8:15:15 AM",
        "eventType": "Alert",
        "deviceMac": "bc:27:c6:21:1c:70",
        "clientMac": "",
        "srcIp": "10.12.11.106",
        "destIp": "121.93.178.13",
        "protocol": "tcp/ip",
        "priority": "0",
        "message": "This is an alert message"
        },
        {
        "ts": "3/6/2023 8:14:54 AM",
        "eventType": "File",
        "srcIp": "178.175.128.249",
        "destIp": "234.113.125.105",
        "fileType": "MS_EXE",
        "fileSizeBytes": 193688,
        "disposition": "Malicious"
        }
]

此响应包含 Alert 和 File 的 eventType 文件事件将引入规范化标准表 AsimFileEventLogs,而警报事件将引入自定义表。

示例自定义表

有关此表的结构的详细信息,请参阅表 API。 自定义日志表名称后缀应为 _CL

{
"properties": {
    "schema": {
        "name": "ExampleConnectorAlerts_CL",
        "columns": [
        {
          "name": "TimeGenerated",
          "type": "datetime"
        },
        {
          "name": "SourceIP",
          "type": "string"
        },
        {
          "name": "DestIP",
          "type": "string"
        },
        {
          "name": "Message",
          "type": "string"
        },
        {
          "name": "Priority",
          "type": "int"
        }
        ]
      }
    }
}

示例数据收集规则

以下 DCR 使用示例数据源定义单个流 Custom-ExampleConnectorInput,并将输出转换为两个表。

  1. 第一个数据流将 eventType = Alert 定向到自定义 ExampleConnectorAlerts_CL 表。
  2. 第二个数据流将 eventType = File 定向到规范化标准表 ASimFileEventLogs

有关此示例的结构的详细信息,请参阅数据收集规则的结构

若要在测试环境中创建此 DCR,请遵循数据收集规则 API{{double curly braces}} 中的示例元素表示需要便于 Postman 使用的值的变量。 在 ARM 模板中创建此资源时,此处表示的变量将替换为参数。

{
  "location": "{{location}}",
  "properties": {
    "dataCollectionEndpointId": "/subscriptions/{{subscriptionId}}/resourceGroups/{{resourceGroupName}}/providers/Microsoft.Insights/dataCollectionEndpoints/{{dataCollectionEndpointName}}",
    "streamDeclarations": {
      "Custom-ExampleConnectorInput": {
        "columns": [
          {
            "name": "ts",
            "type": "datetime"
          },
          {
            "name": "eventType",
            "type": "string"
          },
          {
            "name": "deviceMac",
            "type": "string"
          },
          {
            "name": "clientMac",
            "type": "string"
          },
          {
            "name": "srcIp",
            "type": "string"
          },
          {
            "name": "destIp",
            "type": "string"
          },
          {
            "name": "protocol",
            "type": "string"
          },
          {
            "name": "priority",
            "type": "string"
          },
          {
            "name": "message",
            "type": "string"
          },
          {
            "name": "fileType",
            "type": "string"
          },
          {
            "name": "fileSizeBytes",
            "type": "int"
          },
          {
            "name": "disposition",
            "type": "string"
          }
        ]
      }
    },
    "destinations": {
      "logAnalytics": [
        {
          "workspaceResourceId": "/subscriptions/{{subscriptionId}}/resourcegroups/{{resourceGroupName}}/providers/microsoft.operationalinsights/workspaces/{{workspaceName}}",
          "name": "{{uniqueFriendlyDestinationName}}"
        }
      ]
    },
    "dataFlows": [
      {
        "streams": [
          "Custom-ExampleConnectorInput"
        ],
        "destinations": [
          "{{uniqueFriendlyDestinationName}}"
        ],
        "transformKql": "source | where eventType == \"Alert\" | project TimeGenerated = ts, SourceIP = srcIp, DestIP = destIp, Message = message, Priority = priority \n",
        "outputStream": "Custom-ExampleConnectorAlerts_CL"
      },
      {
        "streams": [
          "Custom-ExampleConnectorInput"
        ],
        "destinations": [
          "{{uniqueFriendlyDestinationName}}"
        ],
        "transformKql": "source | where eventType == \"File\" | project-rename TimeGenerated = ts, EventOriginalType = eventType, SrcIpAddr = srcIp, DstIpAddr = destIp, FileContentType = fileType, FileSize = fileSizeBytes, EventOriginalSeverity = disposition \n",
        "outputStream": "Microsoft-ASimFileEventLogs"
      }
    ]
  }
}

示例数据连接器 UI 定义

此示例位于数据连接器定义参考中。

示例数据连接器连接规则

此示例位于数据连接器参考中。

ARM 模板示例

使用以下结构生成 ARM 部署模板,其中包括生成 CCP 数据连接器所需的 4 部分 JSON 组件:

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {},
    "variables": {},
    "resources": [],
}

使用支持 JSON 的编辑器(例如 Visual Code)将各个部分拼接在一起,以最大程度地减少逗号、右括号和圆括号等语法错误。

为了指导模板生成过程,注释会显示在元数据 description 中或内嵌 // 注释符号。 有关详细信息,请参阅 ARM 模板最佳做法 - 注释

请考虑使用 ARM 模板测试工具包 (arm-ttk) 来验证生成的模板。 有关详细信息,请参阅 arm-ttk

示例 ARM 模板 - 参数

有关详细信息,请参阅 ARM 模板中的参数

警告

对资源部署后可读对象中的所有密码和机密使用 securestring。 有关详细信息,请参阅 保护机密输入有关参数的安全建议

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "location": {
            "type": "string",
            "minLength": 1,
            "defaultValue": "[resourceGroup().location]",
            "metadata": {
                "description": "Not used, but needed to pass the arm-ttk test, 'Location-Should-Not-Be-Hardcoded'. Instead the `workspace-location` derived from the log analytics workspace is used."
            }
        },
        "workspace-location": {
            "type": "string",
            "defaultValue": "",
            "metadata": {
                "description": "[concat('Region to deploy solution resources -- separate from location selection',parameters('location'))]"
            }
        },
        "subscription": {
            "defaultValue": "[last(split(subscription().id, '/'))]",
            "type": "string",
            "metadata": {
                "description": "subscription id where Microsoft Sentinel is configured"
            }
        },
        "resourceGroupName": {
            "defaultValue": "[resourceGroup().name]",
            "type": "string",
            "metadata": {
                "description": "resource group name where Microsoft Sentinel is configured"
            }
        },
        "workspace": {
            "defaultValue": "",
            "type": "string",
            "metadata": {
                "description": "the log analytics workspace enabled for Microsoft Sentinel"
            }
        }
    },
    // Next is the variables section here
}

示例 ARM 模板 - 变量

这些推荐的变量有助于简化模板。 根据需要酌情使用。 有关详细信息,请参阅 ARM 模板中的变量

    "variables": {
        "workspaceResourceId": "[resourceId('microsoft.OperationalInsights/Workspaces', parameters('workspace'))]",
        "_solutionName": "Solution name", // Enter your solution name 
        "_solutionVersion": "3.0.0", // must be 3.0.0 or above
        "_solutionAuthor": "Contoso", // Enter the name of the author
        "_packageIcon": "<img src=\"{LogoLink}\" width=\"75px\" height=\"75px\">", // Enter the http link for the logo. NOTE: This field is only recommended for Azure Global Cloud.
        "_solutionId": "azuresentinel.azure-sentinel-solution-azuresentinel.azure-sentinel-MySolution", // Enter a name for your solution with this format but exchange the 'MySolution' portion
        "dataConnectorVersionConnectorDefinition": "1.0.0",
        "dataConnectorVersionConnections": "1.0.0",
        "_solutionTier": "Community", // This designates the appropriate support - all custom data connectors are "Community"
        "_dataConnectorContentIdConnectorDefinition": "MySolutionTemplateConnectorDefinition", // Enter a name for the connector
        "dataConnectorTemplateNameConnectorDefinition": "[concat(parameters('workspace'),'-dc-',uniquestring(variables('_dataConnectorContentIdConnectorDefinition')))]",
        "_dataConnectorContentIdConnections": "MySolutionTemplateConnections", // Enter a name for the connections this connector makes
        "dataConnectorTemplateNameConnections": "[concat(parameters('workspace'),'-dc-',uniquestring(variables('_dataConnectorContentIdConnections')))]",
        "_logAnalyticsTableId1": "ExampleConnectorAlerts_CL" // Enter the custom table name - not needed if you are ingesting data into standard tables
		// Enter more variables as needed "":""
    },
    // Next is the resources sections here

示例 ARM 模板 - 资源

此模板指南中有 5 个 ARM 部署资源,其中包含 4 个 CCP 数据连接器生成组件。

  1. contentTemplates(父级资源)
  2. dataConnectorDefinitions - 有关详细信息,请参阅数据连接器用户界面
  3. metadata
  4. contentTemplates
  5. contentPackages
    "resources": [
        // resource section 1 - contentTemplates
        {
            "type": "Microsoft.OperationalInsights/workspaces/providers/contentTemplates",
            "apiVersion": "2023-04-01-preview",
            "name": "[concat(parameters('workspace'),'/Microsoft.SecurityInsights/', variables('dataConnectorTemplateNameConnectorDefinition'), variables('dataConnectorVersionConnectorDefinition'))]",
            "location": "[parameters('workspace-location')]",
            "dependsOn": [
                "[extensionResourceId(resourceId('Microsoft.OperationalInsights/workspaces', parameters('workspace')), 'Microsoft.SecurityInsights/contentPackages', variables('_solutionId'))]"
            ],
            "properties": {
                "contentId": "[variables('_dataConnectorContentIdConnectorDefinition')]",
                "displayName": "[concat(variables('_solutionName'), variables('dataConnectorTemplateNameConnectorDefinition'))]",
                "contentKind": "DataConnector",
                "mainTemplate": {
                    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
                    "contentVersion": "[variables('dataConnectorVersionConnectorDefinition')]",
                    "parameters": {},
                    "variables": {},
                    "resources": [
                        {
                            "name": "[concat(parameters('workspace'),'/Microsoft.SecurityInsights/',concat('DataConnector-', variables('_dataConnectorContentIdConnectorDefinition')))]",
                            "apiVersion": "2022-01-01-preview",
                            "type": "Microsoft.OperationalInsights/workspaces/providers/metadata",
                            "properties": {
                                "parentId": "[extensionResourceId(resourceId('Microsoft.OperationalInsights/workspaces', parameters('workspace')), 'Microsoft.SecurityInsights/dataConnectorDefinitions', variables('_dataConnectorContentIdConnectorDefinition'))]",
                                "contentId": "[variables('_dataConnectorContentIdConnectorDefinition')]",
                                "kind": "DataConnector",
                                "version": "[variables('dataConnectorVersionConnectorDefinition')]",
                                "source": {
                                    "sourceId": "[variables('_solutionId')]",
                                    "name": "[variables('_solutionName')]",
                                    "kind": "Solution"
                                },
                                "author": {
                                    "name": "[variables('_solutionAuthor')]"
                                },
                                "support": {
                                    "name": "[variables('_solutionAuthor')]",
                                    "tier": "[variables('_solutionTier')]"
                                },
                                "dependencies": {
                                    "criteria": [
                                        {
                                            "version": "[variables('dataConnectorVersionConnections')]",
                                            "contentId": "[variables('_dataConnectorContentIdConnections')]",
                                            "kind": "ResourcesDataConnector"
                                        }
                                    ]
                                }
                            }
                        },
                        {
                            "name": "MyDCRV1", // Enter your DCR name
                            "apiVersion": "2021-09-01-preview",
                            "type": "Microsoft.Insights/dataCollectionRules",
                            "location": "[parameters('workspace-location')]",
                            "kind": null,
                            "properties": 
							{ 
                                // Enter your DCR properties here.
                                //  Consider using these variables:
                                //  "dataCollectionEndpointId": "[concat('/subscriptions/',parameters('subscription'),'/resourceGroups/',parameters('resourceGroupName'),'/providers/Microsoft.Insights/dataCollectionEndpoints/',parameters('workspace'))]",
                                //  "workspaceResourceId": "[variables('workspaceResourceId')]",
							}
                        },
                        {
                            "name": "[variables('_logAnalyticsTableId1')]",
                            "apiVersion": "2022-10-01",
                            "type": "Microsoft.OperationalInsights/workspaces/tables",
                            "location": "[parameters('workspace-location')]",
                            "kind": null,
                            "properties": 
							{
								// Enter your log analytics table schema here. 
                                //  Consider using this variable for the name property:
                                //  "name": "[variables('_logAnalyticsTableId1')]",
							}			
                        }
						// Enter more tables if needed.
                    ]
                },
                "packageKind": "Solution",
                "packageVersion": "[variables('_solutionVersion')]",
                "packageName": "[variables('_solutionName')]",
                "contentProductId": "[concat(substring(variables('_solutionId'), 0, 50),'-','dc','-', uniqueString(concat(variables('_solutionId'),'-','DataConnector','-',variables('_dataConnectorContentIdConnectorDefinition'),'-', variables('dataConnectorVersionConnectorDefinition'))))]",
                "packageId": "[variables('_solutionId')]",
                "contentSchemaVersion": "3.0.0",
                "version": "[variables('_solutionVersion')]"
            }
        },
        // resource 2 section here
        // resource section 2 - dataConnectorDefinitions
        {
            "name": "[concat(parameters('workspace'),'/Microsoft.SecurityInsights/',variables('_dataConnectorContentIdConnectorDefinition'))]",
            "apiVersion": "2022-09-01-preview",
            "type": "Microsoft.OperationalInsights/workspaces/providers/dataConnectorDefinitions",
            "location": "[parameters('workspace-location')]",
            "kind": "Customizable",
            "properties": 
			{
				//Enter your data connector definition properties here
				//"connectorUiConfig": {
				//	"graphQueriesTableName": "[variables('_logAnalyticsTableId1')]",
                //}, 
			}
        },
        // resource 3 section here
        // resource section 3 - metadata
        {
            "name": "[concat(parameters('workspace'),'/Microsoft.SecurityInsights/',concat('DataConnector-', variables('_dataConnectorContentIdConnectorDefinition')))]",
            "apiVersion": "2022-01-01-preview",
            "type": "Microsoft.OperationalInsights/workspaces/providers/metadata",
            "properties": {
                "parentId": "[extensionResourceId(resourceId('Microsoft.OperationalInsights/workspaces', parameters('workspace')), 'Microsoft.SecurityInsights/dataConnectorDefinitions', variables('_dataConnectorContentIdConnectorDefinition'))]",
                "contentId": "[variables('_dataConnectorContentIdConnectorDefinition')]",
                "kind": "DataConnector",
                "version": "[variables('dataConnectorVersionConnectorDefinition')]",
                "source": {
                    "sourceId": "[variables('_solutionId')]",
                    "name": "[variables('_solutionName')]",
                    "kind": "Solution"
                },
                "author": {
                    "name": "[variables('_solutionAuthor')]"
                },
                "support": {
                    "name": "[variables('_solutionAuthor')]",
                    "tier": "[variables('_solutionTier')]"
                },
                "dependencies": {
                    "criteria": [
                        {
                            "version": "[variables('dataConnectorVersionConnections')]",
                            "contentId": "[variables('_dataConnectorContentIdConnections')]",
                            "kind": "ResourcesDataConnector"
                        }
                    ]
                }
            }
        },
        // resource 4 section here
        // resource section 4 - contentTemplates
        {
            "type": "Microsoft.OperationalInsights/workspaces/providers/contentTemplates",
            "apiVersion": "2023-04-01-preview",
            "name": "[concat(parameters('workspace'),'/Microsoft.SecurityInsights/', variables('dataConnectorTemplateNameConnections'), variables('dataConnectorVersionConnections'))]",
            "location": "[parameters('workspace-location')]",
            "dependsOn": [
                "[extensionResourceId(resourceId('Microsoft.OperationalInsights/workspaces', parameters('workspace')), 'Microsoft.SecurityInsights/contentPackages', variables('_solutionId'))]"
            ],
            "properties": {
                "contentId": "[variables('_dataConnectorContentIdConnections')]",
                "displayName": "[concat(variables('_solutionName'), variables('dataConnectorTemplateNameConnections'))]",
                "contentKind": "ResourcesDataConnector",
                "mainTemplate": {
                    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
                    "contentVersion": "[variables('dataConnectorVersionConnections')]",
                    "parameters":
                    // These parameters are used by the data connector primarily as properties for the administrator to enter in the UI when configuring the connector
					{
                        "connectorDefinitionName": {
                            "defaultValue": "connectorDefinitionName",
                            "type": "string",
                            "minLength": 1
                        },
                        "workspace": {
                            "defaultValue": "[parameters('workspace')]",
                            "type": "string"
                        },
                        "dcrConfig": {
                            "defaultValue": {
                                "dataCollectionEndpoint": "data collection Endpoint",
                                "dataCollectionRuleImmutableId": "data collection rule immutableId"
                            },
                            "type": "object"
                        }
						// Enter additional parameters, for example:
						//"domainname": {
                        //    "defaultValue": "domain name",
                        //    "type": "string",
                        //    "minLength": 1
                        //},
                        //"apikey": {
                        //    "defaultValue": "",
                        //    "type": "securestring",
                        //    "minLength": 1
                        //}
                    },
                    "variables": {
                        "_dataConnectorContentIdConnections": "[variables('_dataConnectorContentIdConnections')]"
                    },
                    "resources": [
                        {
                            "name": "[concat(parameters('workspace'),'/Microsoft.SecurityInsights/',concat('DataConnector-', variables('_dataConnectorContentIdConnections')))]",
                            "apiVersion": "2022-01-01-preview",
                            "type": "Microsoft.OperationalInsights/workspaces/providers/metadata",
                            "properties": {
                                "parentId": "[extensionResourceId(resourceId('Microsoft.OperationalInsights/workspaces', parameters('workspace')), 'Microsoft.SecurityInsights/dataConnectors', variables('_dataConnectorContentIdConnections'))]",
                                "contentId": "[variables('_dataConnectorContentIdConnections')]",
                                "kind": "ResourcesDataConnector",
                                "version": "[variables('dataConnectorVersionConnections')]",
                                "source": {
                                    "sourceId": "[variables('_solutionId')]",
                                    "name": "[variables('_solutionName')]",
                                    "kind": "Solution"
                                },
                                "author": {
                                    "name": "[variables('_solutionAuthor')]"
                                },
                                "support": {
                                    "name": "[variables('_solutionAuthor')]",
                                    "tier": "[variables('_solutionTier')]"
                                }
                            }
                        },
                        {
                            "name": "[concat(parameters('workspace'),'/Microsoft.SecurityInsights/', 'MyDataConnector')]", // Replace the last part of the name with your data connector name
                            //  To create several connections using this template, make the name dynamic. For example, use the 'concat' function to add the connector name with a GUID using the 'guid' function.
                            "apiVersion": "2022-12-01-preview",
                            "type": "Microsoft.OperationalInsights/workspaces/providers/dataConnectors",
                            "location": "[parameters('workspace-location')]",
                            "kind": "RestApiPoller",
                            "properties": 
							{
								// Enter your data connector properties here. If you want to use UI parameters remember to escape the parameter like this: "[[parameters('paramName')]"
								//  Use parameters as needed. For example:	
                                // "dataType": "My product security event API",
                                // "response": {
                                //   "eventsJsonPaths": [
                                //        "$"
                                //    ],
                                //    "format": "json"
                                // },
                                // "paging": {
                                //    "pagingType": "LinkHeader"
                                // },
                                // "connectorDefinitionName": "[[parameters('connectorDefinitionName')]",
                                // "auth": {
                                //   "apiKeyName": "Authorization",
                                //    "ApiKey": "[[parameters('apikey')]",
                                //    "apiKeyIdentifier": "SSWS",
                                //    "type": "APIKey"
                                //} ,
                                // "request": {
                                //   "apiEndpoint": "[[concat('https://',parameters('domainname'),'/api/v1/logs')]",
                                //    "rateLimitQPS": 10,
                                //   "queryWindowInMin": 5,
                                //   "httpMethod": "GET",
                                //    "retryCount": 3,
                                //    "timeoutInSeconds": 60,
                                //    "headers": {
                                //        "Accept": "application/json",
                                //        "User-Agent": "My-Data-Source"
                                //    },
                                //    "startTimeAttributeName": "since",
								//    "endTimeAttributeName": "until"		     
                                // },
                                // "dcrConfig": {
                                //    "dataCollectionEndpoint": "[[parameters('dcrConfig').dataCollectionEndpoint]",
                                //    "dataCollectionRuleImmutableId": "[[parameters('dcrConfig').dataCollectionRuleImmutableId]",
                                //    "streamName": "Custom-ExampleConnectorAlerts_CL" //This input stream should be the same as the inputStream property configured for the DataCollectionRule 
                                // },
                                // "isActive": true
                            }
                        }
                    ]
                },
                "packageKind": "Solution",
                "packageVersion": "[variables('_solutionVersion')]",
                "packageName": "[variables('_solutionName')]",
                "contentProductId": "[concat(substring(variables('_solutionId'), 0, 50),'-','rdc','-', uniqueString(concat(variables('_solutionId'),'-','ResourcesDataConnector','-',variables('_dataConnectorContentIdConnections'),'-', variables('dataConnectorVersionConnections'))))]",
                "packageId": "[variables('_solutionId')]",
                "contentSchemaVersion": "3.0.0",
                "version": "[variables('_solutionVersion')]"
            }
        },
        // resource 5 section here
        // resource section 5 - contentPackages
        {
            "type": "Microsoft.OperationalInsights/workspaces/providers/contentPackages",
            "name": "[concat(parameters('workspace'),'/Microsoft.SecurityInsights/', variables('_solutionId'))]",
            "location": "[parameters('workspace-location')]",
            "apiVersion": "2023-04-01-preview",
            "properties": {
                "version": "[variables('_solutionVersion')]",
                "kind": "Solution",
                "contentSchemaVersion": "3.0.0",
                "contentId": "[variables('_solutionId')]",
                "source": {
                    "kind": "Solution",
                    "name": "[variables('_solutionName')]",
                    "sourceId": "[variables('_solutionId')]"
                },
                "author": {
                    "name": "[variables('_solutionAuthor')]"
                },
                "support": {
                    "name": "[variables('_solutionAuthor')]"
                },
                "dependencies": {
                    "operator": "AND",
                    "criteria": [
                        {
                            "kind": "DataConnector",
                            "contentId": "[variables('dataConnectorVersionConnectorDefinition')]",
                            "version": "[variables('_dataConnectorContentIdConnectorDefinition')]"
                        }
                    ]
                },
                "firstPublishDate": "2023-12-05",
                "providers": [
                    "[variables('_solutionAuthor')]"
                ],
                "contentKind": "Solution",
                "packageId": "[variables('_solutionId')]",
                "contentProductId": "[concat(substring(variables('_solutionId'), 0, 50),'-','sl','-', uniqueString(concat(variables('_solutionId'),'-','Solution','-',variables('_solutionId'),'-', variables('_solutionVersion'))))]",
                "displayName": "[variables('_solutionName')]",
                "publisherDisplayName": "[variables('_solutionId')]",
                "descriptionHtml": "test",
                "icon": "[variables('_packageIcon')]"
            }
        }
        // that's the end!
    ]
}

后续步骤

有关详细信息,请参阅