Registry / azure / azure-mgmt-postgresqlflexibleservers

azure-mgmt-postgresqlflexibleservers

JSON →
library2.0.0pypypi✓ verified 24d ago

The `azure-mgmt-postgresqlflexibleservers` library is the Microsoft Azure Postgresqlflexibleservers Management Client Library for Python. It enables developers to programmatically create, configure, manage, and scale Azure Database for PostgreSQL flexible server instances. This includes operations like managing databases, configuring firewall rules, performing scaling, and handling backup and restore. The library is currently at version 2.0.0 and is actively maintained, receiving regular updates often in conjunction with Azure service updates.

pip install azure-mgmt-postgresqlflexibleservers azure-identity
INSTALL
IMPORT
SIG · AZURE-MGMT-POSTGRE
A
azure-mgmt-postgresqlflexibleservers
azurepythonv2.0.0
Install
4.7s avg
Import
619ms
Disk
47MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.648s · 47.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 4.7s · import 0.590s · 48MB
47MB installed
● package 47MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PostgreSQLManagementClient
from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient
DefaultAzureCredential
from azure.identity import DefaultAzureCredential
Used for authenticating with Azure services through a variety of credential types.

This quickstart demonstrates how to authenticate with Azure using `DefaultAzureCredential` and create a `PostgreSQLManagementClient` instance. It then proceeds to create a new Azure Database for PostgreSQL flexible server instance, waits for its provisioning, and lists existing servers. Ensure you have the necessary environment variables set (AZURE_SUBSCRIPTION_ID, AZURE_RESOURCE_GROUP, AZURE_LOCATION, AZURE_SERVER_NAME, AZURE_ADMIN_USERNAME, AZURE_ADMIN_PASSWORD) or are logged in via Azure CLI for authentication to work.

import os from azure.identity import DefaultAzureCredential from azure.mgmt.postgresqlflexibleservers import PostgreSQLManagementClient # Set environment variables or ensure Azure CLI is logged in # AZURE_SUBSCRIPTION_ID # AZURE_RESOURCE_GROUP # AZURE_LOCATION # AZURE_SERVER_NAME # AZURE_ADMIN_USERNAME # AZURE_ADMIN_PASSWORD subscription_id = os.environ.get('AZURE_SUBSCRIPTION_ID', 'YOUR_SUBSCRIPTION_ID') resource_group_name = os.environ.get('AZURE_RESOURCE_GROUP', 'my-postgresql-rg') server_name = os.environ.get('AZURE_SERVER_NAME', 'my-flex-server-123') location = os.environ.get('AZURE_LOCATION', 'eastus') # e.g., 'eastus' admin_username = os.environ.get('AZURE_ADMIN_USERNAME', 'psqladmin') admin_password = os.environ.get('AZURE_ADMIN_PASSWORD', 'ComplexP@ssw0rd') # Authenticate using DefaultAzureCredential credential = DefaultAzureCredential() # Create a PostgreSQLManagementClient client = PostgreSQLManagementClient(credential, subscription_id) print(f"Creating PostgreSQL flexible server '{server_name}' in resource group '{resource_group_name}'...") # Create a flexible server # This is an asynchronous operation, use .begin_create() and wait() for completion server_poller = client.servers.begin_create( resource_group_name, server_name, { "location": location, "sku": { "name": "Standard_D2ds_v4", "tier": "GeneralPurpose" }, "properties": { "version": "14", # or "12", "13", "15", etc. "administratorLogin": admin_username, "administratorLoginPassword": admin_password, "storage": { "storageSizeGB": 32 }, "network": { "publicNetworkAccess": "Enabled" } } } ) server = server_poller.result() # Wait for the creation to complete print(f"Server '{server.name}' created successfully in {server.location}.") print(f"Provisioning state: {server.provisioning_state}") # Example: List all servers in the resource group print(f"\nListing servers in resource group '{resource_group_name}':") for s in client.servers.list_by_resource_group(resource_group_name): print(f"- {s.name} ({s.location}) - State: {s.state}") # Note: This quickstart creates a resource. Remember to delete it after use # client.servers.begin_delete(resource_group_name, server_name).wait() # print(f"Server '{server_name}' deleted.")
Debug
Known issues
gotchaAuthentication with `DefaultAzureCredential` relies on specific environment variables (e.g., AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET, AZURE_SUBSCRIPTION_ID) or an active Azure CLI login. Incorrect or missing configuration is a frequent source of authentication errors.
fix
Ensure relevant environment variables are set or run `az login` to authenticate via Azure CLI. Refer to Azure SDK for Python authentication documentation for more details.
affects: >=1.0.0
gotchaDeployment of new Azure Database for PostgreSQL Flexible Servers can fail due to subscription-level quotas being exceeded or the selected region not having capacity or access enabled for your subscription. This often results in 'Exceeded quota' or 'Enable region' errors.
fix
Check your subscription's quotas and region access in the Azure portal. Submit a quota increase request if necessary, or choose a different region. Refer to Azure documentation on resolving capacity errors.
affects: >=1.0.0
gotchaNetwork access must be properly configured for your PostgreSQL flexible server. If using public access, you must add your client workstation's IP address to the server's firewall rules. If using private access, your client must be within the same virtual network as the server.
fix
For public access, use `client.firewall_rules.begin_create_or_update()` to add client IP. For private access, ensure your client is deployed within the configured VNet or peered VNet.
affects: >=1.0.0
gotchaThe library provides both synchronous (`azure.mgmt.postgresqlflexibleservers`) and asynchronous (`azure.mgmt.postgresqlflexibleservers.aio`) clients. Mixing them without proper `await`/`async` handling in Python can lead to runtime errors or unexpected behavior. Ensure consistency in your usage.
fix
For synchronous operations, import from `azure.mgmt.postgresqlflexibleservers`. For asynchronous operations, import from `azure.mgmt.postgresqlflexibleservers.aio` and use `async/await` syntax.
affects: >=1.0.0
gotchaIn-place major version upgrades of PostgreSQL instances performed via the management plane (exposed by this library) are irreversible. While they simplify the upgrade process, there is no automated rollback to the previous major version. Point-in-time recovery to before the upgrade is the only way to revert.
fix
Plan major version upgrades carefully. Consider performing a point-in-time recovery backup before initiating the upgrade if a rollback capability is critical for your scenario.
affects: >=1.0.0
Upgrade
Version history
2.0.0latest on PyPI · released Nov 25, 2025
Audit
Dependencies
azure-identityrequiredRequired for Azure Active Directory token authentication with DefaultAzureCredential, a common and recommended authentication method for Azure SDKs.
Agent activity
18 hits · last 30 days
node
16
OpenAI (training)
1
Resources