Create your Azure Cosmos DB for PostgreSQL cluster in the Azure portal.
In the portal, select Create a resource in the upper left-hand corner.
On the Create a resource page, select Databases, and then select Azure Cosmos DB.
On the Select API option page, on the PostgreSQL tile, select Create.
On the Create an Azure Cosmos DB for PostgreSQL cluster page, fill out the following information:
Resource group: Select New, then enter link-demo.
Cluster name: Enter link-demo-sg.
Note
The cluster name must be globally unique across Azure because it
creates a DNS entry. If link-demo-sg is unavailable, enter another name and adjust the following steps accordingly.
Location: Select East US.
Password: Enter and then confirm a password.
Select Next: Networking.
On the Networking tab, for Connectivity method, select Private access.
On the Create private endpoint screen, enter or select the following values:
Resource group: link-demo
Location: (US) East US
Name: link-demo-sg-c-pe1
Target sub-resource: coordinator
Virtual network: link-demo-net
Subnet: link-demo-subnet
Integrate with private DNS zone: Yes
Select OK.
After you create the private endpoint, select Review + create and then select Create to create your cluster.
Access the cluster privately from the VM
The private link allows the VM to connect to the cluster, and prevents external hosts from doing so. In this step, you check that the psql database client on your VM can communicate with the coordinator node of the cluster.
PG_URI='host=c-link-demo-sg.12345678901234.postgres.cosmos.azure.com port=5432 dbname=citus user=citus password={your_password} sslmode=require'
# Attempt to connect to cluster with psql in the VM
az vm run-command invoke \
--resource-group link-demo \
--name link-demo-vm \
--command-id RunShellScript \
--scripts "psql '$PG_URI' -c 'SHOW citus.version;'" \
--query 'value[0].message' \
| xargs printf
Note
In the connection string, replace {your_password} with your cluster password or Microsoft Entra ID token. For more information, see authentication options.
You should see a version number for Citus in the output. If you do, then psql
was able to execute the command, and the private link worked.
Clean up resources
You've seen how to create a private link between a VM and a
cluster. Now you can deprovision the resources.
Delete the resource group, and the resources inside will be deprovisioned:
az group delete --resource-group link-demo
# press y to confirm
Learn how to securely connect an Azure SQL server using an Azure Private Endpoint via the Azure portal, ensuring private and safe communication with your SQL server.