az postgres flexible-server

Manage Azure Database for PostgreSQL Flexible Servers.

Commands

az postgres flexible-server connect

Connect to a flexible server.

az postgres flexible-server create

Create a PostgreSQL flexible server.

az postgres flexible-server db

Manage PostgreSQL databases on a flexible server.

az postgres flexible-server db create

Create a PostgreSQL database on a flexible server.

az postgres flexible-server db delete

Delete a database on a flexible server.

az postgres flexible-server db list

List the databases for a flexible server.

az postgres flexible-server db show

Show the details of a database.

az postgres flexible-server delete

Delete a flexible server.

az postgres flexible-server deploy

Enable and run github action workflow for PostgreSQL server.

az postgres flexible-server deploy run

Run an existing workflow in your github repository.

az postgres flexible-server deploy setup

Create github action workflow file for PostgreSQL server.

az postgres flexible-server execute

Connect to a flexible server.

az postgres flexible-server firewall-rule

Manage firewall rules for a server.

az postgres flexible-server firewall-rule create

Create a new firewall rule for a flexible server.

az postgres flexible-server firewall-rule delete

Delete a firewall rule.

az postgres flexible-server firewall-rule list

List all firewall rules for a flexible server.

az postgres flexible-server firewall-rule show

Get the details of a firewall rule.

az postgres flexible-server firewall-rule update

Update a firewall rule.

az postgres flexible-server list

List available flexible servers.

az postgres flexible-server list-skus

Lists available sku's in the given region.

az postgres flexible-server migration

Manage migration workflows for PostgreSQL Flexible Servers.

az postgres flexible-server migration check-name-availability

Checks if the provided migration-name can be used.

az postgres flexible-server migration create

Create a new migration workflow for a flexible server.

az postgres flexible-server migration delete

Delete a specific migration.

az postgres flexible-server migration list

List the migrations of a flexible server.

az postgres flexible-server migration show

Get the details of a specific migration.

az postgres flexible-server migration update

Update a specific migration.

az postgres flexible-server parameter

Commands for managing server parameter values for flexible server.

az postgres flexible-server parameter list

List the parameter values for a flexible server.

az postgres flexible-server parameter set

Update the parameter of a flexible server.

az postgres flexible-server parameter show

Get the parameter for a flexible server.".

az postgres flexible-server restart

Restart a flexible server.

az postgres flexible-server restore

Restore a flexible server from backup.

az postgres flexible-server show

Get the details of a flexible server.

az postgres flexible-server show-connection-string

Show the connection strings for a PostgreSQL flexible-server database.

az postgres flexible-server start

Start a flexible server.

az postgres flexible-server stop

Stop a flexible server.

az postgres flexible-server update

Update a flexible server.

az postgres flexible-server wait

Wait for the flexible server to satisfy certain conditions.

az postgres flexible-server connect

Connect to a flexible server.

az postgres flexible-server connect --admin-user
                                    --name
                                    [--admin-password]
                                    [--database-name]
                                    [--interactive]
                                    [--querytext]

Required Parameters

--admin-user -u

The login username of the administrator.

--name -n

Name of the server. The name can contain only lowercase letters, numbers, and the hyphen (-) character. Minimum 3 characters and maximum 63 characters.

Optional Parameters

--admin-password -p

The login password of the administrator.

--database-name -d

The name of a database.

--interactive

Pass this parameter to connect to database in interactive mode.

--querytext -q

A query to run against the flexible server.

az postgres flexible-server create

Create a PostgreSQL flexible server.

Create a PostgreSQL flexible server with custom or default configuration. For more information for network configuration, see

az postgres flexible-server create [--address-prefixes]
                                   [--admin-password]
                                   [--admin-user]
                                   [--backup-retention]
                                   [--database-name]
                                   [--high-availability {Disabled, Enabled}]
                                   [--location]
                                   [--name]
                                   [--private-dns-zone]
                                   [--public-access]
                                   [--resource-group]
                                   [--sku-name]
                                   [--standby-zone]
                                   [--storage-size]
                                   [--subnet]
                                   [--subnet-prefixes]
                                   [--tags]
                                   [--tier]
                                   [--version]
                                   [--vnet]
                                   [--yes]
                                   [--zone]

Examples

Create a PostgreSQL flexible server with custom parameters

az postgres flexible-server create --location northeurope --resource-group testGroup \
  --name testserver --admin-user username --admin-password password \
  --sku-name Standard_B1ms --tier Burstable --public-access 153.24.26.117 --storage-size 128 \
  --tags "key=value" --version 13 --high-availability Enabled --zone 1 \
  --standby-zone 3

Create a PostgreSQL flexible server with default parameters and public access enabled by default. Resource group, server name, username, password, and default database will be created by CLI

az postgres flexible-server create

Create a PostgreSQL flexible server with public access and add the range of IP address to have access to this server. The --public-access parameter can be 'All', 'None', <startIpAddress>, or <startIpAddress>-<endIpAddress>

az postgres flexible-server create --resource-group testGroup --name testserver --public-access 125.23.54.31-125.23.54.35

Create a PostgreSQL flexible server with private access. If provided virtual network and subnet do not exists, virtual network and subnet with the specified address prefixes will be created.

az postgres flexible-server create --resource-group testGroup --name testserver --vnet myVnet --subnet mySubnet --address-prefixes 10.0.0.0/16 --subnet-prefixes 10.0.0.0/24

Create a PostgreSQL flexible server using a new subnet resource ID and new private DNS zone resource ID. The subnet and DNS zone can be created in different subscription or resource group.

az postgres flexible-server create \
  --resource-group testGroup --name testserver \
  --subnet /subscriptions/{SubID}/resourceGroups/{ResourceGroup}/providers/Microsoft.Network/virtualNetworks/{VNetName}/subnets/{SubnetName} \
  --private-dns-zone /subscriptions/{SubID}/resourceGroups/{resourceGroup}/providers/Microsoft.Network/privateDnsZones/testPostgreSQLFlexibleDnsZone.private.postgres.database.azure.com \
  --address-prefixes 172.0.0.0/16 --subnet-prefixes 172.0.0.0/24

Create a PostgreSQL flexible server using existing network resources in the same resource group. The provided subnet should not have any other resource deployed in it and this subnet will be delegated to Microsoft.DBforPostgreSQL/flexibleServers, if not already delegated. The private DNS zone will be linked to the virtual network if not already linked.

# create vnet
az network vnet create --resource-group testGroup --name testVnet --location testLocation --address-prefixes 172.0.0.0/16

# create subnet
az network vnet subnet create --resource-group testGroup --vnet-name testVnet --address-prefixes 172.0.0.0/24 --name testSubnet

# create private dns zone
az network private-dns zone create -g testGroup -n testDNS.private.postgres.database.azure.com

az postgres flexible-server create --resource-group testGroup \
  --name testserver --location testLocation \
  --subnet /subscriptions/{SubId}/resourceGroups/{testGroup}/providers/Microsoft.Network/virtualNetworks/tesetVnet/subnets/testSubnet \
  --private-dns-zone /subscriptions/{SubId}/resourceGroups/{testGroup}/providers/Microsoft.Network/privateDnsZones/testDNS.postgres.database.azure.com\


az postgres flexible-server create --resource-group testGroup --name testserver \
  --vnet testVnet --subnet testSubnet --location testLocation \
  --private-dns-zone /subscriptions/{SubId}/resourceGroups/{testGroup}/providers/Microsoft.Network/privateDnsZones/testDNS.postgres.database.azure.com

Create a PostgreSQL flexible server using existing network resources in the different resource group / subscription.

az postgres flexible-server create --resource-group testGroup \
   --name testserver --location testLocation \
  --subnet /subscriptions/{SubId2}/resourceGroups/{testGroup2}/providers/Microsoft.Network/virtualNetworks/tesetVnet/subnets/testSubnet \
  --private-dns-zone /subscriptions/{SubId2}/resourceGroups/{testGroup2}/providers/Microsoft.Network/privateDnsZones/testDNS.postgres.database.azure.com

Optional Parameters

--address-prefixes

The IP address prefix to use when creating a new virtual network in CIDR format. Default value is 10.0.0.0/16.

--admin-password -p

The password of the administrator. Minimum 8 characters and maximum 128 characters. Password must contain characters from three of the following categories: English uppercase letters, English lowercase letters, numbers, and non-alphanumeric characters.

--admin-user -u

Administrator username for the server. Once set, it cannot be changed.

default value: acidicwigeon1
--backup-retention

The number of days a backup is retained. Range of 7 to 35 days. Default is 7 days.

default value: 7
--database-name -d

The name of the database to be created when provisioning the database server.

--high-availability

Enable or disable high availability feature. Default value is Disabled. High availability can only be set during flexible server create time.

accepted values: Disabled, Enabled
default value: Disabled
--location -l

Location. Values from: az account list-locations. You can configure the default location using az configure --defaults location=<location>.

--name -n

Name of the server. The name can contain only lowercase letters, numbers, and the hyphen (-) character. Minimum 3 characters and maximum 63 characters.

--private-dns-zone

This parameter only applies for a server with private access. The name or id of new or existing private dns zone. You can use the private dns zone from same resource group, different resource group, or different subscription. If you want to use a zone from different resource group or subscription, please provide resource Id. CLI creates a new private dns zone within the same resource group as virtual network if not provided by users.

--public-access

Determines the public access. Enter single or range of IP addresses to be included in the allowed list of IPs. IP address ranges must be dash-separated and not contain any spaces. Specifying 0.0.0.0 allows public access from any resources deployed within Azure to access your server. Setting it to "None" sets the server in public access mode but does not create a firewall rule.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--sku-name

The name of the compute SKU. Follows the convention Standard_{VM name}. Examples: Standard_D4s_v3.

default value: Standard_D2s_v3
--standby-zone

The availability zone information of the standby server when high availability is enabled.

--storage-size

The storage capacity of the server. Minimum is 32 GiB and max is 16 TiB.

default value: 128
--subnet

Name or resource ID of a new or existing subnet. If you want to use a subnet from different resource group or subscription, please provide resource ID instead of name. Please note that the subnet will be delegated to flexibleServers. After delegation, this subnet cannot be used for any other type of Azure resources.

--subnet-prefixes

The subnet IP address prefix to use when creating a new subnet in CIDR format. Default value is 10.0.0.0/24.

--tags

Space-separated tags: key[=value] [key[=value] ...]. Use "" to clear existing tags.

--tier

Compute tier of the server. Accepted values: Burstable, GeneralPurpose, Memory Optimized.

default value: GeneralPurpose
--version

Server major version.

default value: 13
--vnet

Name or ID of a new or existing virtual network. If you want to use a vnet from different resource group or subscription, please provide a resource ID. The name must be between 2 to 64 characters. The name must begin with a letter or number, end with a letter, number or underscore, and may contain only letters, numbers, underscores, periods, or hyphens.

--yes -y

Do not prompt for confirmation.

--zone -z

Availability zone into which to provision the resource.

az postgres flexible-server delete

Delete a flexible server.

az postgres flexible-server delete [--ids]
                                   [--name]
                                   [--resource-group]
                                   [--yes]

Examples

Delete a flexible server.

az postgres flexible-server delete --resource-group testGroup --name testserver

Delete a flexible server without prompt or confirmation.

az postgres flexible-server delete --resource-group testGroup --name testserver --yes

Optional Parameters

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name -n

Name of the server. The name can contain only lowercase letters, numbers, and the hyphen (-) character. Minimum 3 characters and maximum 63 characters.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--yes -y

Do not prompt for confirmation.

az postgres flexible-server execute

Connect to a flexible server.

az postgres flexible-server execute --admin-password
                                    --admin-user
                                    --name
                                    [--database-name]
                                    [--file-path]
                                    [--querytext]

Required Parameters

--admin-password -p

The login password of the administrator.

--admin-user -u

The login username of the administrator.

--name -n

Name of the server. The name can contain only lowercase letters, numbers, and the hyphen (-) character. Minimum 3 characters and maximum 63 characters.

Optional Parameters

--database-name -d

The name of a database.

--file-path -f

The path of the sql file to execute.

--querytext -q

A query to run against the flexible server.

az postgres flexible-server list

List available flexible servers.

az postgres flexible-server list [--resource-group]

Examples

List all PostgreSQL flexible servers in a subscription.

az postgres flexible-server list

List all PostgreSQL flexible servers in a resource group.

az postgres flexible-server list --resource-group testGroup

List all PostgreSQL flexible servers in a resource group in table format.

az postgres flexible-server list --resource-group testGroup --output table

Optional Parameters

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

az postgres flexible-server list-skus

Lists available sku's in the given region.

az postgres flexible-server list-skus --location

Required Parameters

--location -l

Location. Values from: az account list-locations. You can configure the default location using az configure --defaults location=<location>.

az postgres flexible-server restart

Restart a flexible server.

az postgres flexible-server restart [--failover]
                                    [--ids]
                                    [--name]
                                    [--resource-group]

Examples

Restart a flexible server.

az postgres flexible-server restart --resource-group testGroup --name testserver

Restart a server with planned failover

az postgres flexible-server restart --resource-group testGroup --name testserver --failover Planned

Restart a server with forced failover

az postgres flexible-server restart --resource-group testGroup --name testserver --failover Forced

Optional Parameters

--failover

Forced or planned failover for server restart operation. Allowed values: Forced, Planned.

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name -n

Name of the server. The name can contain only lowercase letters, numbers, and the hyphen (-) character. Minimum 3 characters and maximum 63 characters.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

az postgres flexible-server restore

Restore a flexible server from backup.

az postgres flexible-server restore --source-server
                                    [--address-prefixes]
                                    [--ids]
                                    [--name]
                                    [--no-wait]
                                    [--private-dns-zone]
                                    [--resource-group]
                                    [--restore-time]
                                    [--subnet]
                                    [--subnet-prefixes]
                                    [--vnet]
                                    [--yes]
                                    [--zone]

Examples

Restore 'testserver' to a specific point-in-time as a new server 'testserverNew'.

az postgres flexible-server restore --resource-group testGroup --name testserverNew --source-server testserver --restore-time "2017-06-15T13:10:00Z"

Restore 'testserver' to current point-in-time as a new server 'testserverNew'.

az postgres flexible-server restore --resource-group testGroup --name testserverNew --source-server testserver

Required Parameters

--source-server

The name or resource ID of the source server to restore from.

Optional Parameters

--address-prefixes

The IP address prefix to use when creating a new virtual network in CIDR format. Default value is 10.0.0.0/16.

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name -n

Name of the server. The name can contain only lowercase letters, numbers, and the hyphen (-) character. Minimum 3 characters and maximum 63 characters.

--no-wait

Do not wait for the long-running operation to finish.

--private-dns-zone

This parameter only applies for a server with private access. The name or id of new or existing private dns zone. You can use the private dns zone from same resource group, different resource group, or different subscription. If you want to use a zone from different resource group or subscription, please provide resource Id. CLI creates a new private dns zone within the same resource group as virtual network if not provided by users.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--restore-time

The point in time in UTC to restore from (ISO8601 format), e.g., 2017-04-26T02:10:00+00:00The default value is set to current time.

default value: 2022-08-11T18:00:33+00:00
--subnet

Name or resource ID of a new or existing subnet. If you want to use a subnet from different resource group or subscription, please provide resource ID instead of name. Please note that the subnet will be delegated to flexibleServers. After delegation, this subnet cannot be used for any other type of Azure resources.

--subnet-prefixes

The subnet IP address prefix to use when creating a new subnet in CIDR format. Default value is 10.0.0.0/24.

--vnet

Name or ID of a new or existing virtual network. If you want to use a vnet from different resource group or subscription, please provide a resource ID. The name must be between 2 to 64 characters. The name must begin with a letter or number, end with a letter, number or underscore, and may contain only letters, numbers, underscores, periods, or hyphens.

--yes -y

Do not prompt for confirmation.

--zone -z

Availability zone into which to provision the resource.

az postgres flexible-server show

Get the details of a flexible server.

az postgres flexible-server show [--ids]
                                 [--name]
                                 [--resource-group]

Examples

Get the details of a flexible server

az postgres flexible-server show --resource-group testGroup --name testserver

Optional Parameters

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name -n

Name of the server. The name can contain only lowercase letters, numbers, and the hyphen (-) character. Minimum 3 characters and maximum 63 characters.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

az postgres flexible-server show-connection-string

Show the connection strings for a PostgreSQL flexible-server database.

az postgres flexible-server show-connection-string [--admin-password]
                                                   [--admin-user]
                                                   [--database-name]
                                                   [--ids]
                                                   [--server-name]

Examples

Show connection strings for cmd and programming languages.

az postgres flexible-server show-connection-string -s testserver -u username -p password -d databasename

Optional Parameters

--admin-password -p

The password of the administrator. Minimum 8 characters and maximum 128 characters. Password must contain characters from three of the following categories: English uppercase letters, English lowercase letters, numbers, and non-alphanumeric characters.

default value: {password}
--admin-user -u

Administrator username for the server. Once set, it cannot be changed.

default value: {login}
--database-name -d

The name of the database to be created when provisioning the database server.

default value: {database}
--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--server-name -s

Name of the server. The name can contain only lowercase letters, numbers, and the hyphen (-) character. Minimum 3 characters and maximum 63 characters.

default value: {server}

az postgres flexible-server start

Start a flexible server.

az postgres flexible-server start [--ids]
                                  [--name]
                                  [--resource-group]

Examples

Start a flexible server.

az postgres flexible-server start --resource-group testGroup --name testserver

Optional Parameters

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name -n

Name of the server. The name can contain only lowercase letters, numbers, and the hyphen (-) character. Minimum 3 characters and maximum 63 characters.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

az postgres flexible-server stop

Stop a flexible server.

az postgres flexible-server stop [--ids]
                                 [--name]
                                 [--resource-group]

Examples

Stop a flexible server.

az postgres flexible-server stop --resource-group testGroup --name testserver

Optional Parameters

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name -n

Name of the server. The name can contain only lowercase letters, numbers, and the hyphen (-) character. Minimum 3 characters and maximum 63 characters.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

az postgres flexible-server update

Update a flexible server.

az postgres flexible-server update [--add]
                                   [--admin-password]
                                   [--backup-retention]
                                   [--force-string]
                                   [--high-availability {Disabled, Enabled}]
                                   [--ids]
                                   [--maintenance-window]
                                   [--name]
                                   [--remove]
                                   [--resource-group]
                                   [--set]
                                   [--sku-name]
                                   [--standby-zone]
                                   [--storage-size]
                                   [--tags]
                                   [--tier]

Examples

Update a flexible server's sku, using local context for server and resource group.

az postgres flexible-server update --sku-name Standard_D4s_v3

Update a server's tags.

az postgres flexible-server update --resource-group testGroup --name testserver --tags "k1=v1" "k2=v2"

Reset password

az postgres flexible-server update --resource-group testGroup --name testserver -p password123

Optional Parameters

--add

Add an object to a list of objects by specifying a path and key value pairs. Example: --add property.listProperty <key=value, string or JSON string>.

--admin-password -p

The password of the administrator. Minimum 8 characters and maximum 128 characters. Password must contain characters from three of the following categories: English uppercase letters, English lowercase letters, numbers, and non-alphanumeric characters.

--backup-retention

The number of days a backup is retained. Range of 7 to 35 days. Default is 7 days.

--force-string

When using 'set' or 'add', preserve string literals instead of attempting to convert to JSON.

--high-availability

Enable or disable high availability feature. Default value is Disabled. High availability can only be set during flexible server create time.

accepted values: Disabled, Enabled
--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--maintenance-window

Period of time (UTC) designated for maintenance. Examples: "Sun:23:30" to schedule on Sunday, 11:30pm UTC. To set back to default pass in "Disabled".

--name -n

Name of the server. The name can contain only lowercase letters, numbers, and the hyphen (-) character. Minimum 3 characters and maximum 63 characters.

--remove

Remove a property or an element from a list. Example: --remove property.list OR --remove propertyToRemove.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--set

Update an object by specifying a property path and value to set. Example: --set property1.property2=.

--sku-name

The name of the compute SKU. Follows the convention Standard_{VM name}. Examples: Standard_D4s_v3.

--standby-zone

The availability zone information of the standby server when high availability is enabled.

--storage-size

The storage capacity of the server. Minimum is 32 GiB and max is 16 TiB.

--tags

Space-separated tags: key[=value] [key[=value] ...]. Use "" to clear existing tags.

--tier

Compute tier of the server. Accepted values: Burstable, GeneralPurpose, Memory Optimized.

az postgres flexible-server wait

Wait for the flexible server to satisfy certain conditions.

az postgres flexible-server wait [--created]
                                 [--custom]
                                 [--deleted]
                                 [--exists]
                                 [--ids]
                                 [--interval]
                                 [--name]
                                 [--resource-group]
                                 [--timeout]
                                 [--updated]

Optional Parameters

--created

Wait until created with 'provisioningState' at 'Succeeded'.

--custom

Wait until the condition satisfies a custom JMESPath query. E.g. provisioningState!='InProgress', instanceView.statuses[?code=='PowerState/running'].

--deleted

Wait until deleted.

--exists

Wait until the resource exists.

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--interval

Polling interval in seconds.

default value: 30
--name -n

Name of the server. The name can contain only lowercase letters, numbers, and the hyphen (-) character. Minimum 3 characters and maximum 63 characters.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--timeout

Maximum wait in seconds.

default value: 3600
--updated

Wait until updated with provisioningState at 'Succeeded'.