cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper IV
Helper IV

dir.create in R is not working for Power BI service.

Hi,

 

I have a R visual which creates a directory in your local using dir.create(C:/foldername) and it is working fine in Power Bi desktop but same when deployed in Power Bi service, it is throwing me an error like C:/foldername does not exist. That means it is not creating directory. 

 

Could you please help me fix the solution for this.

 

Thanks,

Shubham

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Resident Rockstar
Resident Rockstar

Re: dir.create in R is not working for Power BI service.

Hi @ShubhamK ,

 

Sorry for the delay. I may misunderstand your scenario before.

 

By my research for your sceanrio, I'm afraid that we cannot show your desired output in Power BI Service based on R scripts security.

 

  • R visuals are created from R scripts, which could potentially contain code with security or privacy risks.
  • These risks mainly exist in the authoring phase when the script author run the script on their own computer.
  • The Power BI service applies a sandbox technology to protect users and the service from security risks.
  • This sandbox approach imposes some restrictions on the R scripts running in the Power BI service, such as accessing the Internet, or accessing to other resources that are not required to create the R visual.

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Highlighted
Resident Rockstar
Resident Rockstar

Re: dir.create in R is not working for Power BI service.

Hi @ShubhamK ,

 

By my tests with the latest version of Power BI Desktop, it seems that everything works as expected.

 

Untitled.png

 

Here is my setting.

 

setting.PNG

 

If you still need help, please share a dummy pbix file which can reproduce the issue, so that we can help further investigate on it? You can upload it to OneDrive and post the link here. Do mask sensitive data before uploading.)

 

You also could have a test with my test pbix file.

 

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Helper IV
Helper IV

Re: dir.create in R is not working for Power BI service.

Thanks @v-piga-msft  for your reply.


RCode.PNG

 

My code works in a following : - first it will create a directory if it does not exists. then if it exisits then Message will be printed as  "Folder exists" else Message will be printed as "Folder does not exists". Ideally it should never go into else part because i am creating my direcory in the first line.

It does work fine in Power BI desktop as you can see the result in the above image itself.

When i publish to Power BI services, it does not creates the directory and falls in to the else part. Please find below image :

RCode_Service.PNG

 

Please find the below full R code and can you please replicate the same. Just copy-paste it into R visual script and pass 1 dummy column. It will be very helpful for me.

# Sheet name
ExportSheet    =  "Sheet 1"
# Appends data to existing file or overwrites existing fle
AppendToPreviousFile  = FALSE
# Includes header. Better to set to false if AppendToPreviousFile is TRUE
WithHeader    = TRUE  

### Export functions ##################################################################################

Message <- function(Text,Comment) { 
    
    par(mar=c(1,1,1,1)) 
    NoPlot = c(0) 
    barplot(NoPlot)
    plot(1:1, 1:1, main = "", sub = "", fg="white")
    text(1, 1.2, Text, cex = 2, fg="white")
    text(1, 0.8, Comment, cex = 1.5, fg="white")
    return()
}
ExportFile   = "C:/RData/AssetData.xlsx"
dir.create("C:/RData/")  #This creates a folder if not exists
ExportFolder = dirname(ExportFile)
if (dir.exists(ExportFolder)){     #If folder exists then execute below code
    Message("Folder  exist",ExportFolder)
} else {                           #else
    Message("Folder does not exist",ExportFolder)
}

 

Highlighted
Helper IV
Helper IV

Re: dir.create in R is not working for Power BI service.

@v-piga-msft  Could you please replicate the same and see if it is possible to solve or not. I really need help on this. 

 

Thanks in advance.

Highlighted
Resident Rockstar
Resident Rockstar

Re: dir.create in R is not working for Power BI service.

Hi @ShubhamK ,

 

Sorry for the delay. I may misunderstand your scenario before.

 

By my research for your sceanrio, I'm afraid that we cannot show your desired output in Power BI Service based on R scripts security.

 

  • R visuals are created from R scripts, which could potentially contain code with security or privacy risks.
  • These risks mainly exist in the authoring phase when the script author run the script on their own computer.
  • The Power BI service applies a sandbox technology to protect users and the service from security risks.
  • This sandbox approach imposes some restrictions on the R scripts running in the Power BI service, such as accessing the Internet, or accessing to other resources that are not required to create the R visual.

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors