It sounds like your Python application built by flask-appbuilder was deployed on Azure WebApp for Windows, but not works.
There are my answers for two existing SO threads Hosting Flask(Python) app throws CGI error and Hosting Flask(python) API on Azure API.
I tried to create a demo via flask-appbuilder in Python 3 and deploy it to Azure WebApp for Windows, then it works fine. Here is my steps below which you can refer to.
I create a virtual environment for this demo via the commands below on my local machine that I have installed Python 3 runtime and virtualenv via pip install virtualenv.
virtualenv demo
cd demo
bin\activate.bat
pip install flask-appbuilder
fabmanager create-app # use `demoapp` as the `Your new app name` input
cd demoapp
To create admin with all default options and a simple password via fabmanager create-admin.
Username [admin]:
User first name [admin]:
User last name [user]:
Email [admin@fab.org]:
Password:
Repeat for confirmation:
D:\<your path>\demo\demoapp\lib\python3.6\site-packages\flask_sqlalchemy\__init__.py:794: FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True or False to suppress this warning.
'SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and '
2019-02-21 15:29:55,309:INFO:flask_appbuilder.security.sqla.manager:Security DB not found Creating all Models from Base
2019-02-21 15:29:55,334:INFO:flask_appbuilder.security.sqla.manager:Security DB Created
.......
- I run the
demoapp via fabmanager run and it works on my local.
- Then, I drag all my directories and files of
demoapp that include app.db into my Azure WebApp via Kudo Console https://<your webapp name>.scm.azurewebsites.net/DebugConsole.
Due to not directly install the app dependencies for flash-appbuilder, I installed a Python 3 runtime in the Site extensions of Kudu, as the figure below.

Continues, I back to Kudu Console and run the commands below to install flask-appbuilder.
D:\home>cd python364x64
D:\home\python364x64>python -V
Python 3.6.4
D:\home\python364x64>pip install flask-appbuilder
Collecting flask-appbuilder
Downloading https://files.pythonhosted.org/packages/3a/b0/edb3e54241203266222c4863ae6eb30fd49f5d331a117b61f1801e8124da/Flask-AppBuilder-1.12.3.tar.gz (2.3MB)
Requirement already satisfied: colorama<1,>=0.3.9 in d:\home\python364x86\lib\site-packages (from flask-appbuilder) (0.4.1)
Requirement already satisfied: click<8,>=6.7 in d:\home\python364x86\lib\site-packages (from flask-appbuilder) (7.0)
......
Then, to move into site\wwwroot to create & configure a web.config file and change the code in run.py. There are two ways to make it works, as below.
- Not using WSGI. The default port of Azure WebApp is depended on the environment variable
HTTP_PLATFORM_PORT which be set by IIS on Azure. So we need to change the port parameter of app.run method in run.py and configure web.config as below.
The run.py code changed as below:
from app import app
import os
app.run(port=int(os.environ['HTTP_PLATFORM_PORT']))
And the web.config content as below:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="PYTHONPATH" value="D:\home\site\wwwroot" />
<add key="PATH" value="D:\home\python364x64;D:\home\python364x64\Scripts;%PATH%" />
</appSettings>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="D:\home\python364x64\python.exe" arguments="D:\home\site\wwwroot\run.py --port %HTTP_PLATFORM_PORT%" stdoutLogEnabled="true" startupRetryCount='10'>
</httpPlatform>
</system.webServer>
</configuration>
- Using WSGI server instead for production environment.
The run.py code as below.
from app import app
app.run()
And the web.config content as below.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="PYTHONPATH" value="D:\home\site\wwwroot" />
<add key="WSGI_HANDLER" value="app.app" />
</appSettings>
<system.webServer>
<handlers>
<add name="PythonHandler" path="*" verb="*" modules="FastCgiModule" scriptProcessor="D:\home\python364x64\python.exe|D:\home\python364x64\wfastcgi.py" resourceType="Unspecified" requireAccess="Script"/>
</handlers>
</system.webServer>
</configuration>
It works via access https://<your app name>.azurewebsites.net
