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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register 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
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

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.