为什么 Azure 容器实例中的应用程序无法连接到 Azure SQL DB for PostgresSQL?

Why application in Azure Container Instance cannot connect to Azure SQL DB for PostgreSQL?

我在 Azure 容器实例中有 Python 应用程序,它尝试建立与 Azure DB for PostgreSQL 的连接,但失败了。 Azure DB 防火墙对 Azure 服务开放。当应用程序从本地计算机 docker.

连接时,连接工作正常

请问是什么问题?

psql: error: FATAL:  password authentication failed for user "myuser"
'sales.Customers' table is unavailable - sleeping
* Could not resolve host: hslotp
* Closing connection 0
OTP is unavailable - sleeping

你检查过端口匹配了吗,这里是你可以从 Troubleshoot connection issues to Azure Database for PostgreSQL

验证的东西

确保您拥有最新的 psycopg2 版本或至少高于 2.8.0

此外,连接字符串应如下所示。确保从 Azure 门户获取服务器名称和登录详细信息。

postgresql://user:password@container_name:5432?sslmode=disable

参考:thon to connect and query data in Azure Database for PostgreSQL