APPLIES TO:
Azure Database for PostgreSQL flexible server
In this article, you learn how to create and manage read replicas in Azure Database for PostgreSQL Flexible Server from the Azure portal, CLI, and REST API. To learn more about read replicas, see the overview.
Prerequisites
Create an instance of Azure Database for PostgreSQL flexible server to be the primary server.
Note
When deploying read replicas for persistent heavy write-intensive primary workloads, the replication lag could continue to grow and might never catch up with the primary. This might also increase storage usage at the primary as the WAL files are only deleted once received at the replica.
Review primary settings
Before setting up a read replica for Azure Database for PostgreSQL Flexible Server, ensure the primary server is configured to meet the necessary prerequisites. Specific settings on the primary server can affect the ability to create replicas.
Storage auto-grow: Storage autogrow settings on the primary server and its read replicas must adhere to specific guidelines to ensure consistency and prevent replication disruptions. Refer to the Storage autogrow for detailed rules and settings.
Premium SSD v2: The current release doesn't support the creation of read replicas for primary servers using Premium SSD v2 storage. If your workload requires read replicas, choose a different storage option for the primary server.
In the Azure portal, choose the Azure Database for PostgreSQL flexible server instance you want for the replica.
On the Overview dialog, note the PostgreSQL version (ex 15.4
). Also, note the region your primary is deployed to.
On the server sidebar, under Settings, select Compute + storage.
Review and note the following settings:
Under Settings, select Networking.
Review the network settings.
Note
The commands provided in this guide are applicable for Azure CLI version 2.56.0 or higher. Ensure that you have the required version or a later one installed to execute these commands successfully. You can check your current Azure CLI version by running az --version
in your command line interface. To update Azure CLI to the latest version, follow the instructions provided in the Azure CLI documentation.
To view the configuration and current status of an Azure PostgreSQL Flexible Server, use the az postgres flexible-server show
command. This command provides detailed information about the specified server.
az postgres flexible-server show \
--resource-group <resource-group> \
--name <server-name>
Replace <resource-group>
and <server-name>
with your specific resource group and the name of the server you wish to view.
Review and note the following settings:
- Compute Tier, Processor, Size (ex
Standard_D4ds_v4
).
- Storage
- Type
- Storage size (ex
128
)
- autogrow
- High Availability
- Enabled / Disabled
- Availability zone settings
- Backup settings
- Retention period
- Redundancy Options
Sample response
{
"administratorLogin": "myadmin",
"administratorLoginPassword": null,
"authConfig": {
"activeDirectoryAuth": "Disabled",
"passwordAuth": "Enabled",
"tenantId": null
},
"availabilityZone": "2",
"backup": {
"backupRetentionDays": 7,
"earliestRestoreDate": "2024-01-06T11:43:44.485537+00:00",
"geoRedundantBackup": "Disabled"
},
"createMode": null,
"dataEncryption": {
"geoBackupEncryptionKeyStatus": null,
"geoBackupKeyUri": null,
"geoBackupUserAssignedIdentityId": null,
"primaryEncryptionKeyStatus": null,
"primaryKeyUri": null,
"primaryUserAssignedIdentityId": null,
"type": "SystemManaged"
},
"fullyQualifiedDomainName": "{serverName}.postgres.database.chinacloudapi.cn",
"highAvailability": {
"mode": "Disabled",
"standbyAvailabilityZone": null,
"state": "NotEnabled"
},
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}",
"identity": null,
"location": "China North 3",
"maintenanceWindow": {
"customWindow": "Disabled",
"dayOfWeek": 0,
"startHour": 0,
"startMinute": 0
},
"minorVersion": "0",
"name": "{serverName}",
"network": {
"delegatedSubnetResourceId": null,
"privateDnsZoneArmResourceId": null,
"publicNetworkAccess": "Enabled"
},
"pointInTimeUtc": null,
"privateEndpointConnections": null,
"replica": {
"capacity": 5,
"promoteMode": null,
"promoteOption": null,
"replicationState": null,
"role": "Primary"
},
"replicaCapacity": 5,
"replicationRole": "Primary",
"resourceGroup": "{resourceGroupName}",
"sku": {
"name": "Standard_D4ds_v4",
"tier": "GeneralPurpose"
},
"sourceServerResourceId": null,
"state": "Ready",
"storage": {
"autoGrow": "Disabled",
"iops": 500,
"storageSizeGb": 128,
"throughput": null,
"tier": "P10",
"type": ""
},
"systemData": {
"createdAt": "2023-11-08T11:27:48.972812+00:00",
"createdBy": null,
"createdByType": null,
"lastModifiedAt": null,
"lastModifiedBy": null,
"lastModifiedByType": null
},
"tags": {},
"type": "Microsoft.DBforPostgreSQL/flexibleServers",
"version": "16"
}
To obtain information about the configuration of a server in Azure Database for PostgreSQL Flexible Server, especially to view settings for recently introduced features like storage autogrow or private link, you should use the latest API version 2023-06-01-preview
. The GET
request would be formatted as follows:
https://management.chinacloudapi.cn/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}?api-version=2023-06-01-preview
Replace {subscriptionId}
, {resourceGroupName}
, and {serverName}
with your Azure subscription ID, the resource group name, and the name of the primary server you want to review, respectively. This request gives you access to the configuration details of your primary server, ensuring it's properly set up for creating a read replica.
Review and note the following settings:
- Compute Tier, Processor, Size (ex
Standard_D4ds_v4
).
- Storage
- Type
- Storage size (ex
128
)
- autogrow
- Network
- High Availability
- Enabled / Disabled
- Availability zone settings
- Backup settings
- Retention period
- Redundancy Options
Sample response
{
"sku": {
"name": "Standard_D4ds_v4",
"tier": "GeneralPurpose"
},
"systemData": {
"createdAt": "2023-11-22T16:11:42.2461489Z"
},
"properties": {
"replica": {
"role": "Primary",
"capacity": 5
},
"storage": {
"type": "",
"iops": 500,
"tier": "P10",
"storageSizeGB": 128,
"autoGrow": "Disabled"
},
"network": {
"publicNetworkAccess": "Enabled"
},
"dataEncryption": {
"type": "SystemManaged"
},
"authConfig": {
"activeDirectoryAuth": "Disabled",
"passwordAuth": "Enabled"
},
"fullyQualifiedDomainName": "{serverName}.postgres.database.chinacloudapi.cn",
"version": "15",
"minorVersion": "4",
"administratorLogin": "myadmin",
"state": "Ready",
"availabilityZone": "1",
"backup": {
"backupRetentionDays": 7,
"geoRedundantBackup": "Disabled",
"earliestRestoreDate": "2023-11-23T12:55:33.3443218+00:00"
},
"highAvailability": {
"mode": "Disabled",
"state": "NotEnabled"
},
"maintenanceWindow": {
"customWindow": "Disabled",
"dayOfWeek": 0,
"startHour": 0,
"startMinute": 0
},
"replicationRole": "Primary",
"replicaCapacity": 5
},
"location": "China North 3",
"tags": {},
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}",
"name": "{serverName}",
"type": "Microsoft.DBforPostgreSQL/flexibleServers"
}
Create a read replica
To create a read replica, follow these steps:
Select an existing Azure Database for PostgreSQL flexible server instance to use as the primary server.
On the server sidebar, under Settings, select Replication.
Select Create replica.
Enter the Basics form with the following information.
Select Review + create to confirm the creation of the replica or Next: Networking if you want to add, delete, or modify any firewall rules.
Leave the remaining defaults and then select the Review + create button at the bottom of the page or proceed to the next forms to add tags or change data encryption method.
Review the information in the final confirmation window. When you're ready, select Create. A new deployment is created.
During the deployment, you see the primary in Updating
state.
After the read replica is created, it can be viewed from the Replication window.
You can create a read replica for your Azure PostgreSQL Flexible Server by using the az postgres flexible-server replica create
command.
az postgres flexible-server replica create \
--replica-name <replica-name> \
--resource-group <resource-group> \
--source-server <source-server-name> \
--location <location>
Replace <replica-name>
, <resource-group>
, <source-server-name>
, and <location>
with your specific values.
After the read replica is created, the properties of all servers, which are replicas of a primary replica can be obtained by using the az postgres flexible-server replica create
command.
az postgres flexible-server replica list \
--name <source-server-name> \
--resource-group <resource-group>
Replace <source-server-name>
, and <resource-group>
with your specific values.
Initiate an HTTP PUT
request by using the servers create API:
PUT https://management.chinacloudapi.cn/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/flexibleServers/{replicaserverName}?api-version=2022-12-01
Here, you need to replace {subscriptionId}
, {resourceGroupName}
, and {replicaserverName}
with your specific Azure subscription ID, the name of your resource group, and the desired name for your read replica, respectively.
{
"location": "chinanorth3",
"properties": {
"createMode": "Replica",
"SourceServerResourceId": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/flexibleServers/{sourceserverName}"
}
}
After the read replica is created, the properties of all servers, which are replicas of a primary replica can be obtained by initiating an HTTP GET
request by using replicas list by server API:
GET https://management.chinacloudapi.cn/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/flexibleServers/{sourceserverName}/replicas?api-version=2022-12-01
Here, you need to replace {subscriptionId}
, {resourceGroupName}
, and {sourceserverName}
with your specific Azure subscription ID, the name of your resource group, and the name you assigned to your primary replica, respectively.
[
{
"administratorLogin": null,
"administratorLoginPassword": null,
"authConfig": null,
"availabilityZone": null,
"backup": {
"backupRetentionDays": null,
"earliestRestoreDate": "2023-11-23T12:55:33.3443218+00:00",
"geoRedundantBackup": "Disabled"
},
"createMode": null,
"dataEncryption": {
"geoBackupEncryptionKeyStatus": null,
"geoBackupKeyUri": null,
"geoBackupUserAssignedIdentityId": null,
"primaryEncryptionKeyStatus": null,
"primaryKeyUri": null,
"primaryUserAssignedIdentityId": null,
"type": "SystemManaged"
},
"fullyQualifiedDomainName": null,
"highAvailability": null,
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{replicaserverName}",
"identity": null,
"location": "chinanorth3",
"maintenanceWindow": {
"customWindow": "Disabled",
"dayOfWeek": 0,
"startHour": 0,
"startMinute": 0
},
"minorVersion": null,
"name": "{replicaserverName}",
"network": {
"delegatedSubnetResourceId": null,
"privateDnsZoneArmResourceId": null,
"publicNetworkAccess": "Disabled"
},
"pointInTimeUtc": null,
"privateEndpointConnections": null,
"replica": {
"capacity": null,
"promoteMode": null,
"promoteOption": null,
"replicationState": "Active",
"role": "AsyncReplica"
},
"replicaCapacity": null,
"replicationRole": "AsyncReplica",
"resourceGroup": "{resourceGroupName}",
"sku": {
"name": "",
"tier": null
},
"sourceServerResourceId": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}",
"state": "Ready",
"storage": {
"autoGrow": "Disabled",
"iops": null,
"storageSizeGb": 0,
"throughput": null,
"tier": null,
"type": null
},
"systemData": {
"createdAt": "2023-11-22T17:11:42.2461489Z",
"createdBy": null,
"createdByType": null,
"lastModifiedAt": null,
"lastModifiedBy": null,
"lastModifiedByType": null
},
"tags": null,
"type": "Microsoft.DBforPostgreSQL/flexibleServers",
"version": null
}
]
Set the replica server name.
Tip
It is a Cloud Adoption Framework (CAF) best practice to use a resource naming convention that will allow you to easily determine what instance you are connecting to or managing and where it resides.
Select a location different from your primary but note that you can select the same region.
Set the compute and storage to what you recorded from your primary. If the displayed compute doesn't match, select Configure server and select the appropriate one.
Note
If you select a compute size smaller than the primary, the deployment will fail. Also be aware that the compute size might not be available in a different region.
Important
Review the considerations section of the Read Replica overview.
To avoid issues during promotion of replicas constantly change the following server parameters on the replicas first, before applying them on the primary: max_connections
, max_prepared_transactions
, max_locks_per_transaction
, max_wal_senders
, max_worker_processes
.
Create virtual endpoints
Note
All operations involving virtual endpoints - like adding, editing, or removing - are executed in the context of the primary server.
In the Azure portal, select the primary server.
On the server sidebar, under Settings, select Replication.
Select Create endpoint.
In the dialog, type a meaningful name for your endpoint. Notice the DNS endpoint that is being generated.
Select Create.
Note
If you do not create a virtual endpoint you will receive an error on the promote replica attempt.
You can create a virtual endpoint by using the az postgres flexible-server virtual-endpoint create
command.
az postgres flexible-server virtual-endpoint create \
--resource-group <resource-group> \
--server-name <primary-name> \
--name <virtual-endpoint-name> \
--endpoint-type ReadWrite \
--members <replica-name>
Replace <resource-group>
, <primary-name>
, <virtual-endpoint-name>
, and <replica-name>
with your specific values.
To create a virtual endpoint using Azure's REST API, you would use an HTTP PUT
request. The request would look like this:
PUT https://management.chinacloudapi.cn/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/flexibleServers/{sourceserverName}/virtualendpoints/{virtualendpointName}?api-version=2023-06-01-preview
The accompanying JSON body for this request is as follows:
{
"Properties": {
"EndpointType": "ReadWrite",
"Members": ["{replicaserverName}"]
}
}
Here, {replicaserverName}
should be replaced with the name of the replica server you're including as a reader endpoint target in this virtual endpoint.
List virtual endpoints
To list virtual endpoints, use the following steps:
In the Azure portal, select the primary server.
On the server sidebar, under Settings, select Replication.
At the top of the page, you see both the reader and writer endpoints displayed, along with the names of the servers they're pointing to.
You can view the details of the virtual endpoint using either the list
or show
command. Given that only one virtual endpoint is allowed per primary-replica pair, both commands yield the same result.
Here's an example of how to use the list
command:
az postgres flexible-server virtual-endpoint list \
--resource-group <resource-group> \
--server-name <server-name>
Replace <server-name>
with the name of your primary server and <resource-group>
with the name of your resource group.
Here's how you can use the show
command:
az postgres flexible-server virtual-endpoint show \
--name <virtual-endpoint-name>
--resource-group <resource-group> \
--server-name <server-name>
In this command, replace <virtual-endpoint-name>
,<server-name>
, and <resource-group>
with the respective names. <server-name>
is the name of your primary server.
GET https://management.chinacloudapi.cn/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/flexibleServers/{sourceserverName}/virtualendpoints?api-version=2023-06-01-preview
Here, {sourceserverName}
should be the name of the primary server from which you're managing the virtual endpoints.
Modify application to point to the virtual endpoint
Modify any applications that are using your Azure Database for PostgreSQL flexible server instance to use the new virtual endpoints (ex: corp-pg-001.writer.postgres.database.chinacloudapi.cn
and corp-pg-001.reader.postgres.database.chinacloudapi.cn
).
With all the necessary components in place, you're ready to perform a promote replica to primary operation.
To promote replica from the Azure portal, follow these steps:
In the Azure portal, select your primary Azure Database for PostgreSQL flexible server instance.
On the server menu, under Settings, select Replication.
Under Servers, select the Promote icon for the replica.
In the dialog, ensure the action is Promote to primary server.
For Data sync, ensure Planned - sync data before promoting is selected.
Select Promote to begin the process. Once it completes, the roles reverse: the replica becomes the primary, and the primary assumes the role of the replica.
When promoting a replica to a primary server in Azure PostgreSQL Flexible Server, use the az postgres flexible-server replica promote
command. This process is essential for elevating a replica server to function as the primary server and demotion of current primary to replica role. Specify --promote-mode switchover
and --promote-option planned
in the command.
az postgres flexible-server replica promote \
--resource-group <resource-group> \
--name <replica-server-name> \
--promote-mode switchover \
--promote-option planned
Replace <resource-group>
and <replica-server-name>
with your specific resource group and replica server name. This command ensures a smooth transition of the replica to a primary role in a planned manner.
When promoting a replica to a primary server, use an HTTP PATCH
request with a specific JSON
body to set the promotion options. This process is crucial when you need to elevate a replica server to act as the primary server.
The HTTP
request is structured as follows:
PATCH https://management.chinacloudapi.cn/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/flexibleServers/{replicaserverName}?api-version=2023-06-01-preview
{
"Properties": {
"Replica": {
"PromoteMode": "switchover",
"PromoteOption": "planned"
}
}
}
In this JSON
, the promotion is set to occur in switchover
mode with a planned
promotion option. While there are two options for promotion - planned
or forced
- chose planned
for this exercise.
Note
The replica you are promoting must have the reader virtual endpoint assigned, or you will receive an error on promotion.
Test applications
To perform some operations, restart your applications and then attempt those operations. Your applications should function seamlessly without modifying the virtual endpoint connection string or DNS entries. Leave your applications running this time.
Failback to the original server and region
Repeat the same operations to promote the original server to the primary.
In the Azure portal, select the replica.
On the server sidebar, under Settings, select Replication
Under Servers, select the Promote icon for the replica.
In the dialog, ensure the action is Promote to primary server.
For Data sync, ensure Planned - sync data before promoting is selected.
Select Promote, the process begins. Once it completes, the roles reverse: the replica becomes the primary, and the primary assumes the role of the replica.
This time, change the <replica-server-name>
in the az postgres flexible-server replica promote
command to refer to your old primary server, which is currently acting as a replica, and execute the request again.
az postgres flexible-server replica promote \
--resource-group <resource-group> \
--name <replica-server-name> \
--promote-mode switchover \
--promote-option planned
Replace <resource-group>
and <replica-server-name>
with your specific resource group and current replica server name.
This time, change the {replicaserverName}
in the API request to refer to your old primary server, which is currently acting as a replica, and execute the request again.
PATCH https://management.chinacloudapi.cn/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/flexibleServers/{replicaserverName}?api-version=2023-06-01-preview
{
"Properties": {
"Replica": {
"PromoteMode": "switchover",
"PromoteOption": "planned"
}
}
}
In this JSON
, the promotion is set to occur in switchover
mode with a planned
promotion option. While there are two options for promotion - planned
or forced
- chose planned
for this exercise.
Test applications
Again, switch to one of the consuming applications. Wait for the primary and replica status to change to Updating
and then attempt to perform some operations. During the replica promote, your application might encounter temporary connectivity issues to the endpoint:
Add secondary read replica
Create a secondary read replica in a separate region to modify the reader virtual endpoint and to allow for creating an independent server from the first replica.
In the Azure portal, choose the primary Azure Database for PostgreSQL flexible server instance.
On the server sidebar, under Settings, select Replication.
Select Create replica.
Enter the Basics form with information in a third region (ex chinanorth3
and corp-pg-chinanorth-001
)
Select Review + create to confirm the creation of the replica or Next: Networking if you want to add, delete, or modify any firewall rules.
Verify the firewall settings. Notice how the primary settings are copied automatically.
Leave the remaining defaults and then select the Review + create button at the bottom of the page or proceed to the following forms to configure security or add tags.
Review the information in the final confirmation window. When you're ready, select Create. A new deployment is created.
During the deployment, you see the primary in Updating
state.
You can create a secondary read replica by using the az postgres flexible-server replica create
command.
az postgres flexible-server replica create \
--replica-name <replica-name> \
--resource-group <resource-group> \
--source-server <source-server-name> \
--location <location>
Choose a distinct name for <replica-name>
to differentiate it from the primary server and any other replicas.
Replace <resource-group>
, <source-server-name>
, and <location>
with your specific values.
You can create a secondary read replica by using the servers create API:
PUT https://management.chinacloudapi.cn/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/flexibleServers/{replicaserverName}?api-version=2022-12-01
Choose a distinct name for {replicaserverName}
to differentiate it from the primary server and any other replicas.
{
"location": "chinanorth3",
"properties": {
"createMode": "Replica",
"SourceServerResourceId": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/flexibleServers/{sourceserverName}"
}
}
The location is set to chinanorth3
, but you can adjust the setting based on your geographical and operational needs.
Modify virtual endpoint
In the Azure portal, choose the primary Azure Database for PostgreSQL flexible server instance.
On the server sidebar, under Settings, select Replication.
Select the ellipses and then select Edit.
In the dialog, select the new secondary replica.
Select Save. The reader endpoint is now pointed at the secondary replica, and the promote operation is now tied to this replica.
You can now modify your reader endpoint to point to the newly created secondary replica by using a az postgres flexible-server virtual-endpoint update
command. Remember to replace <replica-name>
with the name of the newly created read replica.
az postgres flexible-server virtual-endpoint update \
--resource-group <resource-group> \
--server-name <server-name> \
--name <virtual-endpoint-name> \
--endpoint-type ReadWrite \
--members <replica-name>
Replace <resource-group>
, <server-name>
, <virtual-endpoint-name>
, and <replica-name>
with your specific values.
You can now modify your reader endpoint to point to the newly created secondary replica by using a PATCH
request. Remember to replace {replicaserverName}
with the name of the newly created read replica.
PATCH https://management.chinacloudapi.cn/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/flexibleServers/{sourceserverName}/virtualendpoints/{virtualendpointName}?api-version=2023-06-01-preview
{
"Properties": {
"EndpointType": "ReadWrite",
"Members": ["{replicaserverName}"]
}
}
Rather than switchover to a replica, it's also possible to break the replication of a replica such that it becomes its standalone server.
In the Azure portal, choose the Azure Database for PostgreSQL flexible server primary server.
On the server sidebar, on the server menu, under Settings, select Replication.
Under Servers, select the Promote icon for the replica you want to promote to an independent server.
In the dialog, ensure the action is Promote to independent server and remove from replication. This won't impact the primary server.
For Data sync, ensure Planned - sync data before promoting is selected.
Select Promote, the process begins. Once completed, the server is no longer a replica of the primary.
When you promote a replica in Azure PostgreSQL Flexible Server, the default behavior is to promote it to an independent server. The promotion is achieved using the az postgres flexible-server replica promote
command without specifying the --promote-mode
option, as standalone
mode is assumed by default.
az postgres flexible-server replica promote \
--resource-group <resource-group> \
--name <replica-server-name>
In this command, replace <resource-group>
and <replica-server-name>
with your specific resource group name and the name of the first replica server that you created, that isn't part of virtual endpoint anymore.
You can promote a replica to a standalone server using a PATCH
request. Send a PATCH
request to the specified Azure Management REST API URL with the first JSON
body, where PromoteMode
is set to standalone
and PromoteOption
to planned
. The second JSON
body format, setting ReplicationRole
to None
, is deprecated but still mentioned here for backward compatibility.
PATCH https://management.chinacloudapi.cn/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/flexibleServers/{replicaserverName}?api-version=2023-06-01-preview
{
"Properties": {
"Replica": {
"PromoteMode": "standalone",
"PromoteOption": "planned"
}
}
}
{
"Properties": {
"ReplicationRole": "None"
}
}
Note
Once a replica is promoted to an independent server, it cannot be added back to the replication set.
Delete virtual endpoint
In the Azure portal, select the primary server.
On the server sidebar, under Settings, select Replication.
At the top of the page, locate the Virtual endpoints
section. Navigate to the three dots (menu options) next to the endpoint name, expand it, and choose Delete
.
A delete confirmation dialog appears. It warns you: "This action deletes the virtual endpoint virtualendpointName
. Any clients connected using these domains may lose access." Acknowledge the implications and confirm by clicking on Delete.
To remove a virtual endpoint from an Azure PostgreSQL Flexible Server, you can use the az postgres flexible-server virtual-endpoint delete
command. This action permanently deletes the specified virtual endpoint.
az postgres flexible-server virtual-endpoint delete \
--resource-group <resource-group> \
--server-name <server-name> \
--name <virtual-endpoint-name>
In this command, replace <resource-group>
, <server-name>
, and <virtual-endpoint-name>
with your specific resource group, server name, and the name of the virtual endpoint you wish to delete.
To delete a virtual endpoint using Azure's REST API, you would issue an HTTP DELETE
request. The request URL would be structured as follows:
DELETE https://management.chinacloudapi.cn/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/flexibleServers/{serverName}/virtualendpoints/{virtualendpointName}?api-version=2023-06-01-preview
Delete a replica
You can delete a read replica similar to how you delete a standalone Azure Database for PostgreSQL flexible server instance.
In the Azure portal, open the Overview page for the read replica. Select Delete.
You can also delete the read replica from the Replication window by following these steps:
In the Azure portal, select your primary Azure Database for PostgreSQL flexible server instance.
On the server menu, under Settings, select Replication.
Select the read replica to delete and then select the ellipses. Select Delete.
Acknowledge Delete operation.
To delete a primary or replica server, use the az postgres flexible-server delete
command. If server has read replicas, then you should delete the read replicas first before deleting the primary server.
az postgres flexible-server delete \
--resource-group <resource-group> \
--name <server-name>
Replace <resource-group>
and <server-name>
with the name of your resource group name and the replica server name you wish to delete.
To delete a primary or replica server, use the servers delete API. If server has read replicas, then read replicas should be deleted first before deleting the primary server.
DELETE https://management.chinacloudapi.cn/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/flexibleServers/{replicaserverName}?api-version=2022-12-01
Delete a primary server
You can only delete the primary server once you delete all read replicas. To delete replicas, follow the instructions in the Delete a replica section and then proceed with the steps provided.
To delete a server from the Azure portal, follow these steps:
In the Azure portal, select your primary Azure Database for PostgreSQL flexible server instance.
Open the Overview page for the server and select Delete.
Enter the name of the primary server to delete. Select Delete to confirm the deletion of the primary server.
To delete a primary or replica server, use the az postgres flexible-server delete
command. If server has read replicas, then read replicas should be deleted first before deleting the primary server.
az postgres flexible-server delete \
--resource-group <resource-group> \
--name <server-name>
Replace <resource-group>
and <server-name>
with the name of your resource group name and the primary server name you wish to delete.
To delete a primary or replica server, use the servers delete API. If server has read replicas, then read replicas should be deleted first before deleting the primary server.
DELETE https://management.chinacloudapi.cn/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/flexibleServers/{sourceserverName}?api-version=2022-12-01
Monitor a replica
Two metrics are available to monitor read replicas.
Max Physical Replication Lag
Available only on the primary.
The Max Physical Replication Lag metric shows the byte lag between the primary server and the most lagging replica.
In the Azure portal, select the primary server.
Select Metrics. In the Metrics window, select Max Physical Replication Lag.
For your Aggregation, select Max.
Read Replica Lag metric
The Read Replica Lag metric shows the time since the last replayed transaction on a replica. If no transactions occur on your primary, the metric reflects this time lag. For instance, if no transactions occur on your primary server, and the last transaction was replayed 5 seconds ago, then the Read Replica Lag shows a 5-second delay.
In the Azure portal, select read replica.
Select Metrics. In the Metrics window, select Read Replica Lag.
For your Aggregation, select Max.
Related content