迁移Django数据库时azure无效的用户名

问题描述

我遵循了这个: Tutorial: Deploy a Django web app with PostgreSQL in Azure App Service

我创建了数据库和应用程序,直到进入:

运行Django数据库迁移

通过导航到浏览器来打开SSH会话 https://.scm.azurewebsites.net/webssh/host 运行“ python manage.py migration”

它给了我这个错误

FATAL:  Invalid Username specified. Please check the Username and retry 
connection. The Username should 
be in <username@hostname> format.
(antenv) root@5f4958961a00:/home/site/wwwroot#

我不知道应将哪个“用户名”更改为username @ hostname

提前thnx

解决方法

当您create Postgres database in Azure使用命令时:

az postgres up --resource-group DjangoPostgres-tutorial-rg --location westus2 --sku-name B_Gen5_1 --server-name <postgre-server-name> --database-name pollsdb --admin-user <admin-username> --admin-password <admin-password> --ssl-enforcement Enabled

该命令完成后,它将输出一个JSON对象,该对象包含数据库的不同连接字符串以及服务器URL,生成的用户名(例如“ joyfulKoala @ msdocs-djangodb-12345”)和GUID密码。

例如,

...
  "host": "postgres-server-name.postgres.database.azure.com","password": "somePassword","username": "wert@postgres-server-name"
}

您可以将上述格式的用户名和密码复制到configure environment variables to connect the database

它对我有效。 enter image description here

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...