为Azure Data Explorer创建托管专用终结点

托管专用终结点是连接到高度受保护的Azure资源的可选方法。 它们是允许Azure Data Explorer连接到其他受保护服务的单向专用连接。 本文介绍如何创建托管专用终结点并将其连接到数据源。

注意事项

不要使用托管专用终结点,而是使用托管标识连接到 Azure Storage(事件网格流除外)和 Azure Event Hubs。 若要使用托管标识进行连接,请将Azure Storage或事件中心资源配置为将Azure Data Explorer识别为受信任的服务。 然后,使用 托管身份为受信任的 Azure 服务创建网络规则例外,从而授予访问权限。

先决条件

使用 Azure portal 创建托管专用终结点

使用门户为集群创建托管专用终结点,以便在访问存储时使用。

  1. 在Azure portal中,转到群集并选择Networking

  2. 选择托管专用终结点,然后选择添加

    该屏幕截图显示了网络页面,其中显示了创建托管专用终结点的第一步。

  3. “新建托管专用终结点 ”窗格中,输入包含以下信息的资源详细信息,然后选择“ 下一步”。

    该屏幕截图显示了网络页面,其中显示了创建托管专用终结点的第二步。

    设置 建议的值 字段说明
    名称 mpeToStorage 托管专用终结点的名称
    订阅 订阅 选择要用于群集的Azure订阅
    资源类型 Microsoft。Storage/storageAccounts 选择数据源所需的相关资源类型。
    资源名称 共享 选择要用于新Azure私有终结点目标的群集
    目标子资源 blob 选择数据源的相关目标。
  4. 选择 “创建 ”以创建托管专用终结点资源。

使用 REST API 创建托管专用终结点

若要创建托管专用终结点,请对 Kusto 资源提供程序进行单个 API 调用。 可以为以下资源类型创建托管专用终结点:

  • Microsoft.Storage/storageAccounts(子资源可以是“blob”或“dfs”)
  • Microsoft.EventHub/namespaces (子资源“namespace”)
  • Microsoft.Devices/IoTHubs (子资源“iotHub”)
  • Microsoft.KeyVault/vaults (子资源“vault”)
  • Microsoft.Sql/servers (子资源“sqlServer”)
  • Microsoft.Kusto/clusters (子资源“群集(cluster)”)
  • Microsoft.DigitalTwins/digitalTwinsInstance(子资源“digitaltwinsinstance”)

在以下示例中,使用 PowerShell 中的 ARMclient 通过 REST API 创建托管专用终结点。

注意事项

使用“dfs”资源连接到storage帐户需要另一个托管专用终结点才能连接到“blob”子资源。

使用 REST API 的先决条件

  1. 安装 choco

  2. 安装 ARMClient

    choco install armclient
    
  3. 使用 ARMClient 登录

    armclient login
    

创建用于Azure Event Hubs的托管专用终结点

使用以下 REST API 调用为事件中心服务启用托管专用终结点:

  1. 运行以下命令以创建事件中心服务的托管专用终结点:

    # Replace the <...> placeholders with the correct values
    armclient PUT /subscriptions/<subscriptionIdADX>/resourceGroups/<resourceGroupNameADX>/providers/Microsoft.Kusto/clusters/<clusterName>/managedPrivateEndpoints/<newMpeName>?api-version=2022-02-01 @"
    {
        'properties': {
            'privateLinkResourceId':'/subscriptions/<subscriptionIdEventHub>/resourceGroups/<resourceGroupNameEventHub>/providers/Microsoft.EventHub/namespaces/<EventHubNamespace>',
            'groupId':'namespace',
            'requestMessage':'Please Approve.'
        }
    }
    "@
    
  2. 检查响应。

    {
      "id": "/subscriptions/<subscriptionIdADX>/resourceGroups/<resourceGroupNameADX>/providers/Microsoft.Kusto/Clusters/<clusterName>/ManagedPrivateEndpoints/<newMpeName>",
      "name": "<clusterName>/<newMpeName>",
      "type": "Microsoft.Kusto/Clusters/ManagedPrivateEndpoints",
      "location": "DummyLocation",
      "properties": {
        "privateLinkResourceId": "/subscriptions/<subscriptionIdEventHub>/resourceGroups/<resourceGroupNameEventHub>/providers/Microsoft.EventHub/namespaces/<EventHubNamespace>",
        "groupId": "namespace",
        "requestMessage": "Please Approve.",
        "provisioningState": "Creating"
      }
    }
    

创建一个受管的专用端点连接到 Azure 存储帐户

使用以下 REST API 调用将托管专用终结点启用到Azure Storage blob:

  1. 运行以下命令,创建事件中心的托管专用终结点:

    #replace the <...> placeholders with the correct values
    armclient PUT /subscriptions/<subscriptionIdADX>/resourceGroups/<resourceGroupNameADX>/providers/Microsoft.Kusto/clusters/<clusterName>/managedPrivateEndpoints/<newMpeName>?api-version=2022-02-01 @"
    {
        'properties': {
            'privateLinkResourceId':'/subscriptions/<subscriptionIdStorage>/resourceGroups/<resourceGroupNameStorage>/providers/Microsoft.Storage/storageAccounts/<storageAccountName>',
            'groupId':'blob',
            'requestMessage':'Please Approve.'
        }
    }
    "@
    
  2. 检查响应。

    {
      "id": "/subscriptions/<subscriptionIdADX>/resourceGroups/<resourceGroupNameADX>/providers/Microsoft.Kusto/Clusters/<clusterName>/ManagedPrivateEndpoints/<newMpeName>",
      "name": "<clusterName>/<newMpeName>",
      "type": "Microsoft.Kusto/Clusters/ManagedPrivateEndpoints",
      "location": "DummyLocation",
      "properties": {
        "privateLinkResourceId": "/subscriptions/<subscriptionIdStorage>/resourceGroups/<resourceGroupNameStorage>/providers/Microsoft.Storage/storageAccounts/<storageAccountName>",
        "groupId": "blob",
        "requestMessage": "Please Approve.",
        "provisioningState": "Creating"
      }
    }
    

如何检查进度

若要检查托管专用终结点迁移的进度,请使用以下命令:

  1. 运行以下命令:

    #replace the <...> placeholders with the correct values
    armclient GET /subscriptions/<subscriptionIdADX>/resourceGroups/<resourceGroupNameADX>/providers/Microsoft.Kusto/clusters/<clusterName>/managedPrivateEndpoints/<newMpeName>?api-version=2022-02-01
    
  2. 检查响应。

    {
      "id": "/subscriptions/<subscriptionIdADX>/resourceGroups/<resourceGroupNameADX>/providers/Microsoft.Kusto/Clusters/<clusterName>/ManagedPrivateEndpoints/<newMpeName>",
      "name": "<clusterName>/<newMpeName>",
      "type": "Microsoft.Kusto/Clusters/ManagedPrivateEndpoints",
      "location": "DummyLocation",
      "properties": {
        "privateLinkResourceId": "/subscriptions/02de0e00-8c52-405c-9088-1342de78293d/resourceGroups/<resourceGroupNameADX>/providers/Microsoft.<service>/<...>/<name>",
        "groupId": "<groupId>",
        "requestMessage": "Please Approve.",
        "provisioningState": "Succeeded"
      },
      "systemData": {
        "createdBy": "<UserName>",
        "createdByType": "User",
        "createdAt": "2022-02-05T08:29:54.2912851Z",
        "lastModifiedBy": "chrisqpublic@contoso.com",
        "lastModifiedByType": "User",
        "lastModifiedAt": "2022-02-05T08:29:54.2912851Z"
      }
    }
    

批准托管专用终结点

无论使用哪种方法来创建托管专用终结点,都必须在目标资源上批准其创建。 若要为事件中心服务批准一个托管专用终结点,请执行以下操作:

  1. 在Azure portal中,转到事件中心服务,然后选择Networking

  2. 选择“专用终结点连接”,选择创建的托管专用终结点,然后选择“批准”。

    网络页面的屏幕截图,显示了对事件中心服务的托管私有终结点的批准。

  3. 在“连接状态”列中,验证托管专用终结点是否已获批准。

    网络页面的屏幕截图,显示了已批准的事件中心服务的托管专用终结点。

群集现在可以通过托管的专用终结点连接到资源。

创建多个托管专用终结点

可以使用 ARM 模板和 Terraform 创建多个托管专用终结点。 以下示例确保先创建事件中心命名空间的托管专用终结点,然后再创建到Storage帐户的专用终结点。

以下示例使用 ARM 模板在Azure Data Explorer群集中创建两个托管专用终结点。 第一个终结点连接到事件中心命名空间。 第二个终结点连接到Storage帐户,其依赖项可确保先创建事件中心终结点。

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "cluster_name": {
            "defaultValue": "<ADX cluster name>",
            "type": "String"
        },
        "eventhub_resource_id": {
            "defaultValue": "<Eventhub resource id>",
            "type": "String"
        },
        "storage_resource_id": {
            "defaultValue": "<Storage resource id>",
            "type": "String"
        },
        "managed_pe_eventhub_name": {
            "defaultValue": "<name of the managed private endpoint to Event Hub>",
            "type": "String"
        },
        "managed_pe_storage_name": {
            "defaultValue": "<name of the managed private endpoint to Storage>",
            "type": "String"
        }
    },
    "variables": {},
    "resources": [
        {
            "type": "Microsoft.Kusto/Clusters",
            "apiVersion": "2023-08-15",
            "name": "[parameters('cluster_name')]",
            "location": "<region of the cluster>",
            "sku": {...},
            "zones": {...}
            "properties": {...}
        },
        {
            "type": "Microsoft.Kusto/Clusters/ManagedPrivateEndpoints",
            "apiVersion": "2023-08-15",
            "name": "[concat(parameters('cluster_name'), '/', parameters('managed_pe_eventhub_name'))]",
            "dependsOn": [
                "[resourceId('Microsoft.Kusto/Clusters', parameters('cluster_name'))]"
            ],
            "properties": {
                "privateLinkResourceId": "[parameters('eventhub_resource_id')]",
                "groupId": "namespace",
                "requestMessage": "Please approve"
            }
        },
        {
            "type": "Microsoft.Kusto/Clusters/ManagedPrivateEndpoints",
            "apiVersion": "2023-08-15",
            "name": "[concat(parameters('cluster_name'), '/', parameters('managed_pe_storage_name'))]",
            "dependsOn": [
                "[resourceId('Microsoft.Kusto/Clusters', parameters('cluster_name'))]",
                "[resourceId('Microsoft.Kusto/Clusters/ManagedPrivateEndpoints', parameters('cluster_name'), parameters('managed_pe_eventhub_name'))]"
            ],
            "properties": {
                "privateLinkResourceId": "[parameters('storage_resource_id')]",
                "groupId": "blob",
                "requestMessage": "Please approve"
            }
        }
    ]
}

自动审核

如果请求标识具有目标资源的 Microsoft.<Provider>/<ResourceType>/privateEndpointConnectionsApproval/action 权限,则可以自动批准托管专用终结点。