I'm working on some new data and i'm trying to save it to Azure SQL Database. I got it working by SQL-Authentification. But now i want to build up a connection based on the azure integrated rbac.
Here is the function i use for SQL that works.
def azure_sql_engine(host,db,user,pwd):
driver = '{ODBC Driver 18 for SQL Server}'
connection_string = f'Driver={driver};Server=tcp:{host}.database.windows.net,1433;Database={db};Uid={user};Pwd={pwd};Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;'
engine = create_engine(f"mssql+pyodbc:///?odbc_connect={parse.quote_plus(connection_string)}", fast_executemany=True)
return engine
This is the connection string for integrated
Driver={ODBC Driver 18 for SQL Server};Server=tcp:.database.windows.net,1433;Database=;Uid=;Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;Authentication=ActiveDirectoryIntegrated
I am getting errors regarding to MFA with the code FA004.
Intend to use this for security reasons. In the end i want to build a (Azure) Function to schedule my Notebook as a cron job.
Any ideas on this one?
Tested with pyodbc and sqlalchemy. In VS code i tested also to Sign In on Azure.

