Customize Azure Database for PostgreSQL server parameters using 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?.

You can list, show, and update configuration parameters for an Azure Database for PostgreSQL server using PowerShell. A subset of engine configurations is exposed at the server-level and can be modified.

Prerequisites

To complete this how-to guide, you need:

Important

While the Az.PostgreSql PowerShell module is in preview, you must install it separately from the Az PowerShell module using the following command: Install-Module -Name Az.PostgreSql -AllowPrerelease. Once the Az.PostgreSql PowerShell module is generally available, it becomes part of future Az PowerShell module releases and available natively from within Azure Cloud Shell.

If you choose to use PowerShell locally, connect to your Azure account using the Connect-AzAccount cmdlet.

Azure Cloud Shell

Azure hosts Azure Cloud Shell, an interactive shell environment that you can use through your browser. You can use either Bash or PowerShell with Cloud Shell to work with Azure services. You can use the Cloud Shell preinstalled commands to run the code in this article, without having to install anything on your local environment.

To start Azure Cloud Shell:

Option Example/Link
Select Try It in the upper-right corner of a code or command block. Selecting Try It doesn't automatically copy the code or command to Cloud Shell. Screenshot that shows an example of Try It for Azure Cloud Shell.
Go to https://shell.azure.com, or select the Launch Cloud Shell button to open Cloud Shell in your browser. Button to launch Azure Cloud Shell.
Select the Cloud Shell button on the menu bar at the upper right in the Azure portal. Screenshot that shows the Cloud Shell button in the Azure portal

To use Azure Cloud Shell:

  1. Start Cloud Shell.

  2. Select the Copy button on a code block (or command block) to copy the code or command.

  3. Paste the code or command into the Cloud Shell session by selecting Ctrl+Shift+V on Windows and Linux, or by selecting Cmd+Shift+V on macOS.

  4. Select Enter to run the code or command.

List server configuration parameters for Azure Database for PostgreSQL server

To list all modifiable parameters in a server and their values, run the Get-AzPostgreSqlConfiguration cmdlet.

The following example lists the server configuration parameters for the server mydemoserver in resource group myresourcegroup.

Get-AzPostgreSqlConfiguration -ResourceGroupName myresourcegroup -ServerName mydemoserver

For the definition of each of the listed parameters, see the PostgreSQL reference section on Environment Variables.

Show server configuration parameter details

To show details about a particular configuration parameter for a server, run the Get-AzPostgreSqlConfiguration cmdlet and specify the Name parameter.

This example shows details of the slow_query_log server configuration parameter for server mydemoserver under resource group myresourcegroup.

Get-AzPostgreSqlConfiguration -Name slow_query_log -ResourceGroupName myresourcegroup -ServerName mydemoserver

Modify a server configuration parameter value

You can also modify the value of a certain server configuration parameter, which updates the underlying configuration value for the PostgreSQL server engine. To update the configuration, use the Update-AzPostgreSqlConfiguration cmdlet.

To update the slow_query_log server configuration parameter of server mydemoserver under resource group myresourcegroup.

Update-AzPostgreSqlConfiguration -Name slow_query_log -ResourceGroupName myresourcegroup -ServerName mydemoserver -Value On

Next steps