Forum Discussion
Cannot query data from Fabric Lakehouse SQL Analytics Endpoint using Service Principal (only schema)
- 1 year ago
Hi v-dineshya,
Thank's a lot for your answer. After cheking, everything were already done.
But I found a solution. I used the Onelake explorer from my desktop. I wen to the "Files" folder, and I "shared to everybody" that one.
Now, I'm able to run the SQL Query with the Service Principal.
Hi everyone,
I’ve been working with Microsoft Fabric and so far I’ve been able to:
Write parquet files into a Lakehouse (remotely with python/azcopy),
Define views with SQL remotely using OPENROWSET,
To do that, I made connection using a Service Principal (App Registration).
Now I’m trying to query one of these views from the SQL Analytics Endpoint of the Lakehouse.
The view is based on parquet files stored under the Files folder of the Lakehouse.
When I execute a simple SELECT * query on that view via Python (using SQLAlchemy and ODBC, following this guide https://medium.com/@mariusz_kujawski/connect-to-microsoft-fabric-warehouse-using-python-and-sqlalche...), I only get back the columns of the view but 0 rows.
It feels like my Service Principal only has access to the schema (metadata) but not the underlying parquet data when executing queries.
If I run the exact same query from the Fabric web interface or Azure Data Studio (using my user account), the query works perfectly and returns the expected rows.
Has anyone run into this before? Do I need some specific permission to the Service Principal on the Lakehouse / SQL Endpoint ?
Thanks a lot for any guidance!
Your Service Principal sees the schema but returns 0 rows because it lacks access to the underlying parquet data.
Fix:
Grant the SP Data Reader (or Contributor) role on the Lakehouse, including the Files folder.
Ensure it has access to the SQL Analytics Endpoint.
Optionally, add the SP to the workspace hosting the Lakehouse.
Once these permissions are set, queries via the SP will return data.