Get connection endpoints & create the connection strings for your Azure Arc-enabled PostgreSQL server

This article explains how you can retrieve the connection endpoints for your server group and how you can form the connection strings, which can be used with your applications and/or tools.

Note

As a preview feature, the technology presented in this article is subject to Supplemental Terms of Use for Microsoft Azure Previews.

The latest updates are available in the release notes.

Get connection end points:

Run the following command:

az postgres server-arc endpoint list -n <server name> --k8s-namespace <namespace> --use-k8s

For example:

az postgres server-arc endpoint list -n postgres01 --k8s-namespace arc --use-k8s

It returns the list of endpoints: the PostgreSQL endpoint, the log search dashboard (Kibana), and the metrics dashboard (Grafana). For example:

{
  "instances": [
    {
      "endpoints": [
        {
          "description": "PostgreSQL Instance",
          "endpoint": "postgresql://postgres:<replace with password>@12.345.567.89:5432"
        },
        {
          "description": "Log Search Dashboard",
          "endpoint": "https://23.456.78.99:5601/app/kibana#/discover?_a=(query:(language:kuery,query:'custom_resource_name:postgres01'))"
        },
        {
          "description": "Metrics Dashboard",
          "endpoint": "https://34.567.890.12:3000/d/postgres-metrics?var-Namespace=arc&var-Name=postgres01"
        }
      ],
      "engine": "PostgreSql",
      "name": "postgres01"
    }
  ],
  "namespace": "arc"
}

Use these end points to:

  • Form your connection strings and connect with your client tools or applications
  • Access the Grafana and Kibana dashboards from your browser

For example, you can use the end point named PostgreSQL Instance to connect with psql to your server group:

psql postgresql://postgres:MyPassworkd@12.345.567.89:5432
psql (10.14 (Ubuntu 10.14-0ubuntu0.18.04.1), server 12.4 (Ubuntu 12.4-1.pgdg16.04+1))
WARNING: psql major version 10, server major version 12.
         Some psql features might not work.
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
Type "help" for help.

postgres=#

Note

  • The password of the postgres user indicated in the end point named "PostgreSQL Instance" is the password you chose when deploying the server group.

From CLI with kubectl

kubectl get postgresqls/<server name> -n <namespace name>

For example:

kubectl get postgresqls/postgres01 -n arc

Those commands will produce output like the one below. You can use that information to form your connection strings:

NAME         STATE   READY-PODS   PRIMARY-ENDPOINT     AGE
postgres01   Ready   3/3          12.345.567.89:5432   9d

Form connection strings

Use the connections string examples below for your server group. Copy, paste, and customize them as needed:

Important

SSL is required for client connections. In connection string, the SSL mode parameter should not be disabled. For more information, review https://www.postgresql.org/docs/14/runtime-config-connection.html.

ADO.NET

Server=192.168.1.121;Database=postgres;Port=24276;User Id=postgres;Password={your_password_here};Ssl Mode=Require;`

C++ (libpq)

host=192.168.1.121 port=24276 dbname=postgres user=postgres password={your_password_here} sslmode=require

JDBC

jdbc:postgresql://192.168.1.121:24276/postgres?user=postgres&password={your_password_here}&sslmode=require

Node.js

host=192.168.1.121 port=24276 dbname=postgres user=postgres password={your_password_here} sslmode=require

PHP

host=192.168.1.121 port=24276 dbname=postgres user=postgres password={your_password_here} sslmode=require

psql

psql "host=192.168.1.121 port=24276 dbname=postgres user=postgres password={your_password_here} sslmode=require"

Python

dbname='postgres' user='postgres' host='192.168.1.121' password='{your_password_here}' port='24276' sslmode='true'

Ruby

host=192.168.1.121; dbname=postgres user=postgres password={your_password_here} port=24276 sslmode=require