0
0
Azurecloud~5 mins

Why managed databases matter in Azure - Why It Works

Choose your learning style9 modes available
Introduction
Managing databases yourself can be hard and time-consuming. Managed databases handle the hard parts for you, so you can focus on your app instead of fixing database problems.
When you want to save time by not managing database servers and backups yourself
When you need your database to be available all the time without worrying about crashes
When you want automatic updates and security patches without manual work
When you want easy scaling of your database as your app grows
When you want built-in backups and disaster recovery without extra setup
Commands
This command creates a managed PostgreSQL database server in Azure. It sets up the server with admin credentials and a basic pricing tier.
Terminal
az postgres server create --resource-group example-group --name example-db-server --location eastus --admin-user adminuser --admin-password StrongP@ssw0rd! --sku-name B_Gen5_1 --version 13
Expected OutputExpected
{ "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/example-group/providers/Microsoft.DBforPostgreSQL/servers/example-db-server", "location": "eastus", "name": "example-db-server", "type": "Microsoft.DBforPostgreSQL/servers", "properties": { "administratorLogin": "adminuser", "version": "13", "sslEnforcement": "Enabled", "userVisibleState": "Ready" }, "sku": { "name": "B_Gen5_1", "tier": "Basic" } }
--resource-group - Specifies the Azure resource group to create the server in
--admin-user - Sets the administrator username for the database server
--sku-name - Chooses the pricing tier and performance level
This command checks the details and status of the managed PostgreSQL server to confirm it is ready.
Terminal
az postgres server show --resource-group example-group --name example-db-server
Expected OutputExpected
{ "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/example-group/providers/Microsoft.DBforPostgreSQL/servers/example-db-server", "location": "eastus", "name": "example-db-server", "type": "Microsoft.DBforPostgreSQL/servers", "properties": { "administratorLogin": "adminuser", "version": "13", "sslEnforcement": "Enabled", "userVisibleState": "Ready" }, "sku": { "name": "B_Gen5_1", "tier": "Basic" } }
This command creates a firewall rule to allow your computer's IP address to connect to the managed database server securely.
Terminal
az postgres server firewall-rule create --resource-group example-group --server-name example-db-server --name AllowMyIP --start-ip-address 203.0.113.5 --end-ip-address 203.0.113.5
Expected OutputExpected
{ "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/example-group/providers/Microsoft.DBforPostgreSQL/servers/example-db-server/firewallRules/AllowMyIP", "name": "AllowMyIP", "properties": { "startIpAddress": "203.0.113.5", "endIpAddress": "203.0.113.5" } }
--start-ip-address - Sets the start of the allowed IP range
--end-ip-address - Sets the end of the allowed IP range
This command creates a new database inside the managed PostgreSQL server for your application to use.
Terminal
az postgres db create --resource-group example-group --server-name example-db-server --name exampledb
Expected OutputExpected
No output (command runs silently)
Key Concept

Managed databases handle setup, maintenance, backups, and scaling so you can focus on building your app.

Common Mistakes
Not setting firewall rules to allow your IP to connect
Your computer cannot connect to the database server without permission, causing connection errors
Always create firewall rules that include your current IP address before connecting
Using weak or simple admin passwords
Weak passwords risk unauthorized access and data breaches
Use strong, complex passwords with letters, numbers, and symbols
Trying to manage database backups manually
Manual backups can be forgotten or done incorrectly, risking data loss
Use the managed database's automatic backup features
Summary
Create a managed database server with Azure CLI to avoid manual setup.
Check the server status to ensure it is ready before use.
Set firewall rules to allow your computer to connect securely.
Create databases inside the managed server for your app's data.