This blog will demonstrate on how to connect Azure SQL database from Python Function App using managed identity or access token. If you are looking for how to implement it in Windows App Service, you...
Up to now, I've been developing locally using the token, no issues. Now I've published the function to Azure. I am receiving an error:
AttributeError: 'NoneType' object has no attribute 'cursor'
eventually pointing `cursor = conn.cursor()` in the stack trace. This same code runs perfectly on localhost with token.
I have verified that the System Assigned Managed Identity (SAMI) is turned on, my user is SQL Admin, and the SQL User and Groups have been correctly added.
I noticed that there is no env variable named "MSI_SECRET" under the Configuration blade of the Function.
Is this env var supposed to be visible when SAMI is turned on?
How should I troubleshoot this error?
UPDATE 1:
- I put some logging in after the Python function below. get_sql_connection() returns "None".
- It appears that the Azure Function is not picking up the SAMI.