Skip to content

Commit 41a3048

Browse files
committed
Startup file.
1 parent 8e3e360 commit 41a3048

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

azureproject/get_conn.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,10 @@
33
from azure.identity import DefaultAzureCredential
44

55
def get_conn():
6-
if 'WEBSITE_HOSTNAME' in os.environ:
7-
# Azure hosted, refresh token that becomes password.
8-
azure_credential = DefaultAzureCredential()
9-
# Get token for Azure Database for PostgreSQL
10-
print("Get password token.")
11-
token = azure_credential.get_token("https://ossrdbms-aad.database.windows.net")
12-
conn = str(current_app.config.get('DATABASE_URI')).replace('PASSWORDORTOKEN', token.token)
13-
return conn
14-
else:
15-
# Locally, read password from environment variable.
16-
print("Read password env variable.")
17-
conn = str(current_app.config.get('DATABASE_URI')).replace('PASSWORDORTOKEN', os.environ['DBPASS'])
18-
return conn
6+
# Azure hosted, refresh token that becomes password.
7+
azure_credential = DefaultAzureCredential()
8+
# Get token for Azure Database for PostgreSQL
9+
print("Get password token.")
10+
token = azure_credential.get_token("https://ossrdbms-aad.database.windows.net/.default")
11+
conn = str(current_app.config.get('DATABASE_URI')).replace('PASSWORDORTOKEN', token.token)
12+
return conn

start.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash -v
2+
pip install -r requirements.txt
3+
4+
flask db upgrade
5+
6+
gunicorn --workers 2 --threads 4 --timeout 60 --access-logfile '-' --error-logfile '-' --bind=0.0.0.0:5000 --chdir=/home/site/wwwroot app:app

0 commit comments

Comments
 (0)