Udostępnij przez


Dodaj podmioty 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 głównego obiektu. Wybierz odpowiednią kartę dla preferowanej metody.

Poniższa lista przedstawia wymagania wstępne w celu dodania głównego elementu klastra w języku C#.

Dodaj zasadniczy element klastra

Uruchom następujący kod, aby dodać główną 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
identyfikatorNajemcy xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx Identyfikator najemcy. Znany również jako identyfikator katalogu.
identyfikator subskrypcji 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 twojej dzierżawie.
tajny klucz klienta PlaceholderClientSecret Klucz tajny klienta aplikacji, który może uzyskiwać dostęp do zasobów w Twojej dzierżawie.
nazwaGrupyZasobów testrg Nazwa grupy zasobów zawierającej klaster.
nazwa_klastra mykustocluster Nazwa klastra.
NazwaPrzydzieleniaGłównego clusterPrincipalAssignment1 Nazwa zasobu głównego klastra.
principalId xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx Identyfikator główny, który może być adresem e-mail użytkownika, identyfikatorem aplikacji lub nazwą grupy zabezpieczeń.
rola AllDatabasesAdmin Rola głównego klastra, która może być "AllDatabasesAdmin", "AllDatabasesMonitor" lub "AllDatabasesViewer".
tenantIdForPrincipal xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx Identyfikator klienta głównego podmiotu.
typ główny Aplikacja Typ podmiotu głównego, który może być "Użytkownik", "Aplikacja" lub "Grupa"

Następne kroki