0

I had previously made a topic here, but I was told that this might be a better place to post my question. I want to know if it was possible to query a table in Azure Analysis Service via C#. I am going to be running the C# program in Azure Functions. I was trying to follow this example, but when I try to run this code, I'm not sure how to reference my table in Azure Analysis Service.

The name of my table is Trans Legacy and when I try to run a simple SQL command of:

SELECT * FROM [Trans Legacy]

I get:

Error: Either the user, 'username', does not have permission to access the referenced mining model, 'Legacy Trans', or the object does not exist.

I'm not sure if this is possible to do or if I am referencing the table correctly.

Thank you.

Edit: Here is my code

/*
This function will create a partition of the fact tables that will contain the current month's data
*/
#r "Microsoft.AnalysisServices.Tabular.DLL"
#r "Microsoft.AnalysisServices.Core.DLL"
#r "Microsoft.AnalysisServices.AdomdClient.dll"
#r "System.Configuration"
using System;
using System.Configuration;
using Microsoft.AnalysisServices.Tabular;
using Microsoft.AnalysisServices.AdomdClient;

public static void Run(string input, TraceWriter log)
{
    log.Info($"C# manually triggered function called with input: {input}");

   var connStr = ConfigurationManager.ConnectionStrings["AAS"].ConnectionString;
   AdomdConnection conn = new AdomdConnection(connStr);
   conn.Open();
   string commandText = @"SELECT 
   year(max(dates)) AS year,
   month(max(dates)) as month
   FROM [Legacy Trans]";
   AdomdCommand cmd = new AdomdCommand(commandText, conn);
   AdomdDataReader dr = cmd.ExecuteReader();
       while (dr.Read())
   {
       Console.WriteLine(Convert.ToString(dr[0]));
   }
   dr.Close();
   conn.Close();
 }    

The ddls that I am using are as follows:

  1. Microsoft.AnalysisServices.Core.DLL - Ver. 14.0.800.117
  2. Microsoft.AnalysisServices.Tabular.DLL - Ver 14.0.800.117
  3. Microsoft.AnalysisServices.AdomdClient.dll - Ver 14.0.801.241
Joel Vega
  • 23
  • 5
  • The error message you're getting sounds like an authentication error. Note that it says `user 'username' does not have permission`. Did you specify a valid username/password in your connection string? – Paul Batum Mar 12 '18 at 18:58
  • @PaulBatum Yes, unless it requires a special formatting for querying. I use the following (which has worked for scheduling automated processing): Provider=MSOLAP;Data Source=_my server_; Initial Catalog=*my database*;User ID=*my username*;Password=*my password* – Joel Vega Mar 12 '18 at 19:12
  • Does this resource help? https://azure.microsoft.com/en-us/blog/automating-azure-analysis-services-processing-with-azure-functions/ – Paul Batum Mar 12 '18 at 19:50
  • No, but thank you. This is actually the article that I used in order to schedule an automated refresh. I am having trouble querying the actual data that is in the tables. I'm not sure if it is even possible, I wanted to see if anyone else has been able to accomplish this. – Joel Vega Mar 13 '18 at 14:21
  • Can you post your code and mention the version and path where you got the referenced DLLs from? – GregGalloway Mar 13 '18 at 15:37

1 Answers1

0

@Joel, I think you are using older versions of client libraries for Azure Aanalysis Services. These need to be version 15.x. Let me know if this works. I am required to do similar thing and doing the research right now.

Refer below link to download client libraries-- https://learn.microsoft.com/en-us/azure/analysis-services/analysis-services-data-providers

Refer below link for similar issue-- Connection String error while using ADOMD.NET to connect to Azure Analysis

Neeraj B
  • 1
  • 1