0

我有一个 Azure 数据库服务器,我需要通过命令行获取连接字符串。但是,它告诉我“az postgres server show-connection-string”不正确,“show-connection-string”无法识别。我从 Microsoft 文档中进行了复制和粘贴,但它给出了错误,我似乎找不到答案。我可以用手获取连接字符串。这是我的 CLI 命令:

az postgres server show-connection-string --server-name myserver1 --admin-user myuser@myserver --admin-password mypassword
4

1 回答 1

0

确保您运行的是最新版本的 Azure CLI。截至这个答案,最新的是2.26.0但我让这个命令在运行 2.25.0 的CloudShell运行。

ken@Azure:~$ az postgres server show-connection-string --server-name myserver1 --admin-user myuser@myserver --admin-password mypassword
{
  "connectionStrings": {
    "C++ (libpq)": "host=myserver1.postgres.database.azure.com port=5432 dbname={database} user=myuser@myserver@myserver1 password=mypassword sslmode=require",
    "ado.net": "Server=myserver1.postgres.database.azure.com;Database={database};Port=5432;User Id=myuser@myserver@myserver1;Password=mypassword;",
    "jdbc": "jdbc:postgresql://myserver1.postgres.database.azure.com:5432/{database}?user=myuser@myserver@myserver1&password=mypassword",
    "node.js": "var client = new pg.Client('postgres://myuser@myserver@myserver1:mypassword@myserver1.postgres.database.azure.com:5432/{database}');",
    "php": "host=myserver1.postgres.database.azure.com port=5432 dbname={database} user=myuser@myserver@myserver1 password=mypassword",
    "psql_cmd": "postgresql://myuser@myserver@myserver1:mypassword@myserver1.postgres.database.azure.com/{database}?sslmode=require",
    "python": "cnx = psycopg2.connect(database='{database}', user='myuser@myserver@myserver1', host='myserver1.postgres.database.azure.com', password='mypassword', port='5432')",
    "ruby": "cnx = PG::Connection.new(:host => 'myserver1.postgres.database.azure.com', :user => 'myuser@myserver@myserver1', :dbname => '{database}', :port => '5432', :password => 'mypassword')"
  }
}
于 2021-07-07T17:44:10.633 回答