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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
Vinodh247
Frequent Visitor

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
Resolver II
Resolver II

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

v-yaningy-msft
Community Support
Community Support

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
Oct Fabric Update Carousel

Fabric Monthly Update - October 2024

Check out the October 2024 Fabric update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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