0

I have an Azure database server which I need to obtain the connection string for by way of command line. However, it is telling me that the "az postgres server show-connection-string" is not right, that "show-connection-string" is not recognized. I did a copy and paste from the Microsoft documentation but it gives the error, and I can't seem to find the answer. I could use a hand obtaining the connection string. Here is my CLI command:

az postgres server show-connection-string --server-name myserver1 --admin-user myuser@myserver --admin-password mypassword
Zoe
  • 27,060
  • 21
  • 118
  • 148
Richard Wolford
  • 353
  • 2
  • 15

1 Answers1

0

Ensure you are running the latest version of the Azure CLI. As of this answer, the latest is 2.26.0 but I got this command to run in CloudShell which is running 2.25.0.

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')"
  }
}
Ken W - Zero Networks
  • 3,533
  • 1
  • 13
  • 18