Error Message = "A connection cannot be made. Ensure that the server is running." while connecting to azure analysis service using C#.

  • Thread starter Thread starter Poorva Sudame
  • Start date Start date
P

Poorva Sudame

Guest
Hi,

I am trying to connect to azure analysis service and fire an MDX query to get the metadata of the cube such as columns, their datatype, precision and scaling.

The idea is to connect to AAS and fire DMV queries to do so.

I am using following code:

var token = await ADALTokenHelper.GetAppOnlyAccessToken(domain, $"https://{ssasUrl}", tenantid, ServicePrincipalID, ServicePrincipalSecret);
Console.WriteLine("token received");
Server as_svr = new Server();
String as_conn_str = $"Data Source={managementServerName};Password={token};Persist Security Info=True;Impersonation Level=Impersonate";
Console.WriteLine("Connecting to DS : " + as_conn_str + "\n");
as_svr.Connect(as_conn_str);


class ADALTokenHelper
{
private static string _authUrl = "Sign in to your account";
public async static Task<string> GetAppOnlyAccessToken(string domain, string resourceUrl, string tenantid,
string clientId,
string clientSecret)
{

var authority = $"{_authUrl}/{tenantid}";
var authContext = new AuthenticationContext(authority);

var clientCred = new ClientCredential(clientId, clientSecret);
AuthenticationResult authenticationResult = await authContext.AcquireTokenAsync(resourceUrl, clientCred);
/
return authenticationResult.AccessToken;
}
}
Please note that:

1. The Azure Analysis server is NOT paused.

2. I have installed latest AMO and ADOMD NUGET packages.

3. The ClientId@TenantId is added as Analysis services admin.

While running the code i am getting following error:

"A connection cannot be made. Ensure that the server is running."


What might be the reason behind this error. Am I missing something?

Is there any other way to get the details of the Cube? If yes, please guide :)


Thanks,

Poorva

Continue reading...
 
Back
Top