This is a question about using Python 3.12 to get data from an Azure Synapse database. I’m using Python on Windows 10 with task scheduler to run some programs.
It seems this week Azure Synapse, where we host our data, has changed security requirements to require Two Factory Authentication (2FA). This means my Python programs are not able to run unattended at scheduled times.
I have a variable called “options” which is passed to nearly every function and contains a connection object to the Azure Synapse db which is an MS SQL Server. I use pyodbc to connect. The connection uses a connection string like this: options.connstring = f'DRIVER={options.dbdriverstring};SERVER={options.pacedbhost};DATABASE={options.pacedbname};UID={options.pacedbuser};PWD={options.pacedbpassword};PORT={options.pacedbport};Authentication=ActiveDirectoryPassword'
. Several important values are stored in variables.
And code like this:
options.conn = pyodbc.connect(options.connstring)
if not options.conn:
errstr = f"ERROR: connection not made to database {options.pacedbhost}"
writeerr(f"{errstr}")
sys.exit()
I was never trained in security or know much about the Azure Synapse db we use and I’m not its admin.
Here’s the error from pyodbc:
pyodbc.Error: ('FA004', "[FA004] [Microsoft][ODBC Driver 18 for SQL Server][SQL Server]Failed to authenticate the user 'myemail@yyy.com' in Active Directory (Authentication option is 'ActiveDirectoryPassword').
Error code 0xCAA2000C; state 10
AADSTS50076: Due to a configuration change made by your administrator, or because you moved to a new location, you must use multi-factor authentication to access 'long-letters-and-numbers'. Trace ID: b43e37b2-7b67-4abe-9951-4f1eb1001700 Correlation ID: 82bb87df-6802-4734-8101-669d2b834974 Timestamp: 2025-07-10 12:58:41Z (0) (SQLDriverConnect);
[FA004] [Microsoft][ODBC Driver 18 for SQL Server]Invalid connection string attribute (0);
[FA004] [Microsoft][ODBC Driver 18 for SQL Server][SQL Server]Failed to authenticate the user 'myemail@yyy.com' in Active Directory (Authentication option is 'ActiveDirectoryPassword').
Error code 0xCAA2000C; state 10
AADSTS50076: Due to a configuration change made by your administrator, or because you moved to a new location, you must use multi-factor authentication to access 'long-letters-and-numbers'. Trace ID: b43e37b2-7b67-4abe-9951-4f1eb1001700 Correlation ID: 82bb87df-6802-4734-8101-669d2b834974 Timestamp: 2025-07-10 12:58:41Z (0);
[FA004] [Microsoft][ODBC Driver 18 for SQL Server]Invalid connection string attribute (0)")
Questions
- Do you know if Microsoft changed something at a global level for Azure Synapse databases?
- Did they stop supporting an ODBC connection with pyodbc?
- How do I connect to our db now? This will have to run as a scheduled task with no user interaction.
Thank you.