How to generate an Azure Database for PostgreSQL connection string with PowerShell
APPLIES TO: Azure Database for PostgreSQL - Single Server
Important
Azure Database for PostgreSQL - Single Server is on the retirement path. We strongly recommend that you upgrade to Azure Database for PostgreSQL - Flexible Server. For more information about migrating to Azure Database for PostgreSQL - Flexible Server, see What's happening to Azure Database for PostgreSQL Single Server?.
This article demonstrates how to generate a connection string for an Azure Database for PostgreSQL server. You can use a connection string to connect to an Azure Database for PostgreSQL from many different applications.
Requirements
This article uses the resources created in the following guide as a starting point:
Get the connection string
The Get-AzPostgreSqlConnectionString
cmdlet is used to generate a connection string for connecting
applications to Azure Database for PostgreSQL. The following example returns the connection string
for a PHP client from mydemoserver.
Get-AzPostgreSqlConnectionString -Client PHP -Name mydemoserver -ResourceGroupName myresourcegroup
host=mydemoserver.postgres.database.azure.com port=5432 dbname={your_database} user=myadmin@mydemoserver password={your_password} sslmode=require
Valid values for the Client
parameter include:
- ADO.NET
- JDBC
- Node.js
- PHP
- Python
- Ruby
- WebApp