Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.

Reply
Vinodh247
Resolver II
Resolver II

Connect Fabric database from R studio

How to connect Fabric lakehouse db from R studio?

 

We have this requirement to access lakehouse db from within R studio. I searched and didnt find anything related to this, is there any workaround for this currently?

3 REPLIES 3
spencer_sa
Super User
Super User

Similar to the above two posts, we've used the ODBC driver.  For the proof of concept I used the AZ command line interface (AZCLI) tool to get a token as a user (so authenticating via web client) and then using that token with DBI.
(Incidentally, this is also how I've got the initial Fabric -> Alteryx connection working until I get the ADFS connection behaving)

FlavioLeccese
Frequent Visitor

As an R user i would suggest you to use DBI and dbplyr.

 

- You can retrieve sql endpoint of that lakehouse
- Create a Service Principal in Azure and use it as a "super user" (https://learn.microsoft.com/it-it/entra/identity-platform/app-objects-and-service-principals?tabs=br...)

 

# r code:

driver <- "ODBC Driver 18 for SQL Server"
server <- "put here the sql end point of lakehouse"
database <- "lakehouse, ie database name"
authentication <- "ActiveDirectoryServicePrincipal"
encrypt <- "True"
userid <- "id of the Service Principal"
password <- "Password of the Service Principal"
port <- 1433

connection_string <- glue("Driver={driver}; Server={server}; UID={userid}; PWD={password}; Port={port}; Database={database}; Encoding=UTF-8; Authentication={authentication}")

con <- DBI::dbConnect(odbc::odbc(), .connection_string = connection_string)

 

This is a clean way and you can read tables also from outside MS Fabric, however, as far as I discovered, you won't be able to write but only to read

Anonymous
Not applicable

Hi, @Vinodh247 

The following post tries to use RStudio to connect to Endpoint, you can try to test the connection using her method, whether this can give you inspiration.
Microsoft Fabric to RStudio Desktop - RStudio IDE - Posit Community

Also, the current version of Notebook supports the use of Visual Studio, so you can try using it too.


vyaningymsft_0-1725438724147.png

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Helpful resources

Announcements
FBCApril_Carousel

Fabric Monthly Update - April 2025

Check out the April 2025 Fabric update to learn about new features.

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

Find out what's new and trending in the Fabric community.