PostgreSQL

Overview

The PostgreSQL module contains two builders - postgreSQL, used to create PostgreSQL Azure servers, and postgreSQLDb, used to create individual databases. It supports features such as firewall, autogrow and version selection. Every PostgreSQL Azure server you create will automatically create a SecureString parameter for the admin account password.

There is support for newer “Flexible” as well as the original “Single Server” server type. Several keywords are overloaded to cater for both server types. By default, the builder uses the Flexible Server model.

  • PostgreSQL server (Microsoft.DBforPostgreSQL/servers)
  • PostgreSQL server (Microsoft.DBforPostgreSQL/flexibleServers)

PostgreSQL Builder keywords

Applies ToKeywordPurpose
Servername (string)Sets the name of the PostgreSQL server.
Serveradmin_username (string)Sets the admin username of the server.
Servergeo_redundant_backup (bool)Enables/disables geo-redundant backup
Serverenable_geo_redundant_backupEnables geo-redundant backup
Serverdisable_geo_redundant_backupDisables geo-redundant backup
Serverstorage_autogrow (bool)Enables/disables auto-grow storage
Serverenable_storage_autogrowEnables auto-grow storage
Serverdisable_storage_autogrowDisables auto-grow storage
Serverstorage_size (int<Gb>)Sets the initial size of the storage available
Serverstorage_performance_tier (Vm.DiskPerformanceTier)Sets the storage performance tier of the server.
Serverbackup_retention (int<Days>)Sets the number of days to keep backups
Serverserver_version (Version)Selects the PostgreSQL version of the server
Servercapacity (int<VCores>)Sets the number of cores for the server
Servertier (Sku)Sets the service tier of the server
Serveradd_database (database:Database)Adds a database from the result of a postgreSQLDb builder expression
Serveradd_database (name:string)Adds a database with name of name
Serverenable_azure_firewallEnables firewall access to all Azure services
Serveradd_firewall_rule (name:string, start ip:string, end ip:string)Adds a firewall rule to the server
Serveradd_firewall_rules (rules:(stringstringsting)list)As add_firewall_rule but a list of rules
Serveradd_vnet_rule (name:string, virtualNetworkSubnetId:ResourceId)Adds a vnet rule to the server
Serveradd_vnet_rules (rules:(string*ResourceId)list)As add_vnet_rule but a list of rules
Configuration Members
MemberPurpose
FullyQualifiedDomainNameThe fully qualified domain name for the server endpoint.

PostgreSQLDb Builder keywords

Applies ToKeywordPurpose
Databasename (string)Sets the name of the PostgreSQL database
Databasecollation (string)Sets the collation of the postgreSQL database
Databasecharset (string)Sets the charset of the postgreSQL database

Example

  • Original “Single Server” model
open Farmer
open Farmer.Builders
open Farmer.PostgreSQL

let myPostgres = postgreSQL {
    admin_username "adminallthethings"
    name "aserverformultitudes42"
    capacity 4<VCores>
    storage_size 50<Gb>
    add_database "my_db"
    enable_azure_firewall

    // overloaded or single-instance-specific keywords
    tier GeneralPurpose
    server_version Version.VS_11
    capacity 1<VCores>
}

let template = arm {
    location Location.NorthEurope
    add_resource myPostgres
    output "fqdn" myPostgres.FullyQualifiedDomainName
}
  • “Flexible Server” model
open Farmer
open Farmer.Builders
open Farmer.PostgreSQL

let myPostgres = postgreSQL {
    name "aserverformultitudes42"
    admin_username "adminallthethings"
    storage_size 64<Gb>
    add_database "my_db"
    enable_azure_firewall
    storage_autogrow true

    // overloaded or model-specific keywords
    tier FlexibleTier.Burstable_B1ms
    server_version FlexibleVersion.V_16
    storage_performance_tier Vm.DiskPerformanceTier.P10
}