Closed satindra75 closed 1 year ago
@satindra75 Thanks for creating this issue!
On running it never prompt for authentication
Based on your code snippet, it looks like you are using Hosted Service to run this functionality. In this case, I'm not sure .WithAadUserPromptAuthentication
type of authentication will work, because this approach requires manual user prompt. This type of authentication is useful for demonstration purposes, but it is not recommended in production scenarios.
If you want to test Kusto connector with this type of authentication, you can use following example, if you uncomment KustoMemoryStore. When you run it, a new tab will be opened in your browser to login with your account, which has access to Kusto DB (I just verified this example and it's working as expected): https://github.com/microsoft/semantic-kernel/blob/main/dotnet/samples/KernelSyntaxExamples/Example15_TextMemorySkill.cs
If you want to test the functionality with Hosted Service, you can try another type of authentication, more examples here: https://learn.microsoft.com/en-us/azure/data-explorer/kusto/api/connection-strings/kusto#examples
Authentication with application key should work fine, if you have AAD application, which has permissions to access your Kusto DB (.WithAadApplicationKeyAuthentication(appId, appKey, authority)
).
@satindra75 I will close this issue based on response here and in private conversation. Feel free to re-open it or create a new one in case you encounter any issues. Thank you!
I followed readme @ https://github.com/microsoft/semantic-kernel/tree/main/dotnet/src/Connectors/Connectors.Memory.Kusto#microsoftsemantickernelconnectorsmemorykusto.
Please find the code snippet below. The code is compiling and running fine. On running it never prompt for authentication and when my prompt was to fetch top 10 row from a Kusto table in the db, instead of returning data, it returned query to fetch data from the Kusto table. Could you please let me know if I am missing anything here?
Code Snippet: using Kusto.Data; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.SemanticKernel; using Microsoft.SemanticKernel.Connectors.Memory.Kusto; using Skills;
// Load the kernel settings var kernelSettings = KernelSettings.LoadSettings();
var kustoConnectionStringBuilder = new KustoConnectionStringBuilder(kustoUri).WithAadUserPromptAuthentication(authority); KustoMemoryStore memoryStore = new(kustoConnectionStringBuilder, databaseName);
// Create the host builder with logging configured from the kernel settings. var builder = Host.CreateDefaultBuilder(args) .ConfigureLogging(logging => { logging.ClearProviders(); logging.AddConsole(); logging.SetMinimumLevel(kernelSettings.LogLevel ?? LogLevel.Warning); });
builder.ConfigureServices((context, services) => { var kernel = Kernel.Builder .WithAzureTextEmbeddingGenerationService("text-embedding-ada-002", endpoint, key) .WithAzureChatCompletionService("gpt-35-turbo", endpoint, key) .WithMemoryStorage(memoryStore) .Build();
// Add the primary hosted service to the host builder to start the loop. services.AddHostedService();
});
// Build and run the host. This keeps the app running using the HostedService. var host = builder.Build(); await host.RunAsync();