Deploy Azure Database for PostgreSQL Single Server

The azure-native:dbforpostgresql:SingleServer resource, part of the Pulumi Azure Native provider, provisions Azure Database for PostgreSQL single servers: compute tier, storage capacity, security policies, and operational modes (new server, restore, replica). This guide focuses on three capabilities: creating new servers with storage and security settings, point-in-time and geo-redundant restore, and read replica configuration.

Servers require an Azure resource group and may reference source servers for restore or replication operations. The examples are intentionally small. Combine them with your own resource groups, networking, and monitoring infrastructure.

Create a new server with storage and security settings

Most deployments start by provisioning a new server with administrator credentials, storage capacity, and security policies.

import * as pulumi from "@pulumi/pulumi";
import * as azure_native from "@pulumi/azure-native";

const singleServer = new azure_native.dbforpostgresql.SingleServer("singleServer", {
    location: "westus",
    properties: {
        administratorLogin: "cloudsa",
        administratorLoginPassword: "<administratorLoginPassword>",
        createMode: "Default",
        minimalTlsVersion: azure_native.dbforpostgresql.MinimalTlsVersionEnum.TLS1_2,
        sslEnforcement: azure_native.dbforpostgresql.SslEnforcementEnum.Enabled,
        storageProfile: {
            backupRetentionDays: 7,
            geoRedundantBackup: azure_native.dbforpostgresql.GeoRedundantBackup.Disabled,
            storageMB: 128000,
        },
    },
    resourceGroupName: "TestGroup",
    serverName: "pgtestsvc4",
    sku: {
        capacity: 2,
        family: "Gen5",
        name: "B_Gen5_2",
        tier: azure_native.dbforpostgresql.SingleServerSkuTier.Basic,
    },
    tags: {
        ElasticServer: "1",
    },
});
import pulumi
import pulumi_azure_native as azure_native

single_server = azure_native.dbforpostgresql.SingleServer("singleServer",
    location="westus",
    properties={
        "administrator_login": "cloudsa",
        "administrator_login_password": "<administratorLoginPassword>",
        "create_mode": "Default",
        "minimal_tls_version": azure_native.dbforpostgresql.MinimalTlsVersionEnum.TLS1_2,
        "ssl_enforcement": azure_native.dbforpostgresql.SslEnforcementEnum.ENABLED,
        "storage_profile": {
            "backup_retention_days": 7,
            "geo_redundant_backup": azure_native.dbforpostgresql.GeoRedundantBackup.DISABLED,
            "storage_mb": 128000,
        },
    },
    resource_group_name="TestGroup",
    server_name="pgtestsvc4",
    sku={
        "capacity": 2,
        "family": "Gen5",
        "name": "B_Gen5_2",
        "tier": azure_native.dbforpostgresql.SingleServerSkuTier.BASIC,
    },
    tags={
        "ElasticServer": "1",
    })
package main

import (
	dbforpostgresql "github.com/pulumi/pulumi-azure-native-sdk/dbforpostgresql/v3"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := dbforpostgresql.NewSingleServer(ctx, "singleServer", &dbforpostgresql.SingleServerArgs{
			Location: pulumi.String("westus"),
			Properties: &dbforpostgresql.ServerPropertiesForDefaultCreateArgs{
				AdministratorLogin:         pulumi.String("cloudsa"),
				AdministratorLoginPassword: pulumi.String("<administratorLoginPassword>"),
				CreateMode:                 pulumi.String("Default"),
				MinimalTlsVersion:          pulumi.String(dbforpostgresql.MinimalTlsVersionEnum_TLS1_2),
				SslEnforcement:             dbforpostgresql.SslEnforcementEnumEnabled,
				StorageProfile: &dbforpostgresql.StorageProfileArgs{
					BackupRetentionDays: pulumi.Int(7),
					GeoRedundantBackup:  pulumi.String(dbforpostgresql.GeoRedundantBackupDisabled),
					StorageMB:           pulumi.Int(128000),
				},
			},
			ResourceGroupName: pulumi.String("TestGroup"),
			ServerName:        pulumi.String("pgtestsvc4"),
			Sku: &dbforpostgresql.SingleServerSkuArgs{
				Capacity: pulumi.Int(2),
				Family:   pulumi.String("Gen5"),
				Name:     pulumi.String("B_Gen5_2"),
				Tier:     pulumi.String(dbforpostgresql.SingleServerSkuTierBasic),
			},
			Tags: pulumi.StringMap{
				"ElasticServer": pulumi.String("1"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;

return await Deployment.RunAsync(() => 
{
    var singleServer = new AzureNative.DBforPostgreSQL.SingleServer("singleServer", new()
    {
        Location = "westus",
        Properties = new AzureNative.DBforPostgreSQL.Inputs.ServerPropertiesForDefaultCreateArgs
        {
            AdministratorLogin = "cloudsa",
            AdministratorLoginPassword = "<administratorLoginPassword>",
            CreateMode = "Default",
            MinimalTlsVersion = AzureNative.DBforPostgreSQL.MinimalTlsVersionEnum.TLS1_2,
            SslEnforcement = AzureNative.DBforPostgreSQL.SslEnforcementEnum.Enabled,
            StorageProfile = new AzureNative.DBforPostgreSQL.Inputs.StorageProfileArgs
            {
                BackupRetentionDays = 7,
                GeoRedundantBackup = AzureNative.DBforPostgreSQL.GeoRedundantBackup.Disabled,
                StorageMB = 128000,
            },
        },
        ResourceGroupName = "TestGroup",
        ServerName = "pgtestsvc4",
        Sku = new AzureNative.DBforPostgreSQL.Inputs.SingleServerSkuArgs
        {
            Capacity = 2,
            Family = "Gen5",
            Name = "B_Gen5_2",
            Tier = AzureNative.DBforPostgreSQL.SingleServerSkuTier.Basic,
        },
        Tags = 
        {
            { "ElasticServer", "1" },
        },
    });

});
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.dbforpostgresql.SingleServer;
import com.pulumi.azurenative.dbforpostgresql.SingleServerArgs;
import com.pulumi.azurenative.dbforpostgresql.inputs.SingleServerSkuArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var singleServer = new SingleServer("singleServer", SingleServerArgs.builder()
            .location("westus")
            .properties(ServerPropertiesForDefaultCreateArgs.builder()
                .administratorLogin("cloudsa")
                .administratorLoginPassword("<administratorLoginPassword>")
                .createMode("Default")
                .minimalTlsVersion("TLS1_2")
                .sslEnforcement("Enabled")
                .storageProfile(StorageProfileArgs.builder()
                    .backupRetentionDays(7)
                    .geoRedundantBackup("Disabled")
                    .storageMB(128000)
                    .build())
                .build())
            .resourceGroupName("TestGroup")
            .serverName("pgtestsvc4")
            .sku(SingleServerSkuArgs.builder()
                .capacity(2)
                .family("Gen5")
                .name("B_Gen5_2")
                .tier("Basic")
                .build())
            .tags(Map.of("ElasticServer", "1"))
            .build());

    }
}
resources:
  singleServer:
    type: azure-native:dbforpostgresql:SingleServer
    properties:
      location: westus
      properties:
        administratorLogin: cloudsa
        administratorLoginPassword: <administratorLoginPassword>
        createMode: Default
        minimalTlsVersion: TLS1_2
        sslEnforcement: Enabled
        storageProfile:
          backupRetentionDays: 7
          geoRedundantBackup: Disabled
          storageMB: 128000
      resourceGroupName: TestGroup
      serverName: pgtestsvc4
      sku:
        capacity: 2
        family: Gen5
        name: B_Gen5_2
        tier: Basic
      tags:
        ElasticServer: '1'

The createMode property set to “Default” creates a new server from scratch. The administratorLogin and administratorLoginPassword establish initial access credentials. The storageProfile defines storage capacity (storageMB), backup retention (backupRetentionDays), and geo-redundancy (geoRedundantBackup). The sslEnforcement and minimalTlsVersion properties enforce encrypted connections. The sku property determines compute capacity using tier (Basic, GeneralPurpose, MemoryOptimized), family (Gen5), and capacity (vCores).

Restore a server to a specific point in time

When recovering from data corruption or testing rollback scenarios, teams restore servers to a specific timestamp from automated backups.

import * as pulumi from "@pulumi/pulumi";
import * as azure_native from "@pulumi/azure-native";

const singleServer = new azure_native.dbforpostgresql.SingleServer("singleServer", {
    location: "brazilsouth",
    properties: {
        createMode: "PointInTimeRestore",
        restorePointInTime: "2017-12-14T00:00:37.467Z",
        sourceServerId: "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforPostgreSQL/servers/sourceserver",
    },
    resourceGroupName: "TargetResourceGroup",
    serverName: "targetserver",
    sku: {
        capacity: 2,
        family: "Gen5",
        name: "B_Gen5_2",
        tier: azure_native.dbforpostgresql.SingleServerSkuTier.Basic,
    },
    tags: {
        ElasticServer: "1",
    },
});
import pulumi
import pulumi_azure_native as azure_native

single_server = azure_native.dbforpostgresql.SingleServer("singleServer",
    location="brazilsouth",
    properties={
        "create_mode": "PointInTimeRestore",
        "restore_point_in_time": "2017-12-14T00:00:37.467Z",
        "source_server_id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforPostgreSQL/servers/sourceserver",
    },
    resource_group_name="TargetResourceGroup",
    server_name="targetserver",
    sku={
        "capacity": 2,
        "family": "Gen5",
        "name": "B_Gen5_2",
        "tier": azure_native.dbforpostgresql.SingleServerSkuTier.BASIC,
    },
    tags={
        "ElasticServer": "1",
    })
package main

import (
	dbforpostgresql "github.com/pulumi/pulumi-azure-native-sdk/dbforpostgresql/v3"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := dbforpostgresql.NewSingleServer(ctx, "singleServer", &dbforpostgresql.SingleServerArgs{
			Location: pulumi.String("brazilsouth"),
			Properties: &dbforpostgresql.ServerPropertiesForRestoreArgs{
				CreateMode:         pulumi.String("PointInTimeRestore"),
				RestorePointInTime: pulumi.String("2017-12-14T00:00:37.467Z"),
				SourceServerId:     pulumi.String("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforPostgreSQL/servers/sourceserver"),
			},
			ResourceGroupName: pulumi.String("TargetResourceGroup"),
			ServerName:        pulumi.String("targetserver"),
			Sku: &dbforpostgresql.SingleServerSkuArgs{
				Capacity: pulumi.Int(2),
				Family:   pulumi.String("Gen5"),
				Name:     pulumi.String("B_Gen5_2"),
				Tier:     pulumi.String(dbforpostgresql.SingleServerSkuTierBasic),
			},
			Tags: pulumi.StringMap{
				"ElasticServer": pulumi.String("1"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;

return await Deployment.RunAsync(() => 
{
    var singleServer = new AzureNative.DBforPostgreSQL.SingleServer("singleServer", new()
    {
        Location = "brazilsouth",
        Properties = new AzureNative.DBforPostgreSQL.Inputs.ServerPropertiesForRestoreArgs
        {
            CreateMode = "PointInTimeRestore",
            RestorePointInTime = "2017-12-14T00:00:37.467Z",
            SourceServerId = "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforPostgreSQL/servers/sourceserver",
        },
        ResourceGroupName = "TargetResourceGroup",
        ServerName = "targetserver",
        Sku = new AzureNative.DBforPostgreSQL.Inputs.SingleServerSkuArgs
        {
            Capacity = 2,
            Family = "Gen5",
            Name = "B_Gen5_2",
            Tier = AzureNative.DBforPostgreSQL.SingleServerSkuTier.Basic,
        },
        Tags = 
        {
            { "ElasticServer", "1" },
        },
    });

});
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.dbforpostgresql.SingleServer;
import com.pulumi.azurenative.dbforpostgresql.SingleServerArgs;
import com.pulumi.azurenative.dbforpostgresql.inputs.SingleServerSkuArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var singleServer = new SingleServer("singleServer", SingleServerArgs.builder()
            .location("brazilsouth")
            .properties(ServerPropertiesForRestoreArgs.builder()
                .createMode("PointInTimeRestore")
                .restorePointInTime("2017-12-14T00:00:37.467Z")
                .sourceServerId("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforPostgreSQL/servers/sourceserver")
                .build())
            .resourceGroupName("TargetResourceGroup")
            .serverName("targetserver")
            .sku(SingleServerSkuArgs.builder()
                .capacity(2)
                .family("Gen5")
                .name("B_Gen5_2")
                .tier("Basic")
                .build())
            .tags(Map.of("ElasticServer", "1"))
            .build());

    }
}
resources:
  singleServer:
    type: azure-native:dbforpostgresql:SingleServer
    properties:
      location: brazilsouth
      properties:
        createMode: PointInTimeRestore
        restorePointInTime: 2017-12-14T00:00:37.467Z
        sourceServerId: /subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforPostgreSQL/servers/sourceserver
      resourceGroupName: TargetResourceGroup
      serverName: targetserver
      sku:
        capacity: 2
        family: Gen5
        name: B_Gen5_2
        tier: Basic
      tags:
        ElasticServer: '1'

The createMode property set to “PointInTimeRestore” creates a new server from a backup snapshot. The restorePointInTime specifies the exact timestamp (ISO8601 format) to restore from. The sourceServerId references the original server’s Azure resource ID. The restored server inherits the source server’s configuration but can use a different SKU or location.

Create a read replica for scaling read workloads

Applications with heavy read traffic distribute queries across read replicas to reduce load on the primary server.

import * as pulumi from "@pulumi/pulumi";
import * as azure_native from "@pulumi/azure-native";

const singleServer = new azure_native.dbforpostgresql.SingleServer("singleServer", {
    location: "westcentralus",
    properties: {
        createMode: "Replica",
        sourceServerId: "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup_WestCentralUS/providers/Microsoft.DBforPostgreSQL/servers/testserver-master",
    },
    resourceGroupName: "TestGroup_WestCentralUS",
    serverName: "testserver-replica1",
    sku: {
        capacity: 2,
        family: "Gen5",
        name: "GP_Gen5_2",
        tier: azure_native.dbforpostgresql.SingleServerSkuTier.GeneralPurpose,
    },
});
import pulumi
import pulumi_azure_native as azure_native

single_server = azure_native.dbforpostgresql.SingleServer("singleServer",
    location="westcentralus",
    properties={
        "create_mode": "Replica",
        "source_server_id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup_WestCentralUS/providers/Microsoft.DBforPostgreSQL/servers/testserver-master",
    },
    resource_group_name="TestGroup_WestCentralUS",
    server_name="testserver-replica1",
    sku={
        "capacity": 2,
        "family": "Gen5",
        "name": "GP_Gen5_2",
        "tier": azure_native.dbforpostgresql.SingleServerSkuTier.GENERAL_PURPOSE,
    })
package main

import (
	dbforpostgresql "github.com/pulumi/pulumi-azure-native-sdk/dbforpostgresql/v3"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := dbforpostgresql.NewSingleServer(ctx, "singleServer", &dbforpostgresql.SingleServerArgs{
			Location: pulumi.String("westcentralus"),
			Properties: &dbforpostgresql.ServerPropertiesForReplicaArgs{
				CreateMode:     pulumi.String("Replica"),
				SourceServerId: pulumi.String("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup_WestCentralUS/providers/Microsoft.DBforPostgreSQL/servers/testserver-master"),
			},
			ResourceGroupName: pulumi.String("TestGroup_WestCentralUS"),
			ServerName:        pulumi.String("testserver-replica1"),
			Sku: &dbforpostgresql.SingleServerSkuArgs{
				Capacity: pulumi.Int(2),
				Family:   pulumi.String("Gen5"),
				Name:     pulumi.String("GP_Gen5_2"),
				Tier:     pulumi.String(dbforpostgresql.SingleServerSkuTierGeneralPurpose),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;

return await Deployment.RunAsync(() => 
{
    var singleServer = new AzureNative.DBforPostgreSQL.SingleServer("singleServer", new()
    {
        Location = "westcentralus",
        Properties = new AzureNative.DBforPostgreSQL.Inputs.ServerPropertiesForReplicaArgs
        {
            CreateMode = "Replica",
            SourceServerId = "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup_WestCentralUS/providers/Microsoft.DBforPostgreSQL/servers/testserver-master",
        },
        ResourceGroupName = "TestGroup_WestCentralUS",
        ServerName = "testserver-replica1",
        Sku = new AzureNative.DBforPostgreSQL.Inputs.SingleServerSkuArgs
        {
            Capacity = 2,
            Family = "Gen5",
            Name = "GP_Gen5_2",
            Tier = AzureNative.DBforPostgreSQL.SingleServerSkuTier.GeneralPurpose,
        },
    });

});
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.dbforpostgresql.SingleServer;
import com.pulumi.azurenative.dbforpostgresql.SingleServerArgs;
import com.pulumi.azurenative.dbforpostgresql.inputs.SingleServerSkuArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var singleServer = new SingleServer("singleServer", SingleServerArgs.builder()
            .location("westcentralus")
            .properties(ServerPropertiesForReplicaArgs.builder()
                .createMode("Replica")
                .sourceServerId("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup_WestCentralUS/providers/Microsoft.DBforPostgreSQL/servers/testserver-master")
                .build())
            .resourceGroupName("TestGroup_WestCentralUS")
            .serverName("testserver-replica1")
            .sku(SingleServerSkuArgs.builder()
                .capacity(2)
                .family("Gen5")
                .name("GP_Gen5_2")
                .tier("GeneralPurpose")
                .build())
            .build());

    }
}
resources:
  singleServer:
    type: azure-native:dbforpostgresql:SingleServer
    properties:
      location: westcentralus
      properties:
        createMode: Replica
        sourceServerId: /subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup_WestCentralUS/providers/Microsoft.DBforPostgreSQL/servers/testserver-master
      resourceGroupName: TestGroup_WestCentralUS
      serverName: testserver-replica1
      sku:
        capacity: 2
        family: Gen5
        name: GP_Gen5_2
        tier: GeneralPurpose

The createMode property set to “Replica” creates a read-only copy that continuously replicates from the master. The sourceServerId references the master server’s Azure resource ID. Replicas can be in the same region or a different region for geographic distribution. The replicationRole property (set automatically) distinguishes master from replica servers.

Restore a server from geo-redundant backup

Disaster recovery scenarios require restoring servers from geo-redundant backups when the primary region becomes unavailable.

import * as pulumi from "@pulumi/pulumi";
import * as azure_native from "@pulumi/azure-native";

const singleServer = new azure_native.dbforpostgresql.SingleServer("singleServer", {
    location: "westus",
    properties: {
        createMode: "GeoRestore",
        sourceServerId: "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforPostgreSQL/servers/sourceserver",
    },
    resourceGroupName: "TargetResourceGroup",
    serverName: "targetserver",
    sku: {
        capacity: 2,
        family: "Gen5",
        name: "GP_Gen5_2",
        tier: azure_native.dbforpostgresql.SingleServerSkuTier.GeneralPurpose,
    },
    tags: {
        ElasticServer: "1",
    },
});
import pulumi
import pulumi_azure_native as azure_native

single_server = azure_native.dbforpostgresql.SingleServer("singleServer",
    location="westus",
    properties={
        "create_mode": "GeoRestore",
        "source_server_id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforPostgreSQL/servers/sourceserver",
    },
    resource_group_name="TargetResourceGroup",
    server_name="targetserver",
    sku={
        "capacity": 2,
        "family": "Gen5",
        "name": "GP_Gen5_2",
        "tier": azure_native.dbforpostgresql.SingleServerSkuTier.GENERAL_PURPOSE,
    },
    tags={
        "ElasticServer": "1",
    })
package main

import (
	dbforpostgresql "github.com/pulumi/pulumi-azure-native-sdk/dbforpostgresql/v3"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := dbforpostgresql.NewSingleServer(ctx, "singleServer", &dbforpostgresql.SingleServerArgs{
			Location: pulumi.String("westus"),
			Properties: &dbforpostgresql.ServerPropertiesForGeoRestoreArgs{
				CreateMode:     pulumi.String("GeoRestore"),
				SourceServerId: pulumi.String("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforPostgreSQL/servers/sourceserver"),
			},
			ResourceGroupName: pulumi.String("TargetResourceGroup"),
			ServerName:        pulumi.String("targetserver"),
			Sku: &dbforpostgresql.SingleServerSkuArgs{
				Capacity: pulumi.Int(2),
				Family:   pulumi.String("Gen5"),
				Name:     pulumi.String("GP_Gen5_2"),
				Tier:     pulumi.String(dbforpostgresql.SingleServerSkuTierGeneralPurpose),
			},
			Tags: pulumi.StringMap{
				"ElasticServer": pulumi.String("1"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;

return await Deployment.RunAsync(() => 
{
    var singleServer = new AzureNative.DBforPostgreSQL.SingleServer("singleServer", new()
    {
        Location = "westus",
        Properties = new AzureNative.DBforPostgreSQL.Inputs.ServerPropertiesForGeoRestoreArgs
        {
            CreateMode = "GeoRestore",
            SourceServerId = "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforPostgreSQL/servers/sourceserver",
        },
        ResourceGroupName = "TargetResourceGroup",
        ServerName = "targetserver",
        Sku = new AzureNative.DBforPostgreSQL.Inputs.SingleServerSkuArgs
        {
            Capacity = 2,
            Family = "Gen5",
            Name = "GP_Gen5_2",
            Tier = AzureNative.DBforPostgreSQL.SingleServerSkuTier.GeneralPurpose,
        },
        Tags = 
        {
            { "ElasticServer", "1" },
        },
    });

});
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.dbforpostgresql.SingleServer;
import com.pulumi.azurenative.dbforpostgresql.SingleServerArgs;
import com.pulumi.azurenative.dbforpostgresql.inputs.SingleServerSkuArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var singleServer = new SingleServer("singleServer", SingleServerArgs.builder()
            .location("westus")
            .properties(ServerPropertiesForGeoRestoreArgs.builder()
                .createMode("GeoRestore")
                .sourceServerId("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforPostgreSQL/servers/sourceserver")
                .build())
            .resourceGroupName("TargetResourceGroup")
            .serverName("targetserver")
            .sku(SingleServerSkuArgs.builder()
                .capacity(2)
                .family("Gen5")
                .name("GP_Gen5_2")
                .tier("GeneralPurpose")
                .build())
            .tags(Map.of("ElasticServer", "1"))
            .build());

    }
}
resources:
  singleServer:
    type: azure-native:dbforpostgresql:SingleServer
    properties:
      location: westus
      properties:
        createMode: GeoRestore
        sourceServerId: /subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/SourceResourceGroup/providers/Microsoft.DBforPostgreSQL/servers/sourceserver
      resourceGroupName: TargetResourceGroup
      serverName: targetserver
      sku:
        capacity: 2
        family: Gen5
        name: GP_Gen5_2
        tier: GeneralPurpose
      tags:
        ElasticServer: '1'

The createMode property set to “GeoRestore” creates a new server from a geo-redundant backup. The sourceServerId references the original server in a different region. The location property specifies the target region for recovery. This requires the source server to have geoRedundantBackup enabled in its storageProfile.

Beyond these examples

These snippets focus on specific server-level features: server creation with storage and security configuration, point-in-time and geo-redundant restore, and read replica topology. They’re intentionally minimal rather than full database deployments.

The examples may reference pre-existing infrastructure such as Azure resource groups and source servers for restore and replication operations. They focus on configuring the server rather than provisioning everything around it.

To keep things focused, common server patterns are omitted, including:

  • Azure AD identity integration (identity property)
  • Private endpoint connections and network isolation
  • Infrastructure encryption and customer-managed keys
  • Public network access controls (publicNetworkAccess)

These omissions are intentional: the goal is to illustrate how each server feature is wired, not provide drop-in database modules. See the SingleServer resource reference for all available configuration options.

Let's deploy Azure Database for PostgreSQL Single Server

Get started with Pulumi Cloud, then follow our quick setup guide to deploy this infrastructure.

Try Pulumi Cloud for FREE

Frequently Asked Questions

Server Creation & Restore
What are the different ways to create a PostgreSQL Single Server?
You can create a server using four createMode values: Default for a new server, PointInTimeRestore to restore from a backup, Replica to create a read replica, or GeoRestore for geo-redundant restore.
How do I restore a server from a point in time?
Set createMode to PointInTimeRestore, specify sourceServerId with the source server’s resource ID, and provide restorePointInTime in ISO8601 format (e.g., “2017-12-14T00:00:37.467Z”).
How do I create a read replica?
Set createMode to Replica and specify sourceServerId pointing to the master server’s resource ID. The replica inherits the master’s configuration.
How do I perform a geo-restore?
Set createMode to GeoRestore, specify sourceServerId with the source server’s resource ID, and set location to your target region.
What credentials do I need when creating a new server?
For createMode set to Default, you must provide administratorLogin and administratorLoginPassword in the properties.
Configuration & Security
How do I enforce TLS for my PostgreSQL server?
Set minimalTlsVersion to enforce a minimum TLS version (e.g., TLS1_2). This ensures clients use secure connections.
How do I require SSL connections?
Set sslEnforcement to Enabled to require SSL for all connections to the server.
How do I configure backup retention and storage?
Use storageProfile to set backupRetentionDays (retention period), geoRedundantBackup (Enabled or Disabled), and storageMB (storage size in megabytes).
SKU & Pricing Tiers
What SKU tiers are available?
The examples show Basic and GeneralPurpose tiers. Configure the sku with capacity, family (e.g., “Gen5”), name (e.g., “B_Gen5_2” or “GP_Gen5_2”), and tier.
Immutability & Limitations
What properties can't I change after creating the server?
The resourceGroupName and serverName properties are immutable and cannot be modified after creation. Changing them requires recreating the server.

Using a different cloud?

Explore database guides for other cloud providers: