POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/restart?api-version=2025-08-01
URI Parameters
Name
In
Required
Type
Description
resourceGroupName
path
True
string
minLength: 1 maxLength: 90
The name of the resource group. The name is case insensitive.
Indicates if restart the PostgreSQL database engine should failover or switch over from primary to standby. This only works if server has high availability enabled.
POST https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver/restart?api-version=2025-08-01
{
"restartWithFailover": true,
"failoverMode": "ForcedFailover"
}
import com.azure.resourcemanager.postgresqlflexibleserver.models.FailoverMode;
import com.azure.resourcemanager.postgresqlflexibleserver.models.RestartParameter;
/**
* Samples for Servers Restart.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/
* ServersRestartWithFailover.json
*/
/**
* Sample code: Restart PostgreSQL database engine in a server with a forced failover to standby server.
*
* @param manager Entry point to PostgreSqlManager.
*/
public static void restartPostgreSQLDatabaseEngineInAServerWithAForcedFailoverToStandbyServer(
com.azure.resourcemanager.postgresqlflexibleserver.PostgreSqlManager manager) {
manager.servers().restart("exampleresourcegroup", "exampleserver",
new RestartParameter().withRestartWithFailover(true).withFailoverMode(FailoverMode.FORCED_FAILOVER),
com.azure.core.util.Context.NONE);
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-postgresqlflexibleservers
# USAGE
python servers_restart_with_failover.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = PostgreSQLManagementClient(
credential=DefaultAzureCredential(),
subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff",
)
client.servers.begin_restart(
resource_group_name="exampleresourcegroup",
server_name="exampleserver",
).result()
# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersRestartWithFailover.json
if __name__ == "__main__":
main()
POST https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver/restart?api-version=2025-08-01
/**
* Samples for Servers Restart.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersRestart.
* json
*/
/**
* Sample code: Restart PostgreSQL database engine in a server.
*
* @param manager Entry point to PostgreSqlManager.
*/
public static void restartPostgreSQLDatabaseEngineInAServer(
com.azure.resourcemanager.postgresqlflexibleserver.PostgreSqlManager manager) {
manager.servers().restart("exampleresourcegroup", "exampleserver", null, com.azure.core.util.Context.NONE);
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-postgresqlflexibleservers
# USAGE
python servers_restart.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = PostgreSQLManagementClient(
credential=DefaultAzureCredential(),
subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff",
)
client.servers.begin_restart(
resource_group_name="exampleresourcegroup",
server_name="exampleserver",
).result()
# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2025-08-01/examples/ServersRestart.json
if __name__ == "__main__":
main()
Triggers a failover from primary to standby without killing the primary database process first. This is a graceful failover that attempts to preserve data consistency.
ForcedFailover
Kills the primary database process first, then triggers the failover. This is more aggressive and used when the primary is unresponsive or in an unhealthy state.
PlannedSwitchover
Similar to 'PlannedFailover' but prefers a switch over operation where roles are swapped between primary and standby.
ForcedSwitchover
Kills the primary database process and then triggers a switch over with role swapping.
Indicates if restart the PostgreSQL database engine should failover or switch over from primary to standby. This only works if server has high availability enabled.