I am trying to connect a Django application from local laptop to Azure SQL Managed Instance with AD authentication in place. 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. django-pyodbc-azure 2.1.0.0 docs and microsoft/mssql-django docs. 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
Similar issue has been discussed here.