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:
- Microsoft.AnalysisServices.Core.DLL - Ver. 14.0.800.117
- Microsoft.AnalysisServices.Tabular.DLL - Ver 14.0.800.117
- Microsoft.AnalysisServices.AdomdClient.dll - Ver 14.0.801.241