dotnet / interactive

.NET Interactive combines the power of .NET with many other languages to create notebooks, REPLs, and embedded coding experiences. Share code, explore data, write, and learn across your apps in ways you couldn't before.
MIT License
2.8k stars 374 forks source link

Easiest way to try out KQL? #3481

Open IntegerMan opened 3 months ago

IntegerMan commented 3 months ago

The package and version I'm asking about: Microsoft.DotNet.Interactive.Kql, 1.0.0-beta.24129.1 .NET Interactive 1.0.512901+07977b2f577c0c9a2bc47fc2ca1df2f59a14c825

Question

I'm trying to evaluate the KQL kernel features in Polyglot Notebooks and am having some issues connecting to a kernel.

My earliest attempts wanted to query an app insights resource on Azure, but it was unclear how to do so. Next, I tried connecting to the samples at Help.Kusto.Windows.Net as shown here but ran into auth issues. Most recently, I created my own free cluster at https://dataexplorer.azure.com, added a database, and uploaded a minimal amount of data.

To connect, I should so something similar to this in a KQL code cell:

#!connect kql --kernel-name samples_database --cluster "https://REDACTED.kusto.windows.net/" --database "MyDatabase"

However, when I try running this I get an exception indicating that the MicrosoftKustoServiceLayer failed to start properly and returned a 150 exit code as shown here:

Error: System.InvalidOperationException: /home/matteland/.dotnet/tools/MicrosoftKustoServiceLayer failed to start properly. Exit code: 150.
---> StreamJsonRpc.ConnectionLostException: The JSON-RPC connection with the remote party was lost before the request could complete.
---> System.OperationCanceledException: The operation was canceled.
at System.Threading.CancellationToken.ThrowOperationCanceledException()
at System.Threading.CancellationToken.ThrowIfCancellationRequested()
at StreamJsonRpc.MessageHandlerBase.WriteAsync(JsonRpcMessage content, CancellationToken cancellationToken)
at StreamJsonRpc.JsonRpc.SendAsync(JsonRpcMessage message, CancellationToken cancellationToken)
at StreamJsonRpc.JsonRpc.InvokeCoreAsync(JsonRpcRequest request, Type expectedResultType, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at StreamJsonRpc.JsonRpc.InvokeCoreAsync(JsonRpcRequest request, Type expectedResultType, CancellationToken cancellationToken)
at StreamJsonRpc.JsonRpc.InvokeCoreAsync[TResult](RequestId id, String targetName, IReadOnlyList`1 arguments, IReadOnlyList`1 positionalArgumentDeclaredTypes, IReadOnlyDictionary`2 namedArgumentDeclaredTypes, CancellationToken cancellationToken, Boolean isParameterObject)
at Microsoft.DotNet.Interactive.SqlServer.ToolsServiceClient.ConnectAsync(ConnectParams connectParams)
--- End of inner exception stack trace ---
at Microsoft.DotNet.Interactive.SqlServer.ToolsServiceClient.ConnectAsync(ConnectParams connectParams)
at Microsoft.DotNet.Interactive.Kql.ToolsServiceClientExtensions.ConnectAsync(ToolsServiceClient serviceClient, Uri ownerUri, KqlConnectionDetails kqlDetails)
at Microsoft.DotNet.Interactive.Kql.MsKqlKernel.ConnectAsync()
at Microsoft.DotNet.Interactive.Kql.KqlKernelConnector.CreateKernelAsync(String kernelName)
at Microsoft.DotNet.Interactive.Kql.ConnectKqlCommand.ConnectKernelsAsync(KernelInvocationContext context, InvocationContext commandLineContext)
at Microsoft.DotNet.Interactive.CompositeKernel.<>c__DisplayClass21_0.<<AddKernelConnector>b__0>d.MoveNext() in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\CompositeKernel.cs:line 271
--- End of stack trace from previous location ---
at System.CommandLine.NamingConventionBinder.CommandHandler.GetExitCodeAsync(Object returnValue, InvocationContext context)
at System.CommandLine.NamingConventionBinder.ModelBindingCommandHandler.InvokeAsync(InvocationContext context)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass15_0.<<AddMiddleware>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass12_0.<<UseHelp>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass19_0.<<UseTypoCorrections>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Invocation.InvocationPipeline.<InvokeAsync>g__FullInvocationChainAsync|2_0(InvocationContext context)
at System.CommandLine.Parsing.ParseResultExtensions.InvokeAsync(ParseResult parseResult, IConsole console)
at Microsoft.DotNet.Interactive.Commands.DirectiveCommand.InvokeAsync(KernelInvocationContext context) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\Commands\DirectiveCommand.cs:line 33
at Microsoft.DotNet.Interactive.Kernel.HandleAsync(KernelCommand command, KernelInvocationContext context) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\Kernel.cs:line 330
at Microsoft.DotNet.Interactive.KernelCommandPipeline.<BuildPipeline>b__6_0(KernelCommand command, KernelInvocationContext context, KernelPipelineContinuation _) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\KernelCommandPipeline.cs:line 60
at Microsoft.DotNet.Interactive.KernelCommandPipeline.SendAsync(KernelCommand command, KernelInvocationContext context) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\KernelCommandPipeline.cs:line 41

I'm wondering what the simplest way of connecting to either a brand new or some pre-existing cluster for read access is. If I wanted to point a new learner at trying out the KQL features to get data, what's the best way for them to get started?

Beyond that, what's the most useful use cases of KQL that you imagine seeing? My immediate thought was connecting it to App Insights on Azure for dynamic querying there, but I'm no longer certain that's possible.

IntegerMan commented 3 months ago

I now believe this may be an actual bug as I was able to replicate a similar error in https://github.com/dotnet/interactive/issues/3484 for SQL connections which I do know have worked for me before.

IntegerMan commented 3 months ago

@corivera and @Charles-Gagnon this is also potentially relevant from the issue with SQL (#3484) @colombod and I pinged you on as it seems to be the same failure for a different connection. This issue should probably be reclassified as an issue instead of a question if there's something confirmed wrong in connecting to KQL clusters.

chenxizhang commented 3 months ago

same issue here, anyone can give a suggestion?

chenxizhang commented 3 months ago

image

jonsequitur commented 3 months ago

The workaround is to install .NET 7, until the SQL Tools Service is updated to .NET 8.

https://github.com/microsoft/sqltoolsservice/pull/2346