如何使用C#获取Azure Data Explorer群集内的数据库列表,

问题描述 投票:0回答:1

我已经尝试过使用Kusto.data和kustomanagementclient,但是我没有看到任何结果,有人可以帮忙吗?

c# azure-data-explorer
1个回答
0
投票

使用Microsoft.Azure.Kusto.Data库时,您可以编写如下内容:

// replace 'clustername' and 'westus' according to your actual configuration
var clusterUrl = "https://mycluster.westus.kusto.windows.net";

// replace 'WithAadUserPromptAuthentication' with your preferred method of authentication
var kcsb = new KustoConnectionStringBuilder(clusterUrl).WithAadUserPromptAuthentication();

using (var adminProvider = KustoClientFactory.CreateCslAdminProvider(kcsb))
{
    var command = CslCommandGenerator.GenerateDatabasesShowCommand();
    var databases = adminProvider.ExecuteControlCommand<DatabasesShowCommandResult>(command).ToList();

    foreach (var database in databases)
    {
        Console.WriteLine(database.DatabaseName);
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.