I've tried for 3 days now and can't get this to work. I am following this tutorial from microsoft docs: https://docs.microsoft.com/en-us/azure/app-service-web/web-sites-python-create-deploy-django-app
EDIT: I am using the windows command line option, NOT the Visual Studio. I am starting with the PTVS python/django template in azure marketplace as suggested by the tutorial.
The app works fine with sql lite, but when I change it to the sql server, it stops working with the following error:
django.core.exceptions.ImproperlyConfigured: 'sql_server.pyodbc' isn't an available database backend.
Try using 'django.db.backends.XXX', where XXX is one of:
'mysql', 'oracle', 'postgresql', 'sqlite3'
Error was: No module named 'sql_server'
2017-04-27 04:34:34.525084: wfastcgi.py 2.1.1 closed
The app works for me locally by connecting to the same remote sql azure db, so the problem is definitely azure. I got the same error locally till I installed pyodbc-azure (https://github.com/michiya/django-pyodbc-azure). As suggested by Microsoft docs, and the library docs, the following is my Database connection specification in settings.py:
DATABASES = {
'default': {
'ENGINE': 'sql_server.pyodbc',
'NAME': 'django-myorg',
'USER': 'riz',
'PASSWORD': '#######',
'HOST': 'django-myorg.database.windows.net',
'PORT': '',
'OPTIONS': {
'driver': 'ODBC Driver 13 for SQL Server',
},
},
}
This is my third try setting this up, and I am frustrated by the lack of up-to-date documentation on Microsoft's part.
I have tried troubleshooting where I could by following this guide: https://docs.microsoft.com/en-us/azure/app-service-web/web-sites-python-configure. I've tried building wheels for all the required libraries, but still having the same issue. I have a feeling it's one of the pyodbc libraries that Azure is not able to get by using pip.
Update: I removed .skipPythonDepolyment which was included by default in the PTVS template provided by azure for django. This prompted azure to actually try and install libraries listed in requirements.txt. This is the latest error according to pip.log:
running build
running build_ext
building 'pyodbc' extension
error: Unable to find vcvarsall.bat
this seems to be trying to build pyodbc but fails. Not sure what I can do at this point.
NAME
,USER
&HOST
insettings.py
. Please check them with your SQL Azure connection string which looks likeDriver={ODBC Driver 13 for SQL Server};Server=tcp:<db-server>.database.windows.net,1433;Database=<db-name>;Uid=<user>@<db-server>;Pwd={your_password_here};Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;
Also you can refer to the other SO thread stackoverflow.com/questions/20666043/… – Peter Pan