Udostępnij za pośrednictwem


Dodawanie jednostek klastra dla usługi Azure Data Explorer

Azure Data Explorer to szybka i wysoce skalowalna usługa eksploracji danych na potrzeby danych dziennika i telemetrycznych. W tym artykule dowiesz się, jak dodawać jednostki klastra dla usługi Azure Data Explorer przy użyciu języka C#, Python lub szablonu usługi Azure Resource Manager (ARM).

Wymagania wstępne

Wymagania wstępne różnią się w zależności od metody użytej do dodania podmiotu zabezpieczeń. Wybierz odpowiednią kartę dla preferowanej metody.

Poniższa lista przedstawia wymagania wstępne dotyczące dodawania jednostki klastra z językiem C#.

Dodawanie jednostki klastra

Uruchom następujący kod, aby dodać jednostkę klastra:

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
);
Ustawienie Sugerowana wartość Opis pola
tenantId xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx Identyfikator dzierżawy. Znany również jako identyfikator katalogu.
subscriptionId xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx Identyfikator subskrypcji używany do tworzenia zasobów.
clientId xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx Identyfikator klienta aplikacji, która może uzyskiwać dostęp do zasobów w dzierżawie.
clientSecret Symbol zastępczyClientSecret Klucz tajny klienta aplikacji, który może uzyskiwać dostęp do zasobów w dzierżawie.
resourceGroupName testrg Nazwa grupy zasobów zawierającej klaster.
clusterName mykustocluster Nazwa klastra.
principalAssignmentName clusterPrincipalAssignment1 Nazwa zasobu głównego klastra.
principalId xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx Identyfikator podmiotu zabezpieczeń, który może być adresem e-mail użytkownika, identyfikatorem aplikacji lub nazwą grupy zabezpieczeń.
role (rola) AllDatabasesAdmin Rola jednostki klastra, która może być "AllDatabasesAdmin", "AllDatabasesMonitor" lub "AllDatabasesViewer".
tenantIdForPrincipal xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx Identyfikator dzierżawy podmiotu zabezpieczeń.
principalType Aplikacja Typ podmiotu zabezpieczeń, który może być "Użytkownik", "Aplikacja" lub "Grupa"

Następne kroki