共用方式為


新增 Azure Data Explorer的叢集主體

Azure 資料總管是一項快速又可高度調整的資料探索服務,可用於處理記錄和遙測資料。 在本文中,您將瞭解如何使用 C#、Python 或 Azure Resource Manager (ARM) 範本,為 Azure Data Explorer新增叢集主體。

必要條件

必要條件會根據用來新增主體的方法而有所不同。 選擇慣用方法的相關索引標籤。

下列清單概述使用 C# 新增叢集主體的必要條件。

新增叢集主體

執行下列程式碼以新增叢集主體:

var tenantId = "xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx"; //Directory (tenant) ID
var clientId = "xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx"; //Application ID
var clientSecret = "PlaceholderClientSecret"; //Client Secret
var subscriptionId = "xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx";
var credentials = await ApplicationTokenProvider.LoginSilentAsync(tenantId, clientId, clientSecret);
var kustoManagementClient = new KustoManagementClient(credentials) { SubscriptionId = subscriptionId };
var resourceGroupName = "testrg";
//The cluster that is created as part of the Prerequisites
var clusterName = "mykustocluster";
var clusterPrincipalAssignmentName = "mykustoclusterprincipalassignment";
var principalId = "xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx"; //User email, application ID, or security group name
var role = "AllDatabasesAdmin"; //AllDatabasesAdmin or AllDatabasesViewer
var tenantIdForPrincipal = "xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx";
var principalType = "App"; //User, App, or Group
var clusterPrincipalAssignmentData = new ClusterPrincipalAssignment(
    principalId: principalId, role: role, principalType: principalType, tenantId: tenantIdForPrincipal
);
await kustoManagementClient.ClusterPrincipalAssignments.CreateOrUpdateAsync(
    resourceGroupName, clusterName, clusterPrincipalAssignmentName, clusterPrincipalAssignmentData
);
設定 建議的值 欄位描述
tenantId xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx 您的租用戶識別碼。 也稱為目錄識別碼。
subscriptionId xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx 您用來建立資源的訂用帳戶識別碼。
clientId xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx 應用程式的用戶端識別碼,可存取您租用戶中的資源。
clientSecret PlaceholderClientSecret 應用程式的用戶端密碼,可以存取您租用戶中的資源。
resourceGroupName testrg 包含叢集的資源群組名稱。
clusterName mykustocluster 您叢集的名稱。
principalAssignmentName clusterPrincipalAssignment1 叢集主體資源的名稱。
principalId xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx 主體識別碼,可以是使用者電子郵件、應用程式識別碼或安全性群組名稱。
角色 (role) AllDatabasesAdmin 叢集主體的角色,可以是 'AllDatabasesAdmin'、'AllDatabasesMonitor'或 'AllDatabasesViewer'。
tenantIdForPrincipal xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx 主體的租使用者識別碼。
principalType App 主體的類型,可以是 'User'、'App' 或 'Group'

下一步