确保您运行的是最新版本的 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')"
}
}