we have got the service account from Azure admin, and we are trying to connect to Azure SQL database using that service account from r / r studio. Below is the snippet of code. Below is the sample connection string, i replace the actual value with dummy values (eg. XXX)
if (!require("odbc")) {
install.packages("odbc")
library(odbc)
}
if (!require("DBI")) {
install.packages("DBI")
library(odbc)
}
if (!require("RODBC")) {
install.packages("RODBC")
library(RODBC)
}
odbcDriverConnect("Driver={ODBC Driver 17 for SQL Server};Server=tcp:XXX.database.windows.net,1433;Database=XXXdb;Authentication=ActiveDirectoryPassword;UID=abc.mae@abc.com;PWD=yourpwd;")
It is perfectly working and connecting to database while running from R studio.
The requirement is to schedule the R code via batch (.bat) file, when we try to run the same r script via bat file, we are getting below error:
Server]Failed to authenticate the user ‘#usename' in Active Directory (Authentication option is 'ActiveDirectoryPassword').
Error code 0x800401F0; state 10
CoInitialize has not been called
User contributions licensed under CC BY-SA 3.0