4
votes

I am new to analysis services on azure and trying to query it using AdomdClient. I downloaded the latest client libraries from here :

https://docs.microsoft.com/en-us/azure/analysis-services/analysis-services-data-providers

What I tried :

  • I am able to connect to the model from SSMS after I installed the necessary SQL Server Data Tools.
  • I am able to connect and query without any issue in a simple WebApi with no other dependency using reference to the client libraries
  • I am NOT able to connect and query when the project has a dependency to Microsoft.IdentityModel.Clients.ActiveDirectory with version higher than 2.8

However while connecting to the instance in C#

        using (var conn 
        = new Microsoft.AnalysisServices.AdomdClient.AdomdConnection(
            ConfigurationManager.ConnectionStrings["dax"].ConnectionString))
        {
            conn.Open();

            conn.Close();
        }

I get the following error :

"Message": "An error has occurred.",
  "ExceptionMessage": "Authentication failed: Microsoft.IdentityModel.Clients.ActiveDirectory failed to load 'Microsoft.IdentityModel.Clients.ActiveDirectory.PromptBehavior type'.",
  "ExceptionType": "Microsoft.AnalysisServices.AdomdClient.AdomdConnectionException",
  "StackTrace": "
   at Microsoft.AnalysisServices.AdomdClient.AdalRuntimeLibrary.LoadAndValidateType(Assembly assembly, String typeName)
   at Microsoft.AnalysisServices.AdomdClient.AdalRuntimeLibrary.LoadAuthenticationContextTypes(Assembly assembly)
   at Microsoft.AnalysisServices.AdomdClient.AdalRuntimeLibrary..ctor()
   at Microsoft.AnalysisServices.AdomdClient.AdalRuntimeLibrary.get_Instance()
   at Microsoft.AnalysisServices.AdomdClient.AadAuthenticator.AcquireToken(Uri dataSourceUri, String dataSource, String identityProvider, String userId, String password, Boolean useAdalCache)
   at Microsoft.AnalysisServices.AdomdClient.XmlaClient.OpenHttpConnection(ConnectionInfo connectionInfo, Boolean& isSessionTokenNeeded)
   at Microsoft.AnalysisServices.AdomdClient.XmlaClient.OpenConnection(ConnectionInfo connectionInfo, Boolean& isSessionTokenNeeded)
   at Microsoft.AnalysisServices.AdomdClient.XmlaClient.Connect(ConnectionInfo connectionInfo, Boolean beginSession)
   at Microsoft.AnalysisServices.AdomdClient.AdomdConnection.XmlaClientProvider.Connect(Boolean toIXMLA)
   at Microsoft.AnalysisServices.AdomdClient.AdomdConnection.ConnectToXMLA(Boolean createSession, Boolean isHTTP)
   at Microsoft.AnalysisServices.AdomdClient.AdomdConnection.Open()
   at ...
  • After little bit of digging a bunch of us realized the AdomdClient dll has a reference to an embedded ActiveDirectory dll inside the dll which references version 2.8.*
  • I cannot lower the version to Microsoft.IdentityModel.Clients.ActiveDirectory since few of the nugets that I use explicitly restrict lowest version to 3.x which definitely changed the Microsoft.IdentityModel.Clients.ActiveDirectory.PromptBehavior that comes up in the error.

Is there a way around this ?

1
Did you found a workaround? I am facing the same issueirgnosis

1 Answers

1
votes

I had a similar issue. While other projects in my solution referred to ActiveDirectory versions > 3.0, AdomdClient needs <2.8. Adding a binding redirect like below to the app.config fixed my problem. This will let other dlls use >3.0 versions of ActiveDirectory, but AdomdClient can use 2.8.x

      <dependentAssembly>       
        <assemblyIdentity name="Microsoft.IdentityModel.Clients.ActiveDirectory" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="3.0.0.0-3.19.8.16603" newVersion="3.19.8.16603" />
      </dependentAssembly>