Azure / azure-kusto-samples-dotnet

Azure Data Explorer (ADX) sample code
MIT License
54 stars 41 forks source link

QuickStart Sample Does Not Work: Throws Exception #29

Closed securigy closed 1 year ago

securigy commented 1 year ago

I downloaded the whole package and set the QuickStart project as default. I signed up for free Kusto cluster and used the proposed defaults for the names, except that my region is North America, which I selected. Then I copied the Cluster URI and Data Ingestion URI to replace the 'kustoUri' and 'ingestUri' correspondingly with the one assigned to me. Then, I ran the project. I was not prompted to authenticate since I am already using the same account - am logged in to Edge with it. Then it throws exception claiming that there is no database MyDatabase.

====== Kusto sample app is starting...

Step 1: You will be prompted twice for credentials during this script. Please return to the console after authenticating. Press any key to proceed with this operation...

Step 2: Alter-merge existing table 'MyDatabase.SampleTable' to align with the provided schema Press any key to proceed with this operation...

Script failed with error: Unknown error while trying to execute command '.alter-merge table SampleTable (rownumber:int, rowguid:string, xdouble:real, xfloat:real, xbool:bool, xint16:int, xint32:int, xint64:long, xuint8:long, xuint16:long, xuint32:long, xuint64:long, xdate:datetime, xsmalltext:string, xtext:string, xnumberAsText:string, xtime:timespan, xtextWithNulls:string, xdynamicWithNulls:dynamic)' on database 'MyDatabase' Exception: [0]Kusto.Data.Exceptions.KustoRequestException: NotFound (404-NotFound): { "error": { "code": "NotFound", "message": "Entity name 'MyDatabase' of kind 'Database' does not exist.", "@type": "Kusto.Common.Svc.Exceptions.EntityNameDoesNotExistException", "@message": "Entity name 'MyDatabase' of kind 'Database' does not exist.", "@context": { "timestamp": "2023-05-26T00:52:31.4783365Z", "serviceAlias": "HELP", "machineName": "KEngine000000", "processName": "Kusto.WinSvc.Svc", "processId": 9620, "threadId": 11164, "clientRequestId": "CS_SampleApp_ControlCommand;ea64115e-1234-434f-9340-8eeb0725479d", "activityId": "14793053-b8af-467a-b170-609c0ac39530", "subActivityId": "7078db9e-6b3e-4787-bd91-b146a7ff2201", "activityType": "DN.AdminCommand.TableAlterCommand", "parentActivityId": "1aabb80c-8f22-4d6d-849e-56e03c0c19b5", "activityStack": "(Activity stack: CRID=CS_SampleApp_ControlCommand;ea64115e-1234-434f-9340-8eeb0725479d ARID=14793053-b8af-467a-b170-609c0ac39530 > DN.Admin.Client.ExecuteControlCommand/dcd64be1-c5c5-41cd-9530-dc420117c291 > P.WCF.Service.ExecuteControlCommand..IInterNodeCommunicationAdminContract/e7cdab68-19e0-468d-8ed4-84d515d61366 > DN.FE.ExecuteControlCommand/1aabb80c-8f22-4d6d-849e-56e03c0c19b5 > DN.AdminCommand.TableAlterCommand/7078db9e-6b3e-4787-bd91-b146a7ff2201)" }, "@permanent": true } }. This normally represents a permanent error, and retrying is unlikely to help. Error details: DataSource='https://help.kusto.windows.net/v1/rest/mgmt', DatabaseName='MyDatabase', ClientRequestId='CS_SampleApp_ControlCommand;ea64115e-1234-434f-9340-8eeb0725479d', ActivityId='14793053-b8af-467a-b170-609c0ac39530, Timestamp='2023-05-26T00:52:36.8013264Z'. Timestamp=2023-05-26T00:52:36.8013264Z ClientRequestId=CS_SampleApp_ControlCommand;ea64115e-1234-434f-9340-8eeb0725479d ActivityId=93b1d6c7-fdf9-4886-9242-8369511ca899 ActivityType=DN.RestClient.ExecuteControlCommand MachineName=ASUSROG ProcessName=QuickStart ProcessId=45804 ThreadId=32652 AppDomainName=QuickStart.exe ActivityStack=(Activity stack: CRID=CS_SampleApp_ControlCommand;ea64115e-1234-434f-9340-8eeb0725479d ARID=93b1d6c7-fdf9-4886-9242-8369511ca899 > DN.RestClient.ExecuteControlCommand/93b1d6c7-fdf9-4886-9242-8369511ca899) MonitoredActivityContext=(ActivityType=DN.RestClient.ExecuteControlCommand, Timestamp=2023-05-26T00:52:36.0457116Z, ParentActivityId=93b1d6c7-fdf9-4886-9242-8369511ca899, TimeSinceStarted=755.6148 [ms])ErrorCode=404-NotFound ErrorReason=NotFound ErrorMessage={ "error": { "code": "NotFound", "message": "Entity name 'MyDatabase' of kind 'Database' does not exist.", "@type": "Kusto.Common.Svc.Exceptions.EntityNameDoesNotExistException", "@message": "Entity name 'MyDatabase' of kind 'Database' does not exist.", "@context": { "timestamp": "2023-05-26T00:52:31.4783365Z", "serviceAlias": "HELP", "machineName": "KEngine000000", "processName": "Kusto.WinSvc.Svc", "processId": 9620, "threadId": 11164, "clientRequestId": "CS_SampleApp_ControlCommand;ea64115e-1234-434f-9340-8eeb0725479d", "activityId": "14793053-b8af-467a-b170-609c0ac39530", "subActivityId": "7078db9e-6b3e-4787-bd91-b146a7ff2201", "activityType": "DN.AdminCommand.TableAlterCommand", "parentActivityId": "1aabb80c-8f22-4d6d-849e-56e03c0c19b5", "activityStack": "(Activity stack: CRID=CS_SampleApp_ControlCommand;ea64115e-1234-434f-9340-8eeb0725479d ARID=14793053-b8af-467a-b170-609c0ac39530 > DN.Admin.Client.ExecuteControlCommand/dcd64be1-c5c5-41cd-9530-dc420117c291 > P.WCF.Service.ExecuteControlCommand..IInterNodeCommunicationAdminContract/e7cdab68-19e0-468d-8ed4-84d515d61366 > DN.FE.ExecuteControlCommand/1aabb80c-8f22-4d6d-849e-56e03c0c19b5 > DN.AdminCommand.TableAlterCommand/7078db9e-6b3e-4787-bd91-b146a7ff2201)" }, "@permanent": true } } DataSource=https://help.kusto.windows.net/v1/rest/mgmt DatabaseName=MyDatabase ClientRequestId=CS_SampleApp_ControlCommand;ea64115e-1234-434f-9340-8eeb0725479d ActivityId=14793053-b8af-467a-b170-609c0ac39530

at Kusto.Cloud.Platform.Http.KustoHttpClient.d4.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Kusto.Data.Net.Client.RestClient2.d60.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Kusto.Cloud.Platform.Utils.MonitoredActivity.d12`2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Kusto.Cloud.Platform.Utils.MonitoredActivity.d122.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Kusto.Data.Net.Client.RestClient2.<MakeHttpRequestAsync>d__58.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Kusto.Data.Net.Client.RestClient2.<ExecuteControlCommandAsync>d__53.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at QuickStart.Utils.Queries.d__2.MoveNext() in D:\Projects\azure-kusto-samples-dotnet-master\client\QuickStart\Utils.cs:line 142

D:\Projects\azure-kusto-samples-dotnet-master\client\QuickStart\bin\Debug\net472\QuickStart.exe (process 45804) exited with code -1. To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops. Press any key to close this window . . .

So maybe I should not have replaced the URIs by mine - I am new to this Kusto... So I reverted the json file to original URIs. And then I get the same exception.

But anyway, here is the output that I see on the command-line screen:

Kusto sample app is starting...

Step 1: You will be prompted twice for credentials during this script. Please return to the console after authenticating. Press any key to proceed with this operation...

Step 2: Alter-merge existing table 'MyDatabase.SampleTable' to align with the provided schema Press any key to proceed with this operation...

Script failed with error: Unknown error while trying to execute command '.alter-merge table SampleTable (rownumber:int, rowguid:string, xdouble:real, xfloat:real, xbool:bool, xint16:int, xint32:int, xint64:long, xuint8:long, xuint16:long, xuint32:long, xuint64:long, xdate:datetime, xsmalltext:string, xtext:string, xnumberAsText:string, xtime:timespan, xtextWithNulls:string, xdynamicWithNulls:dynamic)' on database 'MyDatabase' Exception: [0]Kusto.Data.Exceptions.KustoRequestException: NotFound (404-NotFound): { "error": { "code": "NotFound", "message": "Entity name 'MyDatabase' of kind 'Database' does not exist.", "@type": "Kusto.Common.Svc.Exceptions.EntityNameDoesNotExistException", "@message": "Entity name 'MyDatabase' of kind 'Database' does not exist.", "@context": { "timestamp": "2023-05-26T00:56:09.5497246Z", "serviceAlias": "HELP", "machineName": "KEngine000000", "processName": "Kusto.WinSvc.Svc", "processId": 9620, "threadId": 10196, "clientRequestId": "CS_SampleApp_ControlCommand;ec029053-5e3c-4781-bad8-9ce0703b5c37", "activityId": "811572e7-c7af-496a-acdf-73fb571ba25b", "subActivityId": "672489c0-30ac-4fb9-92c8-ac9c154d88a8", "activityType": "DN.AdminCommand.TableAlterCommand", "parentActivityId": "442cf458-c292-4331-83ed-1540859a5e49", "activityStack": "(Activity stack: CRID=CS_SampleApp_ControlCommand;ec029053-5e3c-4781-bad8-9ce0703b5c37 ARID=811572e7-c7af-496a-acdf-73fb571ba25b > DN.Admin.Client.ExecuteControlCommand/8e9811eb-3808-48d5-bca1-133aea37ab84 > P.WCF.Service.ExecuteControlCommand..IInterNodeCommunicationAdminContract/46b1d033-821c-4481-bcd9-caf9580a518f > DN.FE.ExecuteControlCommand/442cf458-c292-4331-83ed-1540859a5e49 > DN.AdminCommand.TableAlterCommand/672489c0-30ac-4fb9-92c8-ac9c154d88a8)" }, "@permanent": true } }. This normally represents a permanent error, and retrying is unlikely to help. Error details: DataSource='https://help.kusto.windows.net/v1/rest/mgmt', DatabaseName='MyDatabase', ClientRequestId='CS_SampleApp_ControlCommand;ec029053-5e3c-4781-bad8-9ce0703b5c37', ActivityId='811572e7-c7af-496a-acdf-73fb571ba25b, Timestamp='2023-05-26T00:56:14.8827124Z'. Timestamp=2023-05-26T00:56:14.8827124Z ClientRequestId=CS_SampleApp_ControlCommand;ec029053-5e3c-4781-bad8-9ce0703b5c37 ActivityId=fdd1dc67-718a-4df9-8c41-479db480a519 ActivityType=DN.RestClient.ExecuteControlCommand MachineName=ASUSROG ProcessName=QuickStart ProcessId=60436 ThreadId=58676 AppDomainName=QuickStart.exe ActivityStack=(Activity stack: CRID=CS_SampleApp_ControlCommand;ec029053-5e3c-4781-bad8-9ce0703b5c37 ARID=fdd1dc67-718a-4df9-8c41-479db480a519 > DN.RestClient.ExecuteControlCommand/fdd1dc67-718a-4df9-8c41-479db480a519) MonitoredActivityContext=(ActivityType=DN.RestClient.ExecuteControlCommand, Timestamp=2023-05-26T00:56:14.0790530Z, ParentActivityId=fdd1dc67-718a-4df9-8c41-479db480a519, TimeSinceStarted=803.6594 [ms])ErrorCode=404-NotFound ErrorReason=NotFound ErrorMessage={ "error": { "code": "NotFound", "message": "Entity name 'MyDatabase' of kind 'Database' does not exist.", "@type": "Kusto.Common.Svc.Exceptions.EntityNameDoesNotExistException", "@message": "Entity name 'MyDatabase' of kind 'Database' does not exist.", "@context": { "timestamp": "2023-05-26T00:56:09.5497246Z", "serviceAlias": "HELP", "machineName": "KEngine000000", "processName": "Kusto.WinSvc.Svc", "processId": 9620, "threadId": 10196, "clientRequestId": "CS_SampleApp_ControlCommand;ec029053-5e3c-4781-bad8-9ce0703b5c37", "activityId": "811572e7-c7af-496a-acdf-73fb571ba25b", "subActivityId": "672489c0-30ac-4fb9-92c8-ac9c154d88a8", "activityType": "DN.AdminCommand.TableAlterCommand", "parentActivityId": "442cf458-c292-4331-83ed-1540859a5e49", "activityStack": "(Activity stack: CRID=CS_SampleApp_ControlCommand;ec029053-5e3c-4781-bad8-9ce0703b5c37 ARID=811572e7-c7af-496a-acdf-73fb571ba25b > DN.Admin.Client.ExecuteControlCommand/8e9811eb-3808-48d5-bca1-133aea37ab84 > P.WCF.Service.ExecuteControlCommand..IInterNodeCommunicationAdminContract/46b1d033-821c-4481-bcd9-caf9580a518f > DN.FE.ExecuteControlCommand/442cf458-c292-4331-83ed-1540859a5e49 > DN.AdminCommand.TableAlterCommand/672489c0-30ac-4fb9-92c8-ac9c154d88a8)" }, "@permanent": true } } DataSource=https://help.kusto.windows.net/v1/rest/mgmt DatabaseName=MyDatabase ClientRequestId=CS_SampleApp_ControlCommand;ec029053-5e3c-4781-bad8-9ce0703b5c37 ActivityId=811572e7-c7af-496a-acdf-73fb571ba25b

at Kusto.Cloud.Platform.Http.KustoHttpClient.d4.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Kusto.Data.Net.Client.RestClient2.d60.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Kusto.Cloud.Platform.Utils.MonitoredActivity.d12`2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Kusto.Cloud.Platform.Utils.MonitoredActivity.d122.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Kusto.Data.Net.Client.RestClient2.<MakeHttpRequestAsync>d__58.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Kusto.Data.Net.Client.RestClient2.<ExecuteControlCommandAsync>d__53.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at QuickStart.Utils.Queries.d__2.MoveNext() in D:\Projects\azure-kusto-samples-dotnet-master\client\QuickStart\Utils.cs:line 142

D:\Projects\azure-kusto-samples-dotnet-master\client\QuickStart\bin\Debug\net472\QuickStart.exe (process 60436) exited with code -1. To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops. Press any key to close this window . . .

The bottom line is: a better explanation is need how to run this sample successfully, that is, why the heck it does not work? May be it is clear to you, guys, but not to someone who sees and runs it the first time... Please clarify.

securigy commented 1 year ago

Other sample that I tried so far: HowToDataIngestion and IngestDataSample do not work either - both crash with the messages: Endpoint 'https://kustolab.kusto.windows.net' is not responsive. This could indicate that the service in unavailable or does not exist

So what kind of samples are they that do not work...?

securigy commented 1 year ago

Well, I hope somebody will respond... meanwhile I have no choice but to switch to Pinecone...

ronmonetaMicro commented 1 year ago

Hey, to make sure we provide the most accurate answer we can, could you please explain the general process in more details - what did you download and where from, what and how you compiled, etc. - it would greatly help us provide a good answer.
Furthermore, would you please provide us with your updated json file? What existing DBs do you have in your cluster? Thanks.

securigy commented 1 year ago

I did not do much of any customization or anything, I simply downloaded your source: azure-kusto-samples-dotnet-master that is, from this very repository... Don't you have a repo context when you see the messages?

I opened solution, I ran QuckStart sample "as is" without changing anything - MS has no instructions that users are supposed to follow... I understand now that you need to have an account on Azure, which I already do but then what? No instructions, no explanations, no significant code comments. How do I provide credentials? Do I need to create my own DB and if yes, what, how, and where? No wonder that nobody wants to use Microsoft stuff...

With no choice, I switched to Pinecone and it worked, woudl you like me to use Kusto? Then do something about it!

securigy commented 1 year ago

I am still struggling with QuckStart example app despite that:

  1. I created ADX Cluster on Azure and I have its URL and its ingestion URI
  2. I also created Database
  3. I modified kusto_sample_config.json file and set the above URIs and DBA name in it. I left the rest of the parameters unchanged in this file.

When I run, first of all the credential prompt is confusing:
Step 1: You will be prompted twice for credentials during this script. Please return to the console after authenticating. Press any key to proceed with this operation...

I type my username followed by Return and the app control then goes until I break on the following line. Inside the adminClient there is DefaultDatabaseName member and its value is "NetDefaultDB". When I execute the line:

await PreIngestionQueryingAsync(config, adminClient, queryProvider);

I get another prompt: Step 2: Alter-merge existing table 'GptModelTrainerTestDB.SampleTable' to align with the provided schema Press any key to proceed with this operation...

But by that time, I already see exceptions in the Output window, starting with:

_StatusCode: 401, ReasonPhrase: 'Unauthorized', Version: 1.1, Content: System.Net.Http.StreamContent, Headers: { x-ms-client-request-id: KI.GetIngestionResources;33efc055-3d4c-46b1-8d91-9a640cc027d1;0 x-ms-activity-id: efee8b30-01db-4f0c-aa01-8480ae26c3a2 Strict-Transport-Security: max-age=2592000; includeSubDomains Date: Fri, 07 Jul 2023 00:10:14 GMT Server: Kestrel WWW-Authenticate: Bearer authorization_uri=""https://login.microsoftonline.com/common"", error=""invalid_token"", errordescription=""The issuer '(null)' is invalid"" Content-Length: 0 }"

My questions are:

  1. Where the NetDefaultDB database name is coming from?
  2. Why it accepts only my username and give me no change to provide my password?
  3. What do I do wrong here?
yogilad commented 1 year ago

If you struggle with manually configuring the app, you can use this wizard to generate the config json from UX. C# Sample App Generator

User Authentication ought to promot you in a new windows or browser page for credentials. Typing the credentials in the app does nothing, as the prompts are only there as mere guidence. If the login UX does not pop out, please let us know.

yogilad commented 1 year ago

By the way, this is all described in detail in the readme file found in the sample app folder.

https://github.com/Azure/azure-kusto-samples-dotnet/tree/master/client/QuickStart

yogilad commented 1 year ago

If there's no further issues, I'm closing this.

securigy commented 1 year ago

Well, that's an easy solution - closing it. The fact remains the same - QuickStart sample does not work... Did you try it? If not, please do. If it works for you then "It is working on my machine" approach" means that there is a piece of information that was not provided or explained to potential users...

yogilad commented 1 year ago

Hi @securigy , Rereading your second to last response you did not fill in all the required parameters. I suggest you skip the manual labor and use the sample generator wizard I linked above. It will create the configuration file for you.

And, yes - we did try the app :)