I am trying to connect a Django application from local windows laptop to Azure SQL Managed Instance with AD authentication in place. Here, we are trying to connect to the Azure SQL to develop our REST APIs. I have the necessary permissions for the SQL as I have been configured to connect it from SSMS with same credentials.
I am trying to use ActiveDirectoryPassword as mentioned here. Microsoft docs to connect to Azure MI. My db settings in settings.py is as follows:
DATABASES = {
'default': {
'ENGINE': 'sql_server.pyodbc',
'NAME': 'XXXX/db name',
'USER': 'xxxx.xxxx@xxxx.com',
'PASSWORD': 'XXXXXX',
'HOST': 'tcp:XXX.public.XXXX.database.windows.net',
'PORT': '3342',
'OPTIONS': {'driver':'ODBC Driver 17 for SQL Server',
'extra_params': 'Authentication=ActiveDirectoryPassword',
},},}
Getting below error:
django.db.utils.Error: (‘FA004’, "[FA004] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Failed to authenticate the user ‘XXXX.XXXX@XXXXXXXX.com’ in Active Directory (Authentication option is ‘ActiveDirectoryPassword’).\r\nError code 0xCAA2000C; state 10\r\nAADSTS50076: 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
This the setting that we have chosen while creating the managed instance.
Please guide on how to connect to sql db in managed instance.
Thanks.