File tree Expand file tree Collapse file tree 2 files changed +10
-10
lines changed
Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Original file line number Diff line number Diff line change 66ALLOWED_HOSTS = [os .environ ['WEBSITE_HOSTNAME' ]] if 'WEBSITE_HOSTNAME' in os .environ else []
77CSRF_TRUSTED_ORIGINS = ['https://' + os .environ ['WEBSITE_HOSTNAME' ]] if 'WEBSITE_HOSTNAME' in os .environ else []
88
9- # Configure Postgres database; the full username for PostgreSQL flexible server is
10- # username (not @sever-name).
9+ # Configure Postgres database based on connection string of the libpq Keyword/Value form
10+ # https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING
11+ conn_str = os .environ ['AZURE_POSTGRESQL_CONNECTIONSTRING' ]
12+ conn_str_params = {pair .split ('=' )[0 ]: pair .split ('=' )[1 ] for pair in conn_str .split (' ' )}
13+
1114DATABASE_URI = 'postgresql+psycopg2://{dbuser}:{dbpass}@{dbhost}/{dbname}' .format (
12- dbuser = os . environ [ 'DBUSER ' ],
13- dbpass = os . environ [ 'DBPASS ' ],
14- dbhost = os . environ [ 'DBHOST' ] + ".postgres.database.azure.com" ,
15- dbname = os . environ [ 'DBNAME ' ]
15+ dbuser = conn_str_params [ 'user ' ],
16+ dbpass = conn_str_params [ 'password ' ],
17+ dbhost = conn_str_params [ 'host' ] ,
18+ dbname = conn_str_params [ 'dbname ' ]
1619)
Original file line number Diff line number Diff line change @@ -106,10 +106,7 @@ resource web 'Microsoft.Web/sites@2022-03-01' = {
106106 name : 'appsettings'
107107 properties : {
108108 SCM_DO_BUILD_DURING_DEPLOYMENT : 'true'
109- DBHOST : postgresServer .name
110- DBNAME : flaskDatabase .name
111- DBUSER : postgresServer .properties .administratorLogin
112- DBPASS : databasePassword
109+ AZURE_POSTGRESQL_CONNECTIONSTRING : 'dbname=${flaskDatabase .name } host=${postgresServer .name }.postgres.database.azure.com port=5432 sslmode=require user=${postgresServer .properties .administratorLogin } password=${databasePassword }'
113110 SECRET_KEY : secretKey
114111 FLASK_DEBUG : 'False'
115112 }
You can’t perform that action at this time.
0 commit comments