POST https://management.azure.com/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.Kusto/clusters/kustoCluster/databases/KustoDatabase8/listPrincipals?api-version=2023-08-15
/** Samples for Databases ListPrincipals. */
public final class Main {
/*
* x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabaseListPrincipals.json
*/
/**
* Sample code: KustoDatabaseListPrincipals.
*
* @param manager Entry point to KustoManager.
*/
public static void kustoDatabaseListPrincipals(com.azure.resourcemanager.kusto.KustoManager manager) {
manager
.databases()
.listPrincipals("kustorptest", "kustoCluster", "KustoDatabase8", com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.kusto import KustoManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-kusto
# USAGE
python kusto_database_list_principals.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = KustoManagementClient(
credential=DefaultAzureCredential(),
subscription_id="12345678-1234-1234-1234-123456789098",
)
response = client.databases.list_principals(
resource_group_name="kustorptest",
cluster_name="kustoCluster",
database_name="KustoDatabase8",
)
for item in response:
print(item)
# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabaseListPrincipals.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armkusto_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kusto/armkusto/v2"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabaseListPrincipals.json
func ExampleDatabasesClient_NewListPrincipalsPager() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armkusto.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewDatabasesClient().NewListPrincipalsPager("kustorptest", "kustoCluster", "KustoDatabase8", nil)
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page.DatabasePrincipalListResult = armkusto.DatabasePrincipalListResult{
// Value: []*armkusto.DatabasePrincipal{
// {
// Name: to.Ptr("Some User"),
// Type: to.Ptr(armkusto.DatabasePrincipalTypeUser),
// AppID: to.Ptr(""),
// Email: to.Ptr("user@microsoft.com"),
// Fqn: to.Ptr("aaduser=some_guid"),
// Role: to.Ptr(armkusto.DatabasePrincipalRoleAdmin),
// },
// {
// Name: to.Ptr("Kusto"),
// Type: to.Ptr(armkusto.DatabasePrincipalTypeGroup),
// AppID: to.Ptr(""),
// Email: to.Ptr("kusto@microsoft.com"),
// Fqn: to.Ptr("aadgroup=some_guid"),
// Role: to.Ptr(armkusto.DatabasePrincipalRoleViewer),
// },
// {
// Name: to.Ptr("SomeApp"),
// Type: to.Ptr(armkusto.DatabasePrincipalTypeApp),
// AppID: to.Ptr("some_guid_app_id"),
// Email: to.Ptr(""),
// Fqn: to.Ptr("aadapp=some_guid_app_id"),
// Role: to.Ptr(armkusto.DatabasePrincipalRoleAdmin),
// }},
// }
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { KustoManagementClient } = require("@azure/arm-kusto");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Returns a list of database principals of the given Kusto cluster and database.
*
* @summary Returns a list of database principals of the given Kusto cluster and database.
* x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabaseListPrincipals.json
*/
async function kustoDatabaseListPrincipals() {
const subscriptionId =
process.env["KUSTO_SUBSCRIPTION_ID"] || "12345678-1234-1234-1234-123456789098";
const resourceGroupName = process.env["KUSTO_RESOURCE_GROUP"] || "kustorptest";
const clusterName = "kustoCluster";
const databaseName = "KustoDatabase8";
const credential = new DefaultAzureCredential();
const client = new KustoManagementClient(credential, subscriptionId);
const resArray = new Array();
for await (let item of client.databases.listPrincipals(
resourceGroupName,
clusterName,
databaseName
)) {
resArray.push(item);
}
console.log(resArray);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using System;
using System.Threading.Tasks;
using System.Xml;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.Kusto;
using Azure.ResourceManager.Kusto.Models;
// Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabaseListPrincipals.json
// this example is just showing the usage of "Databases_ListPrincipals" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this KustoDatabaseResource created on azure
// for more information of creating KustoDatabaseResource, please refer to the document of KustoDatabaseResource
string subscriptionId = "12345678-1234-1234-1234-123456789098";
string resourceGroupName = "kustorptest";
string clusterName = "kustoCluster";
string databaseName = "KustoDatabase8";
ResourceIdentifier kustoDatabaseResourceId = KustoDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName, databaseName);
KustoDatabaseResource kustoDatabase = client.GetKustoDatabaseResource(kustoDatabaseResourceId);
// invoke the operation and iterate over the result
await foreach (KustoDatabasePrincipal item in kustoDatabase.GetPrincipalsAsync())
{
Console.WriteLine($"Succeeded: {item}");
}
Console.WriteLine($"Succeeded");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue