- Hands on Lab: Provisioning, configuring, and getting started with development
In this lab you will create an Azure Database for PostgreSQL Flexible Server and then configure various properties using the Azure Portal. Once created and configured, you will then connect to it using pgAdmin to run some basic queries on pre-loaded data.
- Azure subscription
- Optional - Computer with Postgres 16 and pgAdmin
In this exercise you will create a new Azure Database for PostgreSQL Flexible Server using the Azure Portal.
-
Open the Azure Portal, if prompted, login using your lab credentials.
-
Select Create a resource (+) in the upper-left corner of the portal or select Create a resource under Azure services.
-
In the left side navigation, select Databases.
-
Under Azure Database for PostgreSQL Flexible Server, select Create.
-
Fill out the Basics tab with the following information, be sure to replace
PREFIX
with your lab information (ex1224900
) or a unique prefix such as your initials (exABC
), also replace theREGION
:- Resource Group: Name of your lab resource group (ex
postgres
) - Server name:
PREFIX-pg-flex-REGION-16
- Region:
REGION
- PostgreSQL Version:
16
- Workload Type:
Production (Small/Medium-size)
- Resource Group: Name of your lab resource group (ex
-
Under Compute + Storage, select Configure Server.
-
For the size, select
Standard_D2ds_v5
. -
Please DO NOT select the High Availability option as it is subject to availability and capacity limits in various regions.
-
Select Save.
-
Authentication method:
PostgreSQL authentication only
. -
Admin username:
s2admin
. -
Password and confirm password:
Seattle123Seattle123
. -
Select Next: Networking. On the Networking tab, you can choose how your server is reachable.
-
Configure Networking options:
-
Select Public access (allowed IP addresses)
-
Add your client IP address to ensure you can connect to your new instance
NOTE: You can find your IP Address by using a service such as What Is My IP Address
-
Additionally, select the Allow public access from any Azure service with Azure to the server
-
-
Select Review + create to review your selections.
-
Select Create to provision the server. This operation may take a few minutes.
-
In the top right of the toolbar, select the Notifications icon (a bell).
-
Select Deployment in progress link. You can now monitor the deployment process:
-
Once deployed, select the link to navigate to your server's Overview page.
- Make a note of the Server name and the Server admin login name.
- Hover your cursor over each field, and the copy symbol appears to the right of the text.
- Select the copy symbol as needed to copy the values for use later:
- Subscription ID
- Resource Group
- Resource name
- Server name
In this exercise you will use the Azure Portal to add a new database to your newly created Azure Database for PostgreSQL Flexible Server.
-
Browse to the new PREFIX-pg-flex-REGION-16 instance.
-
Under Settings, select Databases.
-
In the menu, select +Add.
-
For the name, type airbnb.
-
Select Save.
In this exercise you will modify the maintenance schedule of your Azure Database for PostgreSQL Flexible Server. By changing the schedule you can match the Azure update schedule to your own internal update schedule.
-
Browse to the PREFIX-pg-flex-REGION-16 instance.
-
Under Settings, select Maintenance.
-
Select Custom schedule.
-
For the Day of week, select Saturday.
-
For the Start time (UTC), select 23.
-
Select Save.
If you have a laptop or desktop that has pgAdmin and PostgreSQL installed, you can perform these steps on that device. If you do not have a local device capable of running pgAdmin or PostgreSQL, you can utilize the virtual machine that was deployed to your lab environment.
If you are using your own device, ensure the following has been completed:
-
Download and Install pgAdmin.
-
Download and Install PostgreSQL 16.
-
Switch back to the Azure Portal.
-
Browse to the
PREFIX-pg-flex-REGION-16
instance. -
Under Settings, select Networking.
-
Ensure that the Allow public access from any Azure service within Azure to this server checkbox in selected.
-
Under Firewall rules, add an entry for the IP address of your device.
NOTE: You can find your IP Address by using a service such as What Is My IP Address
-
Select Save.
-
Repeat for the
PREFIX-pg-flex-REGION-14
instance. Note that this instance was created by the lab ARM template for you.
If you are using the virtual machine from the lab environment, all the software has been installed for you. Login using the following:
-
Switch to the Azure Portal.
-
Browse to your resource group.
-
Select the PREFIX-vm-pgdb01 virtual machine.
-
In the tabs, select Connect->Connect.
-
Copy and save the IP address.
-
Select Download RDP file.
-
Open the RDP file with Remote Desktop.
-
Select Connect.
-
Login with
s2admin
and passwordSeattle123Seattle123
. -
When prompted, select Next, then Accept.
-
Switch back to the Azure Portal.
-
Browse to the
PREFIX-pg-flex-REGION-16
instance. -
Under Settings, select Networking.
-
Ensure that the Allow public access from any Azure service within Azure to this server checkbox in selected.
-
Under Firewall rules, add an entry using the IP address you copied above.
NOTE: You can find your IP Address by using a service such as What Is My IP Address
-
Select Save.
-
Repeat the networking steps for the
PREFIX-pg-flex-REGION-14
instance. Note that this instance was created by the lab ARM template for you.
-
From the lab virtual machine, open pgAdmin.
-
Right-click the Servers node, select Register->Server.
-
For name, type PREFIX-pg-flex-REGION-16, be sure to replace
PREFIX
with your lab information. -
Select the Connection tab.
-
For the host name/address, paste the server name you copied from above.
-
For the username, type s2admin.
-
For the password, type Seattle123Seattle123.
-
Select Save password? to toggle it on.
-
Select Save.
-
Again, repeat for the PREFIX-pg-flex-REGION-14 instance.
Using pgAdmin, you will execute some basic queries
-
Switch to pgAdmin.
-
Expand the PREFIX-pg-flex-REGION-14 node.
-
Expand the Databases node.
-
Expand the airbnb->Schemas->public nodes.
NOTE: If for some reason you do not see the airbnb table, use
psql
to run the script in the"c:\labfiles\microsoft-postgres-docs-project\artifacts\data\airbnb.sql"
-
Expand the Tables node.
-
Right-click the new
airbnb
table, select Query Tool. -
Copy the following into the query tool window and execute it:
select * from listings;
In this lab, you created a new Azure Database for PostgreSQL Flexible Server instance, configured some various aspects of it, added a database called airbnb
, configured a custom maintenance schedule then explored some data using on a secondary PG14 instance using pgAdmin.
In the next set of labs, you will explore several developer and performance features of PostgreSQL.
If you would like to run these labs in your own Azure subscription, you will need to execute the following steps using the provided ARM template:
- Switch to the Azure Portal.
- Select the + in the top left.
- Search for template, select the **Template deployment (deploy using custom templates).
- Select Create.
- Select Build your own template in the editor.
- Copy and paste the
/artifacts/environment-setup/automation/template.json
file into the window. - Select Save.
- Set the prefix parameter to match your lab environment or your initials (ex
ABC
). - Select Review + create.
- Select Create, the deployment will take a few minutes. Once deployed, you will have:
- A PostgreSQL 14 instance.
- Windows 11 Virtual Machine with necessary software installed.
- Various Azure supporting services