Azure Documentation

Deploy Azure Database for PostgreSQL - Flexible Server

This tutorial guides you through deploying and configuring a PostgreSQL server instance in Azure using the Azure portal.

Note: This tutorial focuses on using the Azure portal for a quick deployment. For more advanced scenarios, consider using Azure CLI or ARM templates.

Prerequisites

1

Sign in to the Azure portal

Open your web browser and navigate to portal.azure.com. Sign in with your Azure account credentials.

2

Create a PostgreSQL resource

In the Azure portal search bar, type "Azure Database for PostgreSQL" and select it from the services list.

Click the + Create button.

3

Configure server settings

On the "Create Azure Database for PostgreSQL server" page, select the Flexible Server deployment option.

Fill in the following details:

  • Subscription: Select your Azure subscription.
  • Resource group: Create a new one (e.g., `myPostgresRG`) or select an existing one.
  • Server name: Enter a globally unique name for your server (e.g., `my-unique-postgres-server`).
  • Region: Choose the Azure region closest to you or your applications.
  • PostgreSQL version: Select a version (e.g., 13 or 14).
  • Workload: Choose "Development" or "Production" based on your needs.
  • Compute + Storage: Click "Configure server" to select your desired compute tier, vCores, and storage size. For development, a General Purpose tier with 2 vCores is often sufficient.
  • Authentication:
    • Authentication method: Choose "PostgreSQL authentication" for simplicity.
    • Server admin login: Enter a username for the server administrator (e.g., `postgresadmin`).
    • Password: Create a strong password and confirm it.
4

Configure networking

Navigate to the Networking tab.

For basic connectivity, you can select "Public access (allowed from any Azure service within Azure)". You will need to configure firewall rules later to restrict access.

For better security, consider setting up "Private access" with a Virtual Network.

5

Review and create

Review all the configuration settings on the Review + create tab. Ensure everything is correct.

Click the Create button.

The deployment process may take a few minutes. You'll see a notification when it's complete.

6

Connect to your PostgreSQL server

Once the deployment is successful, navigate to your newly created PostgreSQL server resource in the Azure portal.

On the Overview page, you'll find your Server name (fully qualified domain name) and the Admin username.

Connection Security:

Navigate to the Connection security blade.

Under Firewall rules, click + Add current client IP address to allow connections from your current location. You can also manually add IP address ranges.

You can now use a PostgreSQL client tool (like `psql`, pgAdmin, DBeaver) or an application to connect to your Azure Database for PostgreSQL server using the server name, admin username, password, and port 5432.

# Example using psql (replace placeholders)
psql "host=my-unique-postgres-server.postgres.database.azure.com port=5432 dbname=postgres user=postgresadmin password=YOUR_STRONG_PASSWORD sslmode=require"
7

Next Steps

Congratulations! You have successfully deployed an Azure Database for PostgreSQL server.

Consider the following for your next steps:

  • Create databases and users within your server.
  • Configure advanced networking and security settings.
  • Set up replication or high availability if needed.
  • Explore performance monitoring and tuning options.
  • Integrate with other Azure services like Azure App Service or Azure Functions.