Search code examples
.netazureazure-functionsazure-api-appsazure-analysis-services

Consume Azure Analysis Services data from Azure Web APIs


I have an Azure analysis service model which I am trying to query from an Azure Web API/ Azure Functions using ADOMD and Dax queries. I am not able to find any nuget packages which can work with Azure Analysis server & the only thing I can find is below:

https://learn.microsoft.com/en-us/azure/analysis-services/analysis-services-connect

I followed the above post & installed the client components and I am able to connect to Azure AS from my local computer using a console app. But my end goal is to connect to Azure AS from an Azure WebAPI and AFAIK I won't be able to install the client components there. Please share any info if you have worked in Azure Analysis service + Azure Web APIs.

Thanks


Solution

  • Just tested it out in Azure WEB APIs and ADOMD works by just adding reference to latest Microsoft.AnalysisServices.AdomdClient dll (Version:14.0.0.0). Sample code:

    var connectionString = $"Provider=MSOLAP;Data Source=asazure://<azure location>.asazure.windows.net/<SSAS name>;Initial Catalog=adventureworks;User ID=<userid>;Password=****;Persist Security Info=True;Impersonation Level=Impersonate";
                var ssasConnection = new AdomdConnection(connectionString);
                ssasConnection.Open();
                var query = @"EVALUATE(Customer)";
                var cmd = new AdomdCommand(query)
                {
                    Connection = ssasConnection
                };
                using (var reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        for (var i=0;i<reader.FieldCount;i++)
                        {
                            Console.WriteLine(reader[i]);
                        }
                        break;
                    }
                }
    

    My blog about the same: https://unnieayilliath.com/2017/11/12/connecting-to-azure-analysis-services-using-adomd/