Auto grow storage in Azure Database for PostgreSQL server using PowerShell

This article describes how you can configure an Azure Database for PostgreSQL server storage to grow without impacting the workload.

Storage auto grow prevents your server from reaching the storage limit and becoming read-only. For servers with 100 GB or less of provisioned storage, the size is increased by 5 GB when the free space is below 10%. For servers with more than 100 GB of provisioned storage, the size is increased by 5% when the free space is below 10 GB. Maximum storage limits apply as specified in the storage section of the Azure Database for PostgreSQL pricing tiers.

Important

Remember that storage can only be scaled up, not down.

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.

Enable PostgreSQL server storage auto grow

Enable server auto grow storage on an existing server with the following command:

Update-AzPostgreSqlServer -Name mydemoserver -ResourceGroupName myresourcegroup -StorageAutogrow Enabled

Enable server auto grow storage while creating a new server with the following command:

$Password = Read-Host -Prompt 'Please enter your password' -AsSecureString
New-AzPostgreSqlServer -Name mydemoserver -ResourceGroupName myresourcegroup -Sku GP_Gen5_2 -StorageAutogrow Enabled -Location westus -AdministratorUsername myadmin -AdministratorLoginPassword $Password

Next steps