Secure your Azure Database for PostgreSQL flexible server

Azure Database for PostgreSQL is a fully managed database service that provides built-in high availability, automated backups, and scaling capabilities. Securing your PostgreSQL database deployments helps protect sensitive data and meet compliance requirements.

This article guides you on how to secure your Azure Database for PostgreSQL flexible server deployment.

The security recommendations in this article implement Zero Trust principles: "Verify explicitly", "Use least privilege access", and "Assume breach". For comprehensive Zero Trust guidance, see the Zero Trust Guidance Center.

Network security

Network security controls help you reduce public exposure and integrate Azure Database for PostgreSQL flexible server into a segmented virtual network architecture.

Identity and access management

Identity and access controls help you centralize authentication, reduce credential exposure, and enforce least privilege across Azure management and PostgreSQL database access.

  • Use Microsoft Entra authentication: Prefer Microsoft Entra authentication for PostgreSQL flexible server to centralize identity controls and reduce dependency on local database passwords. For more information, see Microsoft Entra authentication with Azure Database for PostgreSQL.

  • Manage Microsoft Entra principals: Assign and review Microsoft Entra administrators, users, and groups for PostgreSQL flexible server so database access follows least privilege. For more information, see Manage Microsoft Entra roles in Azure Database for PostgreSQL.

  • Use managed identities for application access: Authenticate Azure-hosted applications to PostgreSQL flexible server with managed identities instead of storing credentials in application code or configuration. For more information, see Managed identities in Azure Database for PostgreSQL.

  • Enforce Conditional Access for PostgreSQL administrators: Apply Conditional Access policies such as multifactor authentication and compliant-device requirements to identities that administer PostgreSQL flexible servers and related Azure resources. For more information, see Common Conditional Access policy: Require MFA for Azure management.

  • Use SCRAM for local authentication: If local PostgreSQL users are required, use SCRAM authentication and strong password practices to reduce password compromise risk. For more information, see SCRAM authentication in Azure Database for PostgreSQL.

  • Manage local database roles: Use PostgreSQL roles and permissions to restrict database-level access to the objects and operations each user needs. For more information, see Manage users in Azure Database for PostgreSQL.

  • Implement Azure role-based access control (RBAC): Assign Azure RBAC roles only to identities that need to create, configure, monitor, or delete PostgreSQL flexible server resources. For more information, see Azure role-based access control.

Data protection

Azure Database for PostgreSQL encrypts primary servers, replicas, point-in-time recovery data, and backups at rest by using service-managed keys. Use the following customer-configurable controls when your workload requires stronger encryption governance or data-use protections.

  • Verify TLS connections: Configure PostgreSQL clients to validate the server certificate chain and hostname by using sslmode=verify-full, or sslmode=verify-ca where verify-full isn't possible. For more information, see Transport Layer Security in Azure Database for PostgreSQL.

  • Maintain trusted root certificates: Keep Azure root certificate authorities in client trust stores and avoid trusting intermediate certificates or individual server certificates so certificate rotations don't break connectivity. For more information, see Transport Layer Security in Azure Database for PostgreSQL.

  • Require TLS 1.3 where supported: Set the ssl_min_protocol_version server parameter to TLSv1.3 for clients that support the latest secure protocol version, and don't set ssl_max_protocol_version. For more information, see Transport Layer Security in Azure Database for PostgreSQL.

  • Use customer-managed keys for encryption governance: Configure customer-managed keys in Azure Key Vault or Azure Managed HSM when you need key lifecycle control or separation of duties. For cross-tenant scenarios, host the encryption key in an Azure Key Vault or Azure Managed HSM instance in a different Microsoft Entra tenant than your flexible server, and the server uses that key for encryption at rest—useful when key ownership must stay separate from service operations. For more information, see Data encryption at rest in Azure Database for PostgreSQL and Configure data encryption in Azure Database for PostgreSQL.

  • Configure automatic key rotation: If you use customer-managed keys, enable key autorotation in Azure Key Vault or Azure Managed HSM and configure PostgreSQL flexible server to use automatic key version updates. For more information, see Configure customer-managed key encryption.

  • Use confidential computing for highly sensitive workloads: Deploy PostgreSQL flexible server on supported confidential computing SKUs in supported regions when you need hardware-based protection for data in use. For more information, see Azure confidential computing in Azure Database for PostgreSQL.

  • Apply data anonymization for sensitive PostgreSQL data: Use the anon extension when you need database-level data anonymization tools, and configure required shared preload libraries before use. For more information, see List of extensions and modules by name in Azure Database for PostgreSQL flexible server.

Logging and monitoring

Logging and monitoring controls help you detect suspicious activity, investigate incidents, and keep PostgreSQL audit evidence available for operational and compliance workflows.

Compliance and governance

Compliance and governance controls help you apply consistent configuration, map PostgreSQL deployments to regulatory requirements, and keep security ownership visible at scale.

  • Enforce PostgreSQL security configuration with Azure Policy: Assign built-in policies for PostgreSQL flexible server controls such as private endpoints, public access restrictions, diagnostic logging, TLS, customer-managed keys, and geo-redundant backup. For more information, see Azure Policy built-ins for Azure Database for PostgreSQL.

  • Review compliance offerings for PostgreSQL: Map Azure Database for PostgreSQL flexible server to relevant compliance certifications and attestations before you process regulated data. For more information, see Compliance in Azure Database for PostgreSQL.

  • Apply resource locks to production servers: Use management locks on production PostgreSQL flexible servers and dependent resources to reduce accidental deletion or disruptive configuration changes. For more information, see Protect your Azure resources with a lock.

  • Tag PostgreSQL resources for governance: Apply tags such as workload, environment, data classification, owner, and compliance scope to PostgreSQL flexible servers and related resources so policy, inventory, and cost-management workflows can identify protected databases. For more information, see Use tags to organize your Azure resources.

Backup and recovery

Backup and recovery controls help you restore PostgreSQL data after accidental deletion, corruption, or regional disruption while meeting workload recovery objectives.

Next steps