Explore Azure Database for PostgreSQL
In this exercise, you’ll create an Azure Database for PostgreSQL flexible server and configure the backup retention period.
Before you start
You need your own Azure subscription to complete this exercise. If you don’t have an Azure subscription, you can create an Azure free trial.
Create a Resource Group
- In a web browser, navigate to the Azure portal. Sign in using an Owner or Contributor account.
- Under Azure services, select Resource Groups, then select + Create.
- Check that the correct subscription is displayed, then enter the Resource group name as rg-PostgreSQL_Flexi. Select a Region.
- Select Review + create. Then select Create.
Create an Azure Database for PostgreSQL flexible server
- Under Azure services, select + Create a resource.
- In Search the Marketplace, type
azure database for postgresql flexible server
, choose Azure Database for PostgreSQL flexible server and click Create.
- In Search the Marketplace, type
- On the Flexible server Basics tab, enter each field as follows:
- Subscription - your subscription.
- Resource group - rg-PostgreSQL_Flexi.
- Server name - psql-postgresql-fx9999 (Server name must be globally unique, so replace 9999 with four random numbers).
- Region - select the same region as the resource group.
- PostgreSQL version - select 16.
- Workload type - Development.
- Compute + storage - Burstable, B1ms. Select Configure server and examine the configuration options. Don’t make any changes and close the blade in the right hand corner.
- Availability zone - No preference.
- High availability - Disabled.
- Authentication Method - PostgreSQL authentication only
- In admin username, enter
demo
. - In password, enter a suitably complex password.
- Select Next: Networking >.
- On the Flexible server Networking tab, enter each field as follows:
- Connectivity method: (o) Public access (allowed IP addresses) and Private endpoint
- Public access, select Allow public access to this resource through the internet using a public IP address
- Under Firewall rules, select + Add current client IP address, to add your current IP address as a firewall rule. You can optionally name this firewall rule to something meaningful.
- Select Review + create. Review your settings, then select Create to create your Azure Database for PostgreSQL Flexible server. When the deployment is complete, select Go to resource ready for the next step.
Examine server parameters
- Under Settings select Server parameters.
- In the Search to filter items … box, enter
connections
. Server parameters related to connections are displayed. Note the value for max_connections. Don’t make any changes. - From the left menu, select Overview to exit from Server parameters.
Change backup retention period
- Navigate to the Overview blade, under Settings, select Compute + storage. This section displays your current Compute tier, and the option to upgrade it. It also displays the amount of storage you’ve provisioned, and the option to increase storage.
- Under backups, the backup retention period in days is displayed. Using the slider bar, change the backup retention period to 14 days. Select Save to retain your changes.
- When you’ve completed this exercise, navigate to the Overview blade, and click STOP which will stop the server.
- You’ll not be charged while the server is in a stopped state, but be aware that within seven days the server will be restarted if you have not deleted it.
Optional exercise - configure a high availability server
- Under Azure services, select + Create a resource.
- In Search the Marketplace, type
azure database for postgresql flexible server
, choose Azure Database for PostgreSQL Flexible Server and click Create.
- In Search the Marketplace, type
- On the Flexible server Basics tab, enter each field as follows:
- Subscription - your subscription.
- Resource group - rg-PostgreSQL_Flexi.
- Server name - psql-postgresql-fx8888 (Server name must be globally unique, so replace 8888 with random numbers).
- Region - select the same region as the resource group.
- PostgreSQL version - select 16.
- Workload type - Production (Small / Medium)
- Compute + storage - leave as General purpose.
- Availability zone - You can leave this at “No preference” and Azure will automatically choose availability zones for your primary and secondary servers. Alternatively, specify an availability zone to co-locate with your application.
- Enable high availability - check this. Note the estimated costs when this option is selected.
- High availability mode - choose Zone redundant - a standby server is always available within another zone in the same region as the primary server
- Authentication Method - PostgreSQL authentication only
- In admin username, enter demo.
- In password, enter a suitably complex password.
- Select Next: Networking >.
- On the Flexible server Networking tab, enter each field as follows:
- Connectivity method: (o) Public access (allowed IP addresses) and Private endpoint
- Public access, select Allow public access to this resource through the internet using a public IP address
- Under Firewall rules, select + Add current client IP address, to add your current IP address as a firewall rule. You can optionally name this firewall rule to something meaningful.
- Select Review + create. Review your settings, then select Create to create your Azure Database for PostgreSQL flexible server. When the deployment is complete, select Go to resource ready for the next step.
Inspect the new server
- Under Settings, select High availability. High availability is enabled, and the primary availability zone should be zone 1.
- The standby availability zone has been automatically allocated and will be different to the primary availability zone and typically is zone 2.
Force a failover
- On the High availability blade, from the top menu select Forced Failover. A message is displayed, select OK.
- The failover process starts. A message is displayed when the failover operation has completed successfully.
- On the High availability blade, you can see that the primary zone is now 2, and the standby availability zone is 1. You may need to refresh your browser to see the latest information.
- When you’ve completed this exercise, delete the server.
Clean-up
The server for this lab exercise will incur charges. Delete the resource group rg-PostgreSQL_Flexi once you’ve completed the exercise. This will remove the server and any other resources that you have deployed in this lab exercise.