0
votes

"Run time exception AADSTS50079: Due to a configuration change made by your administrator, or because you moved to a new location, you must enroll in multi-factor authentication"

static void Main(string[] args)
{
  var builder = new 
  KustoConnectionStringBuilder("help.kusto.windows.net/Samples")
     {
        FederatedSecurity = true,
        UserID = "***@microsoft.com",
        Password = "****",
        EnforceMfa = true
     };

     var client = 
     Kusto.Data.Net.Client.KustoClientFactory.CreateCslQueryProvider(builder); 
     var reader = client.ExecuteQuery("StormEvents | count");

    }
1
According to the error, it may be caused by Conditional Access. For more details, please refer to github.com/AzureAD/azure-activedirectory-library-for-dotnet/…. - Jim Xu
If so, you can try to close the policy to solve the issue or try to use the following code var kustoConnectionStringBuilder = new KustoConnectionStringBuilder($"https://{serviceNameAndRegion}.kusto.windows.net") { FederatedSecurity = true, InitialCatalog = "NetDefaultDB", Authority = authority, };. For more details, please refer to docs.microsoft.com/en-us/azure/kusto/api/connection-strings/… - Jim Xu

1 Answers

0
votes

If you are microsoft FTE and try to query kusto on a dotNet Core Console Application, I suggest you to use a dotNet Framework Console Application. use

var client = Kusto.Data.Net.Client.KustoClientFactory.CreateCslQueryProvider("https://help.kusto.windows.net/Samples;Fed=true");
var reader = client.ExecuteQuery("MyTable | count");
// Read the first row from reader -- it's 0'th column is the count of records in MyTable
// Don't forget to dispose of reader when done.

see https://docs.microsoft.com/en-us/azure/kusto/api/netfx/about-kusto-data Then it will pop up a window to use VSTS as a multi-factor authentication. It seems that VSTS authentication not support dotNet Core.