Azure / azure-kusto-dotnet

Azure Data Explorer (Kusto) SDK for .NET
MIT License
6 stars 3 forks source link

System.PlatformNotSupportedException: Az-Cli does not support the current operating system #8

Closed FaresKi closed 1 year ago

FaresKi commented 1 year ago

Hi! I'm facing an issue when trying to authenticate to my ADX cluster using AZ CLI Authentication:

Error : System.PlatformNotSupportedException: Az-Cli does not support the current operting system
   at Kusto.Cloud.Platform.Security.AzCliTokenProvider.LocateAzCli()
   at Kusto.Cloud.Platform.Security.AzCliTokenProvider.GetTokenFromAzCli(String resource, Boolean interactive)
   at Kusto.Cloud.Platform.Security.AzCliTokenProvider.GetCredentialsAsync(String targetResource)
   at Kusto.Cloud.Platform.Http.TokenProviderHttpClientAuthenticator.AuthenticateAsync(HttpRequestMessage request)
   at Kusto.Data.Net.Client.RestClient2.MakeHttpRequestAsyncImpl(String address, String csl, String ns, String databaseName, Boolean streaming, ClientRequestProperties properties, ServiceModelTimeoutKind timeoutKind, String clientRequestId, Stream body, StreamProperties streamProperties, CancellationToken cancellationToken, KustoProtocolRequest request)
   at Kusto.Cloud.Platform.Utils.MonitoredActivity.InvokeAsync[TActivityType,TResult](TActivityType activityType, Func`1 func, String clientRequestId)
   at Kusto.Cloud.Platform.Utils.MonitoredActivity.InvokeAsync[TActivityType,TResult](TActivityType activityType, Func`1 func, String clientRequestId)
   at Kusto.Data.Net.Client.RestClient2.MakeHttpRequestAsync(ActivityType activityType, String baseAddress, String relativeAddress, String clientRequestIdPrefix, String ns, String databaseName, String csl, String addr, Boolean streaming, ClientRequestProperties properties, ServiceModelTimeoutKind timeoutKind, StreamProperties streamProperties, CancellationToken cancellationToken)
   at Kusto.Data.Net.Client.RestClient2.ExecuteControlCommandAsync(String databaseName, String command, String addr, ClientRequestProperties properties)
   at Kushy.ServerSymbolLoader.ExecuteControlCommandAsync[T](ICslAdminProvider provider, String database, String command, Boolean throwOnError, CancellationToken cancellationToken) in query-parsing-service/SymbolLoader.cs:line 324
   at Kushy.ServerSymbolLoader.LoadTablesAsync(ICslAdminProvider provider, String databaseName, Boolean throwOnError, CancellationToken cancellationToken) in query-parsing-service/SymbolLoader.cs:line 239
   at Kushy.ServerSymbolLoader.LoadDatabaseAsync(String databaseName, String clusterName, Boolean throwOnError, CancellationToken cancellationToken) in query-parsing-service/SymbolLoader.cs:line 208
   at Company.Function.QueryParsingService.Run(HttpRequest req, ILogger log) in query-parsing-service/QueryParsingService.cs:line 42

The code snippet triggering this error is the following:

public static class QueryParsingService
    {
        [FunctionName("QueryParsingService")]
        public static async Task<IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
            ILogger log)
        {
            var cluster = System.Environment.GetEnvironmentVariable("CLUSTER_ENDPOINT");
            var connection = new KustoConnectionStringBuilder(cluster).WithAadAzCliAuthentication();
            var server = new ServerSymbolLoader(connection);

            try
            {
                 var tableNames = await server.LoadDatabaseAsync("DBName", cluster,true);
            }
            catch (System.Exception err)
            {
                System.Console.WriteLine("Error : " + err);
            }
            responseMessage.Add("tables", "OK");

            return new OkObjectResult(responseMessage);
        }

What's strange is that the Python SDK does accept the AZ-CLI authentication method. Am I doing something incorrectly or is this a feature not yet provided?

TIA!

EDIT: I think it's worth sharing i'm on MacOS.

yogilad commented 1 year ago

This bug is fixed in the latest release of the SDK.