Skip to content
Back to Blog
1 min read

Azure Arc-Enabled PostgreSQL Hyperscale

I wrote “Azure Arc-Enabled PostgreSQL Hyperscale” to share practical, production-minded guidance on this topic.

Understanding Azure Arc Data Services

Azure Arc extends Azure management to any infrastructure. With Arc-enabled data services, you get:

  • Azure-managed PostgreSQL on your own infrastructure
  • Elastic scale-out with Citus
  • Always up-to-date with automated updates
  • Unified management through Azure portal

Prerequisites

# Install Azure CLI extensions
az extension add --name arcdata
az extension add --name k8s-extension
az extension add --name connectedk8s

# Connect your Kubernetes cluster to Azure Arc
az connectedk8s connect \
    --name myArcCluster \
    --resource-group myResourceGroup \
    --location eastus

Deploying the Data Controller

# Create the data controller
az arcdata dc create \
    --name arc-dc \
    --resource-group myResourceGroup \
    --location eastus \
    --connectivity-mode indirect \
    --k8s-namespace arc \
    --use-k8s

# Or use direct connectivity for full Azure integration
az arcdata dc create \
    --name arc-dc \
    --resource-group myResourceGroup \
    --location eastus \
    --connectivity-mode direct \
    --subscription $SUBSCRIPTION_ID \
    --custom-location myCustomLocation \
    --k8s-namespace arc

Creating PostgreSQL Hyperscale Server Group

# postgresql-hyperscale.yaml
apiVersion: arcdata.microsoft.com/v1
kind: PostgreSql
metadata:
  name: my-postgres-hs
  namespace: arc
spec:
  scheduling:
    default:
      resources:
        requests:
          memory: "2Gi"
          cpu: "1"
        limits:
          memory: "4Gi"
          cpu: "2"
  storage:
    data:
      className: managed-premium
      size: 100Gi
    logs:
      className: managed-premium
      size: 10Gi
  scale:
    workers: 3
  engine:
    extensions:
      - name: citus
      - name: pg_stat_statements
# Apply the configuration
kubectl apply -f postgresql-hyperscale.yaml

# Or use Azure CLI
az postgres arc-server create \
    --name my-postgres-hs \
    --k8s-namespace arc \
    --workers 3 \
    --cores-request 1 \
    --cores-limit 2 \
    --memory-request 2Gi \
    --memory-limit 4Gi \
    --storage-class-data managed-premium \
    --volume-size-data 100Gi \
    --use-k8s

Connecting to Your Server Group

# Get connection endpoint
az postgres arc-server endpoint list \
    --name my-postgres-hs \
    --k8s-namespace arc \
    --use-k8s

# Connect using psql
PGPASSWORD='mypassword' psql -h <endpoint> -U postgres -d postgres
import psycopg2

# Connection to Arc-enabled PostgreSQL
conn = psycopg2.connect(
    host="my-postgres-hs.arc.svc.cluster.local",
    port=5432,
    database="postgres",
    user="postgres",
    password="mypassword"
)

# Test distributed table creation
with conn.cursor() as cur:
    cur.execute("SELECT citus_version();")
    print(cur.fetchone())

    cur.execute("""
        CREATE TABLE events (
            id bigserial,
            tenant_id int,
            data jsonb
        );
        SELECT create_distributed_table('events', 'tenant_id');
    """)
    conn.commit()

Scaling Operations

# Scale out workers
az postgres arc-server edit \
    --name my-postgres-hs \
    --k8s-namespace arc \
    --workers 5 \
    --use-k8s

# Scale up resources
az postgres arc-server edit \
    --name my-postgres-hs \
    --k8s-namespace arc \
    --cores-request 2 \
    --memory-request 4Gi \
    --use-k8s

Monitoring with Grafana

# Get Grafana endpoint
az arcdata dc endpoint list \
    --k8s-namespace arc \
    --use-k8s

# Access dashboards at https://<grafana-endpoint>/dashboards

Backup and Restore

# Create a backup
az postgres arc-server backup create \
    --name my-postgres-hs \
    --k8s-namespace arc \
    --use-k8s

# List backups
az postgres arc-server backup list \
    --name my-postgres-hs \
    --k8s-namespace arc \
    --use-k8s

# Restore from backup
az postgres arc-server backup restore \
    --name my-postgres-hs \
    --k8s-namespace arc \
    --backup-id <backup-id> \
    --use-k8s

Azure Arc-enabled PostgreSQL Hyperscale brings the best of Azure’s managed database services to wherever your data needs to live.\n\n## Takeaways\n\nAdd a concise, personal takeaway and recommended next steps here.\n

Michael John Peña

Michael John Peña

Senior Data Engineer based in Sydney. Writing about data, cloud, and technology.