title | description | ms.author | author | ms.service | ms.subservice | ms.topic | ms.date |
---|---|---|---|---|---|---|---|
Connect to server - Azure Cosmos DB for PostgreSQL |
See how to connect to and query an Azure Cosmos DB for PostgreSQL cluster. |
jonels |
jonels-msft |
cosmos-db |
postgresql |
how-to |
06/05/2023 |
[!INCLUDE PostgreSQL]
Choose one of the following database clients to see how to configure it to connect to an Azure Cosmos DB for PostgreSQL cluster.
pgAdmin is a popular and feature-rich open source administration and development platform for PostgreSQL.
-
Download and install pgAdmin.
-
Open the pgAdmin application on your client computer. From the Dashboard, select Add New Server.
:::image type="content" source="media/howto-connect/pgadmin-dashboard.png" alt-text="Screenshot that shows the pgAdmin dashboard.":::
-
Choose a Name in the General tab. Any name will work.
:::image type="content" source="media/howto-connect/pgadmin-general.png" alt-text="Screenshot that shows the pgAdmin general connection settings.":::
-
Enter connection details in the Connection tab.
:::image type="content" source="media/howto-connect/pgadmin-connection.png" alt-text="Screenshot that shows the pgAdmin connection settings.":::
Customize the following fields:
- Host name/address: Obtain this value from the Overview page for your
cluster in the Azure portal. It's listed there as Coordinator name.
It will be of the form,
c-<clustername>.12345678901234.postgres.cosmos.azure.com
. - Maintenance database: use the value
citus
. - Username: use the value
citus
. - Password: the connection password.
- Save password: enable if desired.
- Host name/address: Obtain this value from the Overview page for your
cluster in the Azure portal. It's listed there as Coordinator name.
It will be of the form,
-
In the SSL tab, set SSL mode to Require.
:::image type="content" source="media/howto-connect/pgadmin-ssl.png" alt-text="Screenshot that shows the pgAdmin SSL settings.":::
-
Select Save to save and connect to the database.
The psql utility is a terminal-based front-end to PostgreSQL. It enables you to type in queries interactively, issue them to PostgreSQL, and see the query results.
-
Install psql. It's included with a PostgreSQL installation, or available separately in package managers for several operating systems.
-
In the Azure portal, on the cluster page, select the Connection strings menu item, and then copy the psql connection string.
:::image type="content" source="media/quickstart-connect-psql/get-connection-string.png" alt-text="Screenshot that shows copying the psql connection string.":::
The psql string is of the form
psql "host=c-<clustername>.<uniqueID>.postgres.cosmos.azure.com port=5432 dbname=citus user=citus password=<your_password> sslmode=require"
. Notice that the host name starts with ac-
, for examplec-demo.12345678901234.postgres.cosmos.azure.com
. This prefix indicates the coordinator node of the cluster. The defaultdbname
andusername
arecitus
and can't be changed. -
In the connection string you copied, replace
<your_password>
with your administrative password. -
In a local terminal prompt, paste the psql connection string, and then press Enter.
- Troubleshoot connection issues.
- Verify TLS certificates in your connections.
- Now that you can connect to the database, learn how to build scalable apps.