I've been running through the "Deploy a Django application to Azure by using PostgreSQL" MS Learn module (https://learn.microsoft.com/en-gb/learn/modules/django-deployment/) and have encountered myriad issues with deploying/connecting to a PostGres database - specifically the steps located at "Unit 6: Deploy to Azure": https://learn.microsoft.com/en-gb/learn/modules/django-deployment/6-deploy-azure
The codebase use is Microsoft's own "Solution" code for this exercise, found here: https://github.com/MicrosoftDocs/mslearn-django-deployment/tree/main/solution
1) Could someone who knows what they're doing please run through this and confirm whether it works? As I haven't had this run successfully I'd really appreciate if someone could confirm whether this does work and whether it's my issue. A video of the walkthrough would also be incredibly useful...!
2) After SSH'ing into the application my attempts to run a python manage.py migrate
command ran into a "port 5432 failed: FATAL: password authentication failed for user" error, which regardless of how I'd set the Azure application settings (/environment variables). In the context of the below code, my understanding is that the following environment variables are required:
- DBNAME: shelters # name of the database
- DBHOST: jacksorjacksor_shelter_dbserver01 # name of the database server
- DBUSER: shelter_admin # name of the admin account of the database server
- DBPASS: 86i^z5#emSk6wu3t10nC* # admin password for the database server, defined in the learning module instructions
- SECRET_KEY: 86i^z5#emSk6wu3t10nC* # secret key for the app - I used various when testing out just so it was never empty
This then fits into the azure.py file, as defined in the /project/azure.py
python
# azure.py
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql",
"NAME": os.environ["DBNAME"],
"HOST": hostname + ".postgres.database.azure.com",
"USER": os.environ["DBUSER"] + "@" + hostname,
"PASSWORD": os.environ["DBPASS"],
}
}
Please advise on what I'm doing wrong! Have spent a huge amount of time on this over the weekend and am entirely stuck - ultimately went with SQLite which worked!
Cheers!
Rich