S-C-O-U-T / Pyadomd

A pythonic approach to query SSAS data models.
https://pyadomd.readthedocs.io/en/latest/index.html
Apache License 2.0
25 stars 6 forks source link

SSAS Authentication issue #4

Closed KamilZet closed 3 years ago

KamilZet commented 3 years ago

Hi

I'm getting the following authentication error when trying to use Pyadomd:

image

Do you know what might be a reason for that?

S-C-O-U-T commented 3 years ago

Hi,

Thanks for raising this incident.

The problem you are facing is not because of the Pyadomd package, but is due to that you have to register you application in Azure Active Directory, and give that App read access to your Azure Analysis Services.

You can follow the Microsoft Documentation of App registration: https://docs.microsoft.com/en-us/azure/analysis-services/analysis-services-addservprinc-admins After you have registered the App you then give access rights on the Azure analysis to the “user”: app:< Application (client) ID>@

With the registered app you must authenticate through the azure-identity package is your python program: https://pypi.org/project/azure-identity/

I’ll update the readme, when I get to it, with the above.

I’m leaving the incident open until then.

/Thanks

S-C-O-U-T commented 3 years ago

The readme file is updated with FAQ

m-janyell0w commented 1 year ago

Hello,

I am using python 3.8 in an anaconda environment on windows 10. I am trying to query a multidimensional SSAS cube using pyadomd. (I have read rights to the cube). This is my code:

import pandas as pd
from sys import path
path.append(r"C:\Program Files\Microsoft.NET\ADOMD.NET\160")
from pyadomd import Pyadomd

conn_str = 'Provider=MSOLAP.8;Data Source=source_name;Integrated Security=SSPI;Initial Catalog=cube_name;'
mdx_query = """SELECT [Measures].[measure] ON COLUMNS
            FROM [cube_name]
            """
with Pyadomd(conn_str) as conn:
    with conn.cursor().execute(mdx_query) as cur:
        df = pd.DataFrame(cur.fetchmany(size=100),
        columns=[i.name for i in cur.description])

I checked that the cube exists and I can acecss it via an excel add-in. However using pyadomd, I get following error:

---------------------------------------------------------------------------
AdomdErrorResponseException               Traceback (most recent call last)
Cell In[12], line 2
      1 with Pyadomd(conn_str) as conn:
----> 2     with conn.cursor().execute(mdx_query) as cur:
      3         df = pd.DataFrame(cur.fetchmany(size=100),
      4         columns=[i.name for i in cur.description])

File [c:\Users\username\Anaconda3\envs\env-name\lib\site-packages\pyadomd\pyadomd.py:67](file:///C:/Users/username/Anaconda3/envs/env-name/lib/site-packages/pyadomd/pyadomd.py:67), in Cursor.execute(self, query)
     61 """
     62 Executes a query against the data source
     63 
     64 :params [query]: The query to be executed
     65 """
     66 self._cmd = AdomdCommand(query, self._conn)
---> 67 self._reader = self._cmd.ExecuteReader()
     68 self._field_count = self._reader.FieldCount
     70 for i in range(self._field_count):

AdomdErrorResponseException: The cube_name-Cube does not exist or has not been processed..
   bei Microsoft.AnalysisServices.AdomdClient.XmlaClient.CheckForSoapFault(XmlReader reader, XmlaResult xmlaResult, Boolean throwIfError)
   bei Microsoft.AnalysisServices.AdomdClient.XmlaClient.CheckForError(XmlReader reader, XmlaResult xmlaResult, Boolean throwIfError)
   bei Microsoft.AnalysisServices.AdomdClient.XmlaClient.SendMessage(Boolean endReceivalIfException, Boolean readSession, Boolean readNamespaceCompatibility)
   bei Microsoft.AnalysisServices.AdomdClient.XmlaClient.ExecuteStatement(String statement, IDictionary connectionProperties, IDictionary commandProperties, IDataParameterCollection parameters, Boolean isMdx)
   bei Microsoft.AnalysisServices.AdomdClient.AdomdConnection.XmlaClientProvider.Microsoft.AnalysisServices.AdomdClient.IExecuteProvider.ExecuteTabular(CommandBehavior behavior, ICommandContentProvider contentProvider, AdomdPropertyCollection commandProperties, IDataParameterCollection parameters)
   bei Microsoft.AnalysisServices.AdomdClient.AdomdCommand.ExecuteReader(CommandBehavior behavior)

Can you hint me toward what could be going wrong? Could it be that I have to register my python-app with de MSSQL Server like you mentioned above? If so, how? I am quite new to MS SQL Server, so I am pretty lost with the error right now.

Thank you! :)