I tried connecting to a MS SQL database using azureml.dataprep
in an Azure Notebook, as outlined in https://docs.microsoft.com/en-us/azure/machine-learning/service/how-to-load-data#load-sql-data, using MSSqlDataSource, using code of the form
import azureml.dataprep as dprep
secret = dprep.register_secret(value="[SECRET-PASSWORD]", id="[SECRET-ID]")
ds = dprep.MSSQLDataSource(server_name="[SERVER-NAME]",
database_name="[DATABASE-NAME], [PORT]",
user_name="[DATABASE-USERNAME]",
password=secret)
Setting [DATABASE-USERNAME]
equal to MYWINDOWSDOMAIN\\MYWINDOWSUSERNAME
and the password [SECRET-PASSWORD]
coinciding with my Windows password (i.e. trying to use Windows authentication).
After firing a query with
dataflow = dprep.read_sql(ds, "SELECT top 100 * FROM [dbo].[MYTABLE]")
dataflow.head(5)
I get
ExecutionError: Login failed.
I could connect to other databases without Windows Authentication fine. What am I doing wrong?
Consider using SQL server authentication as a workaround/alternative solution to connect to that db (the same
dataflow
syntax will work):Here is the MS Doc on
MSSQLDataSource
.MSSQLDataSource
instances have a property,credentials_type
which defaults toSERVER
. Try explicitly setting this toWINDOWS
before you do your query. Also, the port should be specified together with the server name.