0

I am currently deploying an R microservice to azure functions but I am running into some issues. I installed the R executable from the azure site extensions and I am running my R script with this R executable using PowerShell.

The script runs entirely but I get some strange errors that don't seem to come from my R script, but are specific PowerShell errors. Here are the logs I get:

2018-06-11T15:37:14.373 [Info] PowerShell Timer trigger function executed at:06/11/2018 15:37:14

2018-06-11T15:37:17.924 [Info] [1] "Retrieving data"

2018-06-11T15:37:18.158 [Error] D:\home\R-3.3.3\bin\x64\Rscript.exe : Loading required package: methods

at run.ps1: line 4

+ D:\home\R-3.3.3\bin\x64\Rscript.exe

+ ___________________________________

    + CategoryInfo          : NotSpecified: (Loading required package: methods:String) [], RemoteException

    + FullyQualifiedErrorId : NativeCommandError


at run.ps1: line 4

+ D:\home\R-3.3.3\bin\x64\Rscript.exe

+ ___________________________________

    + CategoryInfo          : NotSpecified: (:) [], RemoteException

    + FullyQualifiedErrorId : NativeCommandErrorMessage


at run.ps1: line 4

+ D:\home\R-3.3.3\bin\x64\Rscript.exe

+ ___________________________________

    + CategoryInfo          : NotSpecified: (:) [], RemoteException

    + FullyQualifiedErrorId : NativeCommandErrorMessage

2018-06-11T15:37:20.837 [Info] [1] "Finished retrieving data, computing first function"

2018-06-11T15:37:21.040 [Info] [1] "2nd function.."

2018-06-11T15:37:21.040 [Info] [1] "3rd function.."

2018-06-11T15:37:21.061 [Info] [1] "last function.."

2018-06-11T15:37:21.061 [Info] [1] "Finished everything"


at run.ps1: line 4

+ D:\home\R-3.3.3\bin\x64\Rscript.exe

+ ___________________________________

    + CategoryInfo          : NotSpecified: (:) [], RemoteException

    + FullyQualifiedErrorId : NativeCommandErrorMessage

2018-06-11T15:37:21.290 [Error] Exception while executing function: Functions.TimerTriggerEngagement. Microsoft.Azure.WebJobs.Script: PowerShell script error. Loading required package: methods.

2018-06-11T15:37:21.337 [Error] Function completed (Failure, Id=..., Duration=7114ms)

My PowerShell script run is simply:

cd D:\home\site\wwwroot\microservices
D:\home\R-3.3.3\bin\x64\Rscript.exe engagement.r

When I run my script inside of RStudio for example, I have no warning/error. Any clues ? An explanation of these errors ?

Edit (Answer)

As ahmelsayed pointed out, this is an odd behavior of powershell in azure. By running some tests, a code as simple as

library('httr')
library('parsedate')
library('jsonlite')
print('Testing the azure functions')

for (i in 1:10){
    print(i)
}

returns

2018-06-18T09:43:08.204 [Error] D:\home\R-3.3.3\bin\x64\Rscript.exe : Loading required package: methods

at run.ps1: line 4

+ D:\home\R-3.3.3\bin\x64\Rscript.exe

+ ___________________________________

    + CategoryInfo          : NotSpecified: (Loading required package: methods:String) [], RemoteException

    + FullyQualifiedErrorId : NativeCommandError

2018-06-18T09:43:09.003 [Info] [1] "Testing the azure functions"

2018-06-18T09:43:09.048 [Info] [1] 1

2018-06-18T09:43:09.048 [Info] [1] 2

2018-06-18T09:43:09.048 [Info] [1] 3

2018-06-18T09:43:09.048 [Info] [1] 4

2018-06-18T09:43:09.048 [Info] [1] 5

2018-06-18T09:43:09.048 [Info] [1] 6

2018-06-18T09:43:09.048 [Info] [1] 7

2018-06-18T09:43:09.048 [Info] [1] 8

2018-06-18T09:43:09.081 [Info] [1] 9

2018-06-18T09:43:09.081 [Info] [1] 10

2018-06-18T09:43:09.173 [Error] Exception while executing function: Functions.TimerTriggerTest. Microsoft.Azure.WebJobs.Script: PowerShell script error. Loading required package: methods.

2018-06-18T09:43:09.220 [Error] Function completed (Failure, Id=..., Duration=5223ms)

It seems that just loading a few packages in R and running simple code generates an error in Powershell, even if all packages are loaded correctly and the code runs fine.

Cédric
  • 3
  • 3
  • Can you post *engagement.r* script or at least a small enough example to reproduce? Also use `cat` in R over `print` to avoid the vector `[1]` outputs. Other than log files, does the console show anything? – Parfait Jun 11 '18 at 15:55

1 Answers1

0

I think this is just odd behavior from powershell depending on the io host it's using. see this question and the accepted answer Error when calling 3rd party executable from Powershell when using an IDE

ahmelsayed
  • 7,125
  • 3
  • 28
  • 40