Azure Database for PostgreSQL is a relational database service based on the open source Postgres database engine. It is a fully managed database as a service offering capable of handling mission-critical workloads with predictable performance, security, high availability, and dynamic scalability. Develop applications with Azure Database for PostgreSQL leveraging the open source tools and platform of your choice.
- Create a server.
-
Check whether creating server succeeds or not.
-
Configure firewall rules
1. Collect credentials.
Do nothing
- Delete the server.
- Check whether deleting server succeeds or not.
- Get the service name and plans
cf marketplace
Sample output:
service plans description
azure-postgresqldb basic50*, basic100*, standard100*, standard200*, standard400*, standard800* Azure PostgreSQL Database Service
If you can not find the service name, please use the following command to make the plans public.
cf enable-service-access azure-postgresqldb
- Create a service instance
Configuration parameters are supported with the provision request. These parameters are passed in a valid JSON object containing configuration parameters, provided either in-line or in a file.
cf create-service azure-postgresqldb $service_plan $service_instance_name -c $path_to_parameters
Supported configuration parameters:
{
"resourceGroup": "<resource-group>", // [Required] Unique. Only allow up to 90 characters
"location": "<azure-region-name>", // [Required] support westus and northeurope only
"postgresqlServerName": "<server-name>", // [Required] Unique. Server name cannot be empty or null. It can contain only lowercase letters, numbers and '-', but can't start or end with '-' or have more than 63 characters.
"postgresqlServerParameters": {
"allowPostgresqlServerFirewallRules": [ // [Optional] If present, ruleName, startIpAddress and endIpAddress are mandatory in every rule.
{
"ruleName": "<rule-name-0>", // The rule name can only contain 0-9, a-z, A-Z, -, _, and cannot exceed 128 characters
"startIpAddress": "xx.xx.xx.xx",
"endIpAddress": "xx.xx.xx.xx"
},
{
"ruleName": "<rule-name-1>",
"startIpAddress": "xx.xx.xx.xx",
"endIpAddress": "xx.xx.xx.xx"
}
],
"properties": {
"version": "9.5" | "9.6",
"sslEnforcement": "Enabled" | "Disabled",
"storageMB": 51200 | 128000 | ... | 947200,
"administratorLogin": "<server-admin-name>",
"administratorLoginPassword": "<server-admin-password>"
}
}
}
For example:
cf create-service azure-postgresqldb basic100 postgresqldb -c examples/postgresqldb-example-config.json
The contents of examples/postgresqldb-example-config.json
:
{
"resourceGroup": "postgresqldbResourceGroup",
"location": "westus",
"postgresqlServerName": "postgresqlservera",
"postgresqlServerParameters": {
"allowPostgresqlServerFirewallRules": [
{
"ruleName": "newrule",
"startIpAddress": "0.0.0.0",
"endIpAddress": "255.255.255.255"
}
],
"properties": {
"version": "9.6",
"sslEnforcement": "Disabled",
"storageMB": 51200,
"administratorLogin": "myusername",
"administratorLoginPassword": "myPASSw0rd"
}
}
}
NOTE:
- Please remove the comments in the JSON file before you use it.
- Check the operation status of creating the service instance
The creating operation is asynchronous. You can get the operation status after the creating operation.
cf service $service_instance_name
For example:
cf service postgresqldb
cf bind-service $app_name $service_instance_name
For example:
cf bind-service demoapp postgresqldb
Verify that the credentials are set as environment variables
cf env $app_name
The credentials have the following format:
"credentials": {
"postgresqlServerName": "postgresqlservera",
"postgresqlServerFullyQualifiedDomainName": "postgresqlservera.postgres.database.azure.com",
"administratorLogin": "ulrich",
"administratorLoginPassword": "u1r8chP@ss",
"jdbcUrl": "jdbc:postgresql://postgresqlservera.postgres.database.azure.com:5432/{your_database}?user=ulrich@fake-server&password=u1r8chP@ss&ssl=true"
}
NOTE:
- The character "&" in JDBC url is encoded into "\u0026" by the Cloud Controller. Your app may need to handle this.
cf unbind-service $app_name $service_instance_name
For example:
cf unbind-service demoapp postgresqldb
cf delete-service $service_instance_name -f
For example:
cf delete-service postgresqldb -f