Azure Database for PostgreSQL

September 10, 2019 ยท View on GitHub

Note: PostgreSQL version 9.6 is STABLE, and PostgreSQL version 10 is in PREVIEW

Open Service Broker for Azure contains three types of Azure Database for PostgreSQL services. These services enable you to select the most appropriate provision scenario for your needs. These services are:

Service TypeDescription
azure-postgresql-*Provision both an Azure Database for PostgreSQL Database Management System (DBMS) and a database.
azure-postgresql-*-dbmsProvision only an Azure Database for PostgreSQL DBMS. This can be used to provision multiple databases at a later time.
azure-postgresql-*-databaseProvision a new database only upon a previously provisioned DBMS.

The azure-postgresql-* services allow you to provision both a DBMS and a database. When the provision operation is successful, the database will be ready to use. You can not provision additional databases onto an instance of azure-postgresql-*. The azure-postgresql-*-dbms and azure-postgresql-*-database services, on the other hand, can be combined to provision multiple databases on a single DBMS. Currently, OSBA supports two versions of Azure Database for PostgreSQL services:

Service Type Service name Stability
azure-postgresql-* azure-postgresql-9-6 Stable
azure-postgresql-10 Preview
azure-postgresql-*-dbms azure-postgresql-9-6-dbms Stable
azure-postgresql-10-dbms Preview
azure-postgresql-*-database azure-postgresql-9-6-database Stable
azure-postgresql-10-database Preview

For more information on each service, refer to the descriptions below.

This module involves the Parent-Child Model concept in OSBA, please refer to the Parent-Child Model doc.

Services & Plans

Service: azure-postgresql-*

Plan NameDescription
basicBasic Tier, Up to 2 vCores, Variable I/O performance
general-purposeGeneral Purporse Tier, Up to 32 vCores, Predictable I/O Performance, Local or Geo-Redundant Backups
memory-optimizedMemory Optimized Tier, Up to 16 memory optimized vCores, Predictable I/O Performance, Local or Geo-Redundant Backups

Behaviors

Provision

Provisions a new PostgreSQL DBMS and a new database upon that DBMS. The new database will be named randomly and will be owned by a role (group) of the same name.

Provisioning Parameters
Parameter NameTypeDescriptionRequiredDefault Value
locationstringThe Azure region in which to provision applicable resources.Y
resourceGroupstringThe (new or existing) resource group with which to associate new resources.Y
serverNamestringName of the PostgreSQL server.NA random generated string.
adminAccountSettingsobjectSettings of administrator account of PostgreSQL server. Typically you do not need to specify this.NDefault admin username is "postgres" and password is a randomly generated string.
adminAccountSettings.adminUsernamestringThe administrator username for the server.N"postgres"
adminAccountSettings.adminPasswordstringThe administrator password for the server. Warning: you may leak your password if you specify this property, others can see this password in your request body and ServiceInstance definition. DO NOT use this property unless you know what you are doing.NA random generated password.
sslEnforcementstringSpecifies whether the server requires the use of TLS when connecting. Valid valued are "" (unspecified), enabled, or disabled.N"". Left unspecified, SSL will be enforced.
firewallRulesarraySpecifies the firewall rules to apply to the server. Definition follows.N[] Left unspecified, Firewall will default to only Azure IPs. If rules are provided, they must have valid values.
firewallRules[n].namestringSpecifies the name of the generated firewall ruleY
firewallRules[n].startIPAddressstringSpecifies the start of the IP range allowed by this firewall ruleY
firewallRules[n].endIPAddressstringSpecifies the end of the IP range allowed by this firewall ruleY
virtualNetworkRulesarraySpecifies the firewall rules to apply to the server. Definition follows.N[] Left unspecified, Firewall will default to only Azure IPs. If rules are provided, they must have valid values.
virtualNetworkRules[n].namestringSpecifies the name of the generated virtual network ruleY
virtualNetworkRules[n].subnetIdstringThe full resource ID of a subnet in a virtual network to allow access from. Example format: /subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Network/virtualNetworks/{vn}/subnets/{sn}Y
tagsmap[string]stringTags to be applied to new resources, specified as key/value pairs.NTags (even if none are specified) are automatically supplemented with heritage: open-service-broker-azure.
extensionsstring[]Specifies a list of PostgreSQL extensions to installN

####### Provisioning Parameters: basic

Parameter NameTypeDescriptionRequiredDefault Value
coresintegerSpecifies vCores, which represent the logical CPU. Valid values are 1 or 2N1
storageintegerSpecifies the amount of storage to allocate in GB. Ranges from 5 to 1048N10
backupRetentionintegerSpecifies the number of days to retain backups. Ranges from 7 to 35N7

####### Provisioning Parameters: general-purpose

Parameter NameTypeDescriptionRequiredDefault Value
coresintegerSpecifies vCores, which represent the logical CPU. Valid values are 2, 4, 8, 16, or 32N2
storageintegerSpecifies the amount of storage to allocate in GB. Ranges from 5 to 1048N10
backupRetentionintegerSpecifies the number of days to retain backups. Ranges from 7 to 35N7
backupRedundancystringSpecifies the backup redundancy, either local or geoNlocal

####### Provisioning Parameters: memory-optimized

Parameter NameTypeDescriptionRequiredDefault Value
coresintegerSpecifies vCores, which represent the logical CPU. Valid values are 2, 4, 8, 16N2
storageintegerSpecifies the amount of storage to allocate in GB. Ranges from 5 to 1048N10
backupRetentionintegerSpecifies the number of days to retain backups. Ranges from 7 to 35N7
backupRedundancystringSpecifies the backup redundancy, either local or geoNlocal
Update

Updates a previously provisioned PostgreSQL DBMS. Currently updating the database extensions is not supported.

Updating Parameters
Parameter NameTypeDescriptionRequiredDefault Value
sslEnforcementstringSpecifies whether the server requires the use of TLS when connecting. Valid valued are "" (unspecified), enabled, or disabled.N"". Left unspecified, SSL will be enforced.
firewallRulesarraySpecifies the firewall rules to apply to the server. Definition follows.N[] Left unspecified, Firewall will default to only Azure IPs. If rules are provided, they must have valid values.
firewallRules[n].namestringSpecifies the name of the generated firewall ruleY
firewallRules[n].startIPAddressstringSpecifies the start of the IP range allowed by this firewall ruleY
firewallRules[n].endIPAddressstringSpecifies the end of the IP range allowed by this firewall ruleY

####### Updating Parameters: basic

Parameter NameTypeDescriptionRequiredDefault Value
coresintegerSpecifies vCores, which represent the logical CPU. Valid values are 1 or 2N1
storageintegerSpecifies the amount of storage to allocate in GB. Ranges from 5 to 1048. Note, this must not be lower than what was given at provision time.N10
backupRetentionintegerSpecifies the number of days to retain backups. Ranges from 7 to 35N7

####### Updating Parameters: general-purpose

Parameter NameTypeDescriptionRequiredDefault Value
coresintegerSpecifies vCores, which represent the logical CPU. Valid values are 2, 4, 8, 16, or 32N2
storageintegerSpecifies the amount of storage to allocate in GB. Ranges from 5 to 1048. Note, this must not be lower than what was given at provision time.N10
backupRetentionintegerSpecifies the number of days to retain backups. Ranges from 7 to 35N7

####### Updating Parameters: memory-optimized

Parameter NameTypeDescriptionRequiredDefault Value
coresintegerSpecifies vCores, which represent the logical CPU. Valid values are 2, 4, 8, or 16N2
storageintegerSpecifies the amount of storage to allocate in GB. Ranges from 5 to 1048. Note, this must not be lower than what was given at provision time.N10
backupRetentionintegerSpecifies the number of days to retain backups. Ranges from 7 to 35N7
Bind

Creates a new role (user) on the PostgreSQL DBMS. The new role will be named randomly and added to the role (group) that owns the database.

Binding Parameters

This binding operation does not support any parameters.

Credentials

Binding returns the following connection details and credentials:

Field NameTypeDescription
hoststringThe fully-qualified address of the PostgreSQL DBMS.
portintThe port number to connect to on the PostgreSQL DBMS.
databasestringThe name of the database.
usernamestringThe name of the database user (in the form username@host).
passwordstringThe password for the database user.
sslRequiredbooleanFlag indicating if SSL is required to connect the PostgreSQL DBMS.
uristringA URI string containing all necessary connection information.
jdbcUrlstringA fully formed JDBC url.
tagsstring[]A list of tags consumers can use to identify the credential.
Unbind

Drops the applicable role (user) from the PostgreSQL DBMS.

Deprovision

Deletes the PostgreSQL DBMS and database.

Examples
Kubernetes

The contrib/k8s/examples/postgresql/postgresql-instance.yaml can be used to provision the basic50 plan. This can be done with the following example:

kubectl create -f contrib/k8s/examples/postgresql/postgresql-instance.yaml

You can then create a binding with the following command:

kubectl create -f contrib/k8s/examples/postgresql/postgresql-binding.yaml
Cloud Foundry

Using the cf cli, you can provision the basic50 plan of this service with the following command:

cf create-service azure-postgresql basic50 postgresql-all-in-one -c '{
    "resourceGroup" : "demo",
    "location" : "eastus",
    "firewallRules" : [
        {
            "name": "AllowAll",
            "startIPAddress": "0.0.0.0",
            "endIPAddress" : "255.255.255.255"
        }
    ]
}
'
cURL

To provision an instance using the broker directly, you must use the ID for both plan and service. Assuming your OSBA is running locally on port 8080 with the default username and password, you can provision the basic50 plan with a cURL command similar to the following example:

curl -X PUT \
  'http://localhost:8080/v2/service_instances/postgresql-all-in-one?accepts_incomplete=true' \
  -H 'authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \
  -H 'content-type: application/json' \
  -H 'x-broker-api-version: 2.13' \
  -d '{
    "service_id" : "b43b4bba-5741-4d98-a10b-17dc5cee0175",
    "plan_id" : "b2ed210f-6a10-4593-a6c4-964e6b6fad62",
    "parameters" : {
        "resourceGroup": "demo",
        "location" : "eastus",
        "firewallRules" : [
            {
                "name": "AllowSome",
                "startIPAddress": "0.0.0.0",
                "endIPAddress" : "35.0.0.0"
            },
            {
                "name": "AllowMore",
                "startIPAddress": "35.0.0.1",
                "endIPAddress" : "255.255.255.255"
            }
        ]
    }
}'

Service: azure-postgresql-*-dbms

Plan NameDescription
basicBasic Tier, Up to 2 vCores, Variable I/O performance
general-purposeGeneral Purporse Tier, Up to 32 vCores, Predictable I/O Performance, Local or Geo-Redundant Backups
memory-optimizedMemory Optimized Tier, Up to 16 memory optimized vCores, Predictable I/O Performance, Local or Geo-Redundant Backups

Behaviors

Provision

Provisions an Azure Database for PostgreSQL DBMS instance containing no databases. Databases can be created through subsequent provision requests using the azure-postgresql-database service.

Provisioning Parameters
Parameter NameTypeDescriptionRequiredDefault Value
locationstringThe Azure region in which to provision applicable resources.Y
resourceGroupstringThe (new or existing) resource group with which to associate new resources.Y
serverNamestringName of the PostgreSQL server.NA random generated string.
adminAccountSettingsobjectSettings of administrator account of PostgreSQL server. Typically you do not need to specify this.NDefault admin username is "postgres" and password is a randomly generated string.
adminAccountSettings.adminUsernamestringThe administrator username for the server.N"postgres"
adminAccountSettings.adminPasswordstringThe administrator password for the server. Warning: you may leak your password if you specify this property, others can see this password in your request body and ServiceInstance definition. DO NOT use this property unless you know what you are doing.NA random generated password.
aliasstringSpecifies an alias that can be used by later provision actions to create databases on this DBMS.Y
sslEnforcementstringSpecifies whether the server requires the use of TLS when connecting. Valid valued are "" (unspecified), enabled, or disabled.N"". Left unspecified, SSL will be enforced.
firewallRulesarraySpecifies the firewall rules to apply to the server. Definition follows.N[] Left unspecified, Firewall will default to only Azure IPs. If rules are provided, they must have valid values.
firewallRules[n].namestringSpecifies the name of the generated firewall ruleY
firewallRules[n].startIPAddressstringSpecifies the start of the IP range allowed by this firewall ruleY
firewallRules[n].endIPAddressstringSpecifies the end of the IP range allowed by this firewall ruleY
tagsmap[string]stringTags to be applied to new resources, specified as key/value pairs.NTags (even if none are specified) are automatically supplemented with heritage: open-service-broker-azure.

####### Provisioning Parameters: basic

Parameter NameTypeDescriptionRequiredDefault Value
coresintegerSpecifies vCores, which represent the logical CPU. Valid values are 1 or 2N1
storageintegerSpecifies the amount of storage to allocate in GB. Ranges from 5 to 1048N10
backupRetentionintegerSpecifies the number of days to retain backups. Ranges from 7 to 35N7

####### Provisioning Parameters: general-purpose

Parameter NameTypeDescriptionRequiredDefault Value
coresintegerSpecifies vCores, which represent the logical CPU. Valid values are 2, 4, 8, 16, or 32N2
storageintegerSpecifies the amount of storage to allocate in GB. Ranges from 5 to 1048N10
backupRetentionintegerSpecifies the number of days to retain backups. Ranges from 7 to 35N7
backupRedundancystringSpecifies the backup redundancy, either local or geoNlocal

####### Provisioning Parameters: memory-optimized

Parameter NameTypeDescriptionRequiredDefault Value
coresintegerSpecifies vCores, which represent the logical CPU. Valid values are 2, 4, 8, or 16N2
storageintegerSpecifies the amount of storage to allocate in GB. Ranges from 5 to 1048N10
backupRetentionintegerSpecifies the number of days to retain backups. Ranges from 7 to 35N7
backupRedundancystringSpecifies the backup redundancy, either local or geoNlocal
Update

Updates a previously provisioned PostgreSQL DBMS.

Updating Parameters
Parameter NameTypeDescriptionRequiredDefault Value
sslEnforcementstringSpecifies whether the server requires the use of TLS when connecting. Valid valued are "" (unspecified), enabled, or disabled.N"". Left unspecified, SSL will be enforced.
firewallRulesarraySpecifies the firewall rules to apply to the server. Definition follows.N[] Left unspecified, Firewall will default to only Azure IPs. If rules are provided, they must have valid values.
firewallRules[n].namestringSpecifies the name of the generated firewall ruleY
firewallRules[n].startIPAddressstringSpecifies the start of the IP range allowed by this firewall ruleY
firewallRules[n].endIPAddressstringSpecifies the end of the IP range allowed by this firewall ruleY

####### Updating Parameters: basic

Parameter NameTypeDescriptionRequiredDefault Value
coresintegerSpecifies vCores, which represent the logical CPU. Valid values are 1 or 2N1
storageintegerSpecifies the amount of storage to allocate in GB. Ranges from 5 to 1048. Note, this must not be lower than what was given at provision time.N10
backupRetentionintegerSpecifies the number of days to retain backups. Ranges from 7 to 35N7

####### Updating Parameters: general-purpose

Parameter NameTypeDescriptionRequiredDefault Value
coresintegerSpecifies vCores, which represent the logical CPU. Valid values are 2, 4, 8, 16, or 32N2
storageintegerSpecifies the amount of storage to allocate in GB. Ranges from 5 to 1048. Note, this must not be lower than what was given at provision time.N10
backupRetentionintegerSpecifies the number of days to retain backups. Ranges from 7 to 35N7

####### Updating Parameters: memory-optimized

Parameter NameTypeDescriptionRequiredDefault Value
coresintegerSpecifies vCores, which represent the logical CPU. Valid values are 2, 4, 8, or 16N2
storageintegerSpecifies the amount of storage to allocate in GB. Ranges from 5 to 1048. Note, this must not be lower than what was given at provision time.N10
backupRetentionintegerSpecifies the number of days to retain backups. Ranges from 7 to 35N7
Bind

This service is not bindable.

Unbind

This service is not bindable.

Deprovision

Deletes the PostgreSQL DBMS only. If databases have been provisioned on this DBMS, deprovisioning will be deferred until all databases have been deprovisioned.

Examples
Kubernetes

The contrib/k8s/examples/postgresql/advanced/postgresql-dbms-instance.yaml can be used to provision the basic50 plan. This can be done with the following example:

kubectl create -f contrib/k8s/examples/postgresql/advanced/postgresql-dbms-instance.yaml
Cloud Foundry

Using the cf cli, you can provision the basic50 plan of this service with the following command:

cf create-service azure-postgresql-dbms basic50 postgresql-dbms -c '{
    "resourceGroup" : "demo",
    "location" : "eastus",
    "alias" : "3f368072-6fa8-42ad-ae9c-c02e59b7dc8d",
    "firewallRules" : [
        {
            "name": "AllowAll",
            "startIPAddress": "0.0.0.0",
            "endIPAddress" : "255.255.255.255"
        }
    ]
}
'
cURL

To provision an instance using the broker directly, you must use the ID for both plan and service. Assuming your OSBA is running locally on port 8080 with the default username and password, you can provision the basic50 plan with a cURL command similar to the following example:

curl -X PUT \
  'http://localhost:8080/v2/service_instances/postgreqsl-dbms?accepts_incomplete=true' \
  -H 'authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \
  -H 'content-type: application/json' \
  -H 'x-broker-api-version: 2.13' \
  -d '{
    "service_id" : "d3f74b44-79bc-4d1e-bf7d-c247c2b851f9",
    "plan_id" : "bf389028-8dcc-433a-ab6f-0ee9b8db142f",
    "parameters" : {
        "resourceGroup": "demo",
        "location" : "eastus",
        "alias" : "d94f7740-74d8-446a-bbfd-c616935b4d58",
        "firewallRules" : [
            {
                "name": "AllowAll",
                "startIPAddress": "0.0.0.0",
                "endIPAddress" : "255.255.255.255"
            }
        ]
    }
}'

Service: azure-postgresql-*-database

Plan NameDescription
databaseNew database on existing DBMS

Behaviors

Provision

Provisions a new database upon an existing PostgreSQL DBMS. The new database will be named randomly and will be owned by a role (group) of the same name.

Provisioning Parameters
Parameter NameTypeDescriptionRequiredDefault Value
extensionsstring[]Specifies a list of PostgreSQL extensions to installN
parentAliasstringSpecifies the alias of the DBMS upon which the database should be provisioned.Y

Note: You should use corresponding dbms service instance as the parent of database service instance. For example, you should use azure-postgresql-10-dbms as the parent of azure-postgresql-10-database.

Update

Not currently supported.

Bind

Creates a new role (user) on the PostgreSQL DBNS. The new role will be named randomly and added to the role (group) that owns the database.

Binding Parameters

This binding operation does not support any parameters.

Credentials

Binding returns the following connection details and credentials:

Field NameTypeDescription
hoststringThe fully-qualified address of the PostgreSQL DBMS.
portintThe port number to connect to on the PostgreSQL DBMS.
databasestringThe name of the database.
usernamestringThe name of the database user (in the form username@host).
passwordstringThe password for the database user.
sslRequiredbooleanFlag indicating if SSL is required to connect the PostgreSQL DBMS.
uristringA URI string containing all necessary connection information.
jdbcUrlstringA fully formed JDBC url.
tagsstring[]A list of tags consumers can use to identify the credential.
Unbind

Drops the applicable role (user) from the PostgreSQL DBMS.

Deprovision

Deletes the PostgreSQL database only, the DBMS remains provisioned.

Examples
Kubernetes

The contrib/k8s/examples/postgresql/postgresql-database-instance.yaml can be used to provision the database plan. This can be done with the following example:

kubectl create -f contrib/k8s/examples/postgresql/advanced/postgresql-database-instance.yaml

You can then create a binding with the following command:

kubectl create -f contrib/k8s/examples/postgresql/advanced/postgresql-database-binding.yaml
Cloud Foundry

Using the cf cli, you can provision the database plan of this service with the following command:

cf create-service azure-postgresql-database database postgresql-database -c '{
    "parentAlias" : "ed9798f2-2e91-4b21-8903-d364a3ff7d12"
}'
cURL

To provision an instance using the broker directly, you must use the ID for both plan and service. Assuming your OSBA is running locally on port 8080 with the default username and password, you can provision the database plan with a cURL command similar to the following example:

curl -X PUT \
  'http://localhost:8080/v2/service_instances/postgresql-db?accepts_incomplete=true' \
  -H 'authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \
  -H 'content-type: application/json' \
  -H 'x-broker-api-version: 2.13' \
  -d '{
    "service_id" : "25434f16-d762-41c7-bbdd-8045d7f74ca6",
    "plan_id" : "df6f5ef1-e602-406b-ba73-09c107d1e31b",
    "parameters" : {
        "parentAlias" : "d94f7740-74d8-446a-bbfd-c616935b4d58"
    }
}'