Azure Database for MySQL and PostgreSQL: Open-Source Databases, Fully Managed
A beginner-friendly guide to running the world's favourite open-source relational databases on Azure, without carrying the daily burden of servers, patches, backups and failures.
Imagine you own a busy restaurant. You love cooking, and you love your customers, but every evening you also have to repair the oven, order gas, wash the floors and check the fire alarms. One night the oven breaks in the middle of dinner service and everything stops. Now imagine hiring a facilities company that keeps the kitchen running, repairs equipment before it fails and has a spare oven ready. You still decide the menu, but the building looks after itself. A managed database service works the same way for your data.
In this guide we begin with the simple question “what is a database?” and slowly arrive at high availability, security, cost and migration. No earlier knowledge is assumed. Every new word is explained the first time it appears, usually with an everyday comparison.
1What Is Azure Database for MySQL and PostgreSQL?
These are two Azure services that run MySQL and PostgreSQL for you as managed cloud databases.
A database is an organised place to keep information so that programs can store it, find it and change it quickly and safely. A relational database keeps its information in tables, much like spreadsheets. Each table has columns that describe the kind of information and rows that hold the actual records. Tables can be linked to one another, which is why they are called relational.
MySQL and PostgreSQL are two very popular open-source relational databases. Open source means that anyone may read, use and improve the software without paying a licence fee. Thousands of websites, mobile apps, shops and business systems around the world are built on one of these two. Because developers already know them, companies often want to keep using them when they move to the cloud.
Azure Database for MySQL and Azure Database for PostgreSQL are Microsoft’s managed versions. “Managed” means Microsoft handles the machines, the operating system, the database installation, patching, backups, failure recovery and many monitoring tasks. You decide the size of the server, create databases and tables, connect your applications and manage who may do what. The product you will use today is called Flexible Server for both databases.
Owning your own database server is like owning a car: you pay for fuel, servicing, insurance and repairs, and you are stranded if it breaks down. A managed database is like a car subscription with a service team. You still choose where to drive, but the maintenance is part of the deal.
Words you will meet again and again
Flexible Server
The current deployment model for both services. It gives you control over compute size, high availability, maintenance times and networking.
Compute Tier
The family of processors and memory you pick: Burstable, General Purpose or Memory Optimized.
High Availability
A standby copy of the server that takes over automatically if the main one fails.
Read Replica
An extra copy of the database used only for reading, which takes load off the main server.
Point-in-Time Restore
The ability to rewind the database to a chosen moment within the backup period.
Private Access
A way of connecting where the database has an address inside your own virtual network instead of the public internet.
The older “Single Server” deployment option for both databases has been retired by Microsoft. If you read old articles about it, treat them as history and focus on Flexible Server. Similarly, the old “Hyperscale (Citus)” option for PostgreSQL now lives on as Azure Cosmos DB for PostgreSQL, which is a separate service.
2Why Use a Managed Database?
To appreciate a managed service, look at the chores it removes from your plate.
When a team installs a database on its own virtual machine, a long list of jobs follows. Someone must pick the machine size, install the operating system and database software, apply security patches, schedule backups and test that those backups can really be restored. Someone must watch the disk so it does not fill up and build a second server in case the first one dies. These jobs never end, and a mistake in any of them can cause data loss.
Many companies do not have a full-time database administrator. Even those that do prefer their experts to spend time on designing good tables and fast queries rather than replacing disks and installing patches. A managed service lets a small team run a serious, reliable database.
Advantages
- Automatic backups with point-in-time restore
- Built-in high availability with automatic failover
- Security patches and minor updates handled by the platform
- Grow or shrink compute with a short restart
- Familiar MySQL or PostgreSQL tools and drivers keep working
- Monitoring and alerts included
Disadvantages / Trade-offs
- No access to the underlying operating system
- Some settings and extensions are restricted or unavailable
- You pay for convenience, so costs can exceed a self-built server
- Maintenance happens on Microsoft’s schedule within the window you choose
- Very unusual custom setups may not fit
Cooking at home gives you total freedom to use any pot, any stove and any recipe, but you also shop, clean and wash up. A hotel kitchen gives you a ready service with some house rules. A managed database is the hotel kitchen.
“Managed” does not mean “nothing for me to do”. Microsoft looks after the platform, but you still design the tables, write efficient queries, manage users and permissions, and decide how long to keep backups. The responsibility is shared.
3MySQL or PostgreSQL: Which One Fits?
Both are excellent, and the right choice usually depends on your application and your team.
MySQL became famous as the database behind many websites and content systems. It is known for being simple to set up, fast for straightforward reading and writing, and widely supported by hosting tools. PostgreSQL, often called “Postgres”, is known for its rich feature set, strict standards, advanced data types and a huge ecosystem of extensions that add new abilities.
| Question | MySQL | PostgreSQL |
|---|---|---|
| Reputation | Simple, fast, very common for web applications | Feature-rich, standards-focused, favoured for complex data work |
| Extra abilities | Fewer add-ons, focused core | Many extensions, such as maps, vector search and scheduled jobs |
| Special data types | Good support for common types and JSON | Very wide choice, including arrays, ranges and geometry |
| Typical users | Websites, online shops, content platforms | Analytics-heavy apps, mapping, financial and scientific systems |
| Built-in connection pooling | Not built in; external tools are common | Optional built-in pooler on Flexible Server |
| Read replicas | Up to ten | Up to five |
Choose MySQL when
Your application framework, such as a popular blogging or shop platform, already expects MySQL, or your team has years of MySQL experience and wants a smooth, familiar move to Azure.
Choose PostgreSQL when
You need advanced data types, geographic data, strict data rules, powerful extensions or vector search for artificial intelligence features, or you are building something new and want a flexible long-term foundation.
Do not switch databases just because of fashion. If an existing application runs well on one engine, stay with it. For a brand-new project with no preference, PostgreSQL is a common default because of its flexibility.
4Creating a Server: Compute Tiers and Sizes
The first big decision is how much brainpower and memory your database server needs.
The compute of a database server is made of virtual cores, often called vCores, and memory. Cores do the thinking, and memory acts like the desk space where the database keeps its most-used data close at hand. A database with a lot of memory can answer many questions without going to the slower disk.
Burstable
Low-cost servers for development, testing and small apps. They run at a modest baseline and can burst higher for short periods using saved-up credits.
General Purpose
The balanced choice for most production workloads, with a healthy ratio of memory to cores.
Memory Optimized
More memory per core, designed for busy databases with large working sets, analytics queries or heavy caching needs.
Burstable is like a small scooter that can sprint briefly but tires on long hills. General Purpose is a family car that handles daily life comfortably. Memory Optimized is a delivery van with a huge cargo space, made for carrying a lot of goods at once.
Choices made at creation time
Choose the region
Pick a region close to your application. Distance adds delay to every query, and some rules require data to stay in particular countries.
Choose the engine version
Select a supported major version. Newer versions bring improvements and longer support, while older ones eventually reach end of life.
Choose compute and storage
Pick a tier and size, then the amount of storage. Both can be changed later, although changing compute causes a brief restart.
Choose availability and networking
Decide on a standby server and whether access is public with firewall rules or private inside a virtual network. The networking choice is difficult to switch later.
Choose how people sign in
Use the traditional database administrator login, Microsoft Entra ID, or both together.
Running production on a Burstable server because it looked cheap. When the saved credits run out, performance drops to the baseline and users notice slow pages. Reserve Burstable for light or non-critical work.
5Storage, IOPS and Growth
A database is only as fast as the disk behind it, so storage deserves its own thought.
Data, indexes and logs of the database live on storage that Azure attaches to the server. You choose the size in gigabytes or terabytes. Storage can be increased later but, in general, it cannot be reduced, so start with a sensible amount and grow when needed. Many servers also offer an option called storage auto-grow, which automatically adds space before the disk fills up, helping to avoid a sudden outage.
IOPS means input and output operations per second, which is the number of small reads and writes the disk can handle each second. A busy shop database that serves thousands of orders needs many IOPS. Each server size and storage size comes with an included amount of IOPS, and some configurations allow you to pay for more when your workload needs it.
Storage size is the number of shelves in a library. IOPS is how many librarians are available to fetch books at the same time. A huge library with only one librarian still feels slow when many visitors arrive together.
If your database is slow and the processor is mostly idle, the disk may be the bottleneck. Check the storage and IOPS metrics before buying a bigger processor, because more cores will not fix a disk that cannot keep up.
A database whose storage becomes completely full can switch to a read-only state to protect itself, and writes then fail. Set alerts at around eighty percent usage and keep auto-grow enabled where available.
6Inside the Machine: Architecture and Components
Behind a single connection address, several parts work together to keep your database running.
When you create a Flexible Server, Azure starts a virtual machine that runs the MySQL or PostgreSQL engine inside a managed container environment. Your data lives on remote storage that is separate from the machine itself. Because the storage is kept apart from the compute, Azure can replace a broken machine and attach the same storage to a fresh one without losing your data.
The gateway and endpoint
Your application connects to the server’s name. Networking rules check whether the connection is allowed before it reaches the database engine.
The database engine
The MySQL or PostgreSQL software that parses queries, plans the fastest route to the answer, applies changes and keeps data consistent.
Data storage
Disks that hold tables and indexes. Azure keeps multiple copies of this storage, so a disk problem does not lose your data.
Transaction logs
A diary of every change made. The log is the secret behind crash recovery, replicas and point-in-time restore.
Backup storage
Automatic backups and log archives are kept in separate, durable storage so they survive even if the server itself is lost.
flowchart TD
A["Application"] --> B["Server Name and Firewall or Private Network"]
B --> C["Database Engine: MySQL or PostgreSQL"]
C --> D["Data and Index Storage"]
C --> E["Transaction Log"]
D --> F["Automatic Backups"]
E --> F
C --> G["Monitoring and Metrics"]
Think of a bank branch. The front door guard checks who may enter, the teller handles your request, the vault stores the money, and a ledger records every transaction. If the teller falls ill, another teller can sit at the same desk using the same vault and ledger.
Transactions and the promise of safety
Both engines follow a set of rules called ACID, which stands for atomicity, consistency, isolation and durability. In simple words, a group of changes either happens completely or not at all, the data always follows its rules, simultaneous users do not corrupt each other’s work, and once a change is confirmed it is not lost. Transferring money between two accounts is the classic example: the money must leave one account and arrive in the other, never just one of the two.
7High Availability: Surviving Failure
Machines fail, so a good design plans for it before it happens.
Availability is the share of time your database is ready to answer. A server with high availability enabled has a hidden twin, called a standby, that continuously receives every change made on the main server, which is called the primary. If the primary fails, Azure switches to the standby automatically, and applications reconnect to the same server name after a short pause.
Zone-Redundant HA
The standby sits in a different availability zone, which is an independent building with its own power and cooling in the same region. This survives the loss of an entire zone.
Same-Zone HA
The standby sits in the same zone as the primary. It protects against server and machine failures but not against a whole-zone problem. It is available where zones are not.
flowchart LR
APP["Application"] --> EP["Same Server Name"]
EP --> PRI["Primary Server in Zone 1"]
PRI -- "continuous copy of changes" --> STB["Standby Server in Zone 2"]
PRI --> ST1["Storage Copy"]
STB --> ST2["Storage Copy"]
What happens during a failover
Failure detected
The platform notices that the primary is unhealthy or unreachable.
Standby promoted
The standby finishes applying the changes it has received and becomes the new primary.
Address redirected
The server name now points to the new primary. Applications reconnect, usually within a minute or two.
New standby built
Azure creates a fresh standby in the background to restore full protection.
Applications must expect short connection drops during failover and maintenance. Use retry logic, so a brief interruption becomes a slight delay instead of an error shown to customers.
A standby effectively doubles the compute cost, since you pay for the second server. Use it for production systems where downtime is expensive, and skip it for development and testing.
8Backups and Point-in-Time Restore
High availability protects against failures, but only backups protect against mistakes.
Suppose a developer runs a command that deletes the wrong table. The standby faithfully copies that deletion, so the standby is no help. Backups are what let you go back to the moment before the mistake.
Flexible Server takes care of backups automatically. It takes regular snapshots of the data and continuously saves the transaction log. Combining the nearest snapshot with the log lets you restore the database to any chosen second within the retention period. The retention period is seven days by default and can be extended, up to a maximum of thirty-five days.
Imagine a video recording of your document being edited. Occasional full photographs of the document are the snapshots, and the recording of every keystroke is the transaction log. To see the document as it was at 3:15 pm, start from the nearest photograph and replay the keystrokes until 3:15.
Pick the time
Choose the exact moment you want to return to, just before the mistake happened.
Restore to a new server
Azure builds a brand-new server from the backup and replays the log up to your chosen time. The original server is not touched.
Check the data
Verify that the missing or damaged information is back and correct.
Switch or copy
Either point applications at the restored server or copy the recovered data back into the original.
Where backups are stored
By default, backups are kept in locally redundant or zone-redundant storage, depending on your setup. You can also choose geo-redundant backup, which keeps a copy in a paired region far away. This allows a geo-restore, in which you build a server in another region after a regional disaster. The geo option must be selected when the server is created.
A backup you have never restored is only a hope. Run a test restore every few months and record how long it takes, so you know your real recovery time before an emergency.
When you delete a server, its automatic backups are removed with it. For data that must be kept for years, also export logical backups to separate storage on a schedule you control.
9Scaling: Bigger Servers and Read Replicas
When more users arrive, you can scale up, scale out for reading, or both.
Scaling up, also called vertical scaling, means moving to a server with more cores and memory. In Flexible Server this is a simple change of size. The server restarts briefly while it moves to the new size, so it is best done during a quiet period. Scaling up is the easiest path, and it often solves problems for a long time.
Scaling out for reads uses read replicas. A read replica is an extra server that continuously receives changes from the main server and keeps its own copy of the data. Applications send their read-only questions, such as showing a product list or building a report, to the replicas, while all changes still go to the main server. This is a very effective way of protecting the primary from heavy reporting queries.
flowchart LR
W["Application Writes"] --> P["Primary Server"]
R1["Application Reads"] --> RR1["Read Replica 1"]
R2["Reports and Dashboards"] --> RR2["Read Replica 2"]
P -- "asynchronous copy" --> RR1
P -- "asynchronous copy" --> RR2
Replication lag
Replicas copy changes asynchronously, which means they trail the primary by a small amount of time. A user who just saved an order and immediately views it on a replica might not see it yet. Design screens that need the freshest data to read from the primary.
Replicas in other regions
Replicas can be placed in other regions to bring reads closer to far-away users and to serve as a starting point for disaster recovery, since a replica can be promoted into an independent server.
How many replicas
MySQL Flexible Server supports up to ten replicas and PostgreSQL Flexible Server supports up to five. Each replica is a full server and is billed as such.
Every connection to a database uses memory. Applications that open thousands of short connections can exhaust a server. PostgreSQL Flexible Server offers an optional built-in connection pooler, and MySQL applications commonly use pooling in the application or a proxy in front of the database.
Adding replicas when the real problem is a slow query. A single badly written query that scans a huge table will be slow on every server. Fix the query and the indexes first, then scale.
10Networking: Who Can Reach the Database?
A database should be visible only to the applications that truly need it.
Flexible Server offers two main ways of connecting, and you choose one when you create the server. Understanding the difference early saves a lot of rework, because changing it later can mean building a new server.
Public Access with Firewall Rules
The server has a public address, but only the internet addresses and Azure services you list in the firewall may connect. Simple, but it exposes an address to the internet.
Private Access
The server is placed into a dedicated subnet of your own virtual network, or reached through a private endpoint where supported. It has no public address and is reachable only from inside connected networks.
Public access with firewall rules is a shop on a main street with a doorman and a guest list. Private access is an office on the inside floors of a gated campus: strangers cannot even find the door.
| Question | Public with Firewall | Private Access |
|---|---|---|
| Exposure to the internet | Public address exists | No public address |
| Setup effort | Low | Higher, needs network planning |
| Typical use | Development, simple apps, quick tests | Production, sensitive and regulated data |
| Reaching from your laptop | Add your address to the firewall | Needs VPN, a bastion or a jump machine |
Encrypted connections
Whatever path you use, connections can be protected with TLS, which scrambles the traffic so that nobody listening on the network can read it. Servers support modern versions of TLS, and you can require encrypted connections so that clients without encryption are rejected.
A firewall rule that opens the entire internet range is the same as having no firewall. Never leave a rule like that in place, even “just for a minute” during testing, because automated scanners constantly search for open database ports.
11Security: Layers of Protection
Strong security comes from several small walls, not one big wall.
Network layer
Private access or tight firewall rules decide who can even attempt a connection.
Identity layer
Users and applications must prove who they are, using database passwords or, better, Microsoft Entra ID.
Permission layer
Inside the database, roles and grants decide which tables each person may read or change.
Data layer
Encryption protects the data stored on disks, in backups and in transit.
Audit layer
Logs and alerts record who did what and warn about strange behaviour.
Signing in
Every server has an administrator account created with a password at set-up time. Many teams also enable Microsoft Entra authentication. With Entra, people sign in with their normal work identity, and applications running in Azure can use a managed identity, which is an identity given by Azure that needs no stored password. This removes secrets from configuration files and makes it easy to remove access when someone leaves.
Encryption
Data at rest, including backups, is encrypted with strong AES 256-bit encryption by default using keys managed by Microsoft. If your rules require control over keys, you can use customer-managed keys stored in Azure Key Vault. Data in transit is protected by TLS.
A hospital protects patient records with a gate guard, a staff badge, department-specific door cards, locked filing cabinets and a camera log. Removing any one layer weakens the whole building, but all of them together make theft very hard.
Letting every application connect as the administrator. A bug or leak then gives an attacker total control. Create separate low-privilege users for each application, granting only the actions that application needs.
Microsoft Defender for Cloud can look for suspicious sign-in attempts and unusual activity on supported database servers, and audit logging can record connections and statements for compliance.
12Monitoring, Logging and Performance Tuning
A healthy database is one you keep an eye on before users start complaining.
Azure Monitor collects numbers from your server automatically. These metrics show how busy the processor is, how much memory and storage are used, how many connections are open, how many reads and writes the disk performs and whether replicas are keeping up. You can draw charts of them and create alerts that send a message when a number crosses a limit.
CPU Percentage
Constantly high values mean the server is working hard and may need more cores or better queries.
Memory Percentage
Shows whether the working data fits in memory. Constant pressure leads to more disk reads and slower answers.
Storage Used
Tracks growth so that you can act before the disk fills.
Active Connections
A sudden jump may reveal an application leaking connections or an attack.
IOPS and Latency
Show how hard the disk is working and how long each request waits.
Replication Lag
Tells you how far behind replicas are from the primary.
Finding slow queries
Most performance problems come from a small number of slow queries. Both services can record statements that take longer than a chosen time into a slow query log. PostgreSQL also offers Query Store and a tool to show the statements that use the most time, and both can send their logs to Log Analytics, where they can be searched and charted. Look for queries that run very often, run very long or read far more rows than they return.
Finding a name in a phone book is quick because the book is sorted alphabetically. An index in a database is exactly such a sorted list. Without it, the database must read every entry, like checking each page of the phone book from the start.
Add the right indexes
Indexes speed up searching but slow down writing slightly and use storage. Add them for columns that appear often in filters and joins, and remove those nobody uses.
Keep statistics and housekeeping healthy
Both engines need regular housekeeping so that the planner has accurate information and old data does not bloat tables. PostgreSQL uses a background process called autovacuum for this, and it should be monitored and tuned rather than turned off.
Review the plan
Ask the database to explain how it will run a query. The explanation shows whether it uses an index or reads the whole table, which is the quickest clue to a fix.
13Maintenance, Versions and Extensions
Keeping software fresh and secure is a steady job, and the platform helps with it.
Azure regularly applies updates to the operating system, the database engine’s minor versions and the platform itself. You can pick a custom maintenance window, such as early Sunday morning, so that the short restart that sometimes goes with an update happens when few people are using your application. Some updates are urgent security fixes and may be applied outside the usual cycle.
Major and minor versions
A minor version contains fixes and small improvements and is applied by the platform. A major version, for example moving from one big release number to the next, brings larger changes and is done by you when you decide. Each major version has an end-of-life date after which it no longer receives fixes, so plan upgrades well ahead. Flexible Server supports in-place major version upgrades for PostgreSQL and MySQL in many cases, and you should always test an upgrade on a restored copy first.
Read the release notes
Learn what changes in the new version and which features are removed or behave differently.
Test on a copy
Restore a recent backup to a new server and run the upgrade there, then run your application tests against it.
Schedule the real upgrade
Pick a quiet time, tell users, and take a fresh backup before you begin.
Verify and watch
Check that the application works and keep a close eye on performance for several days.
Extensions in PostgreSQL
One of the great strengths of PostgreSQL is extensions, which add new abilities to the database. Azure allows a curated list of supported extensions that you switch on yourself. Examples include maps and geographic queries, text search helpers, scheduling of recurring jobs, and vector storage for artificial intelligence similarity search. Since the platform controls the server, only approved extensions are available, so check the supported list before designing around one.
Many database settings, such as memory sizes and timeouts, can be changed through server parameters in the portal. Some are applied immediately and some need a restart. Change one thing at a time and measure the effect.
14Understanding and Controlling Cost
The bill for a database is built from a few clear pieces, and each one can be managed.
Compute
Charged for every hour the server is running, based on tier and size. Usually the largest part of the bill.
Storage
Charged for the provisioned amount, whether or not you fill it.
Backup Storage
A portion equal to your provisioned storage is typically included; extra backup space is billed.
Extras
A standby server, replicas, additional IOPS and data leaving Azure each add to the total.
Right-size regularly
Check CPU and memory graphs monthly. A server that never goes above twenty percent usage is probably too large and can be reduced.
Stop servers you do not need at night
Development and test servers can be stopped to save compute charges. A stopped server restarts automatically after a limited number of days, so schedule a recurring stop if you want it to stay off.
Commit for a discount
If you know a production server will run for at least a year, reserved capacity lowers the hourly price compared with pay-as-you-go.
Keep copies lean
Every replica and every restored test server is billed like any other server. Delete temporary servers once the work is done.
Forgotten restore tests and abandoned proof-of-concept servers quietly consume money month after month. Tag every server with an owner and a purpose, and review the list regularly.
15Migrating to Azure
Most teams do not start from nothing, so moving an existing database safely is a key skill.
Migration means moving a database from where it lives now, such as a server in your office, another cloud or a virtual machine, into Azure. The two main concerns are keeping every record correct and keeping the downtime short. The right approach depends on the size of the database and how long the application can be offline.
Offline migration
Stop the application, copy all the data, then switch to the new server. It is the simplest path and works well for small databases or systems that can be down overnight. The downtime lasts as long as the copy takes.
Online migration
Copy the existing data while the application keeps running, then continuously send new changes until both sides match. You switch over in a short moment. It needs more preparation but keeps downtime to minutes.
Assess
List the databases, sizes, versions, extensions and features in use, and check that each is supported on the target.
Prepare the target
Create the Azure server, networking, users and settings that match the source as closely as is sensible.
Copy the data
Use the Azure Database Migration Service or the engine’s own dump and restore tools to transfer the data.
Validate
Compare row counts, run key reports and test the application against the new server before anybody depends on it.
Cut over and watch
Point the application at the new server, keep the old one untouched for a safety period, and monitor closely.
flowchart LR
S["Source Database"] --> M["Migration Tool"]
M --> T["Azure Flexible Server"]
S -. "ongoing changes in online mode" .-> M
T --> V["Validation and Testing"]
V --> C["Cutover of Application"]
Forgetting small dependencies such as scheduled jobs, user accounts, stored procedures, character sets and time zone settings. They are easy to overlook and can cause confusing bugs after the move.
16Design Patterns That Work Well
Experienced teams keep returning to a handful of reliable ways of using managed databases.
Pattern: Primary with Read Replicas
All writes go to the primary, and read-heavy features such as search pages and reports are sent to replicas. This scales reading without changing the application model much.
Pattern: Cache in Front of the Database
Frequently requested and rarely changing data, such as product details, is stored in a fast in-memory cache. Most requests are answered from the cache, and the database only handles the leftovers.
Pattern: Connection Pooling
Instead of every request opening its own connection, a pool keeps a small set of open connections and reuses them. This protects the server from connection storms.
Pattern: Separate Databases per Service
In larger systems, each service owns its own database. A change in one service does not break the others, and each can be sized independently.
Pattern: Retry with Back-off
When a connection fails during failover or maintenance, the application waits a short time and tries again, waiting longer after each failure. Users experience a small pause instead of an error.
flowchart TD
U["Users"] --> W["Web Application"]
W --> CA["Cache"]
W --> POOL["Connection Pool"]
POOL --> PR["Primary Server for Writes"]
POOL --> RP["Read Replicas for Reads"]
PR -- "replication" --> RP
17Real-World Examples
These services quietly run many of the apps and sites you already use.
Online shops
Product catalogues, customer accounts and orders sit in a relational database. During festival sales, read replicas and caches absorb browsing traffic while the primary protects the integrity of every order.
Content and blogging platforms
Many popular content management systems were designed for MySQL, so moving them to Azure Database for MySQL takes little change and removes the burden of server care.
Mapping and logistics
Delivery companies use PostgreSQL with geographic extensions to store locations and answer questions such as “which warehouse is nearest to this address?”
Software-as-a-service products
Business software vendors keep customer data in PostgreSQL or MySQL, relying on high availability, automatic backups and role-based security to meet customer promises.
Applications with similarity search
Teams building recommendation or document search features store numeric representations of content in PostgreSQL using a vector extension, so ordinary data and similarity search live in one place.
Financial and reporting systems
Strict transaction rules guarantee that balances remain correct, while point-in-time restore gives auditors and administrators a safety net.
18Anti-Patterns to Avoid
These tempting shortcuts regularly cause outages, leaks or surprise bills.
Problem
The firewall allows the whole internet range to reach the database, because it was “easier” to connect from anywhere.
Why It’s Harmful
Attackers constantly scan for open database ports and try common passwords. A single weak password then exposes all the data.
Correct Approach
Use private access for production, or list only the specific addresses that need entry. Require TLS and prefer Entra ID sign-in.
Problem
Every application connects with the administrator account, and its password is pasted into many configuration files.
Why It’s Harmful
A leak from any one place gives total control over every database on the server. Rotating the password means changing it everywhere at once.
Correct Approach
Create a separate least-privilege user for each application, store secrets in a key vault, and use managed identities where possible.
Problem
The team treats high availability as a replacement for backups and never tests a restore.
Why It’s Harmful
A standby copies every change, including accidental deletions and corrupt data. It cannot undo human error, and an untested restore might fail when it is needed most.
Correct Approach
Use high availability for hardware failures and backups for mistakes. Set an adequate retention period and rehearse a restore regularly.
Problem
Slow pages are fixed by buying a bigger server again and again, without looking at the queries.
Why It’s Harmful
Missing indexes and wasteful queries grow worse as data grows. Costs rise steadily while the real cause remains.
Correct Approach
Study slow query logs, inspect query plans, add the right indexes and only then scale the hardware.
Problem
An application opens a new database connection for every single request and never closes it properly.
Why It’s Harmful
Each connection consumes memory. Under heavy traffic the server reaches its connection limit and refuses new users, even though the processor is barely busy.
Correct Approach
Reuse connections through a pool, close them reliably and set sensible limits.
19Best Practices and a Starter Checklist
Follow these steps when setting up a new production server.
Choose the engine and region wisely
Match the engine to your application, and place the server near your users and app servers.
Right-size from the start
Use General Purpose or Memory Optimized for production, and keep Burstable for light workloads.
Turn on high availability
Prefer zone-redundant mode where the region supports it, and build retry logic into the application.
Lock down the network
Use private access for sensitive data, require TLS and keep firewall lists short.
Control identities
Enable Entra ID, create per-application users with minimal rights and keep the administrator account for emergencies.
Plan backups
Extend retention to match your needs, consider geo-redundant backup, and practise restores.
Set up monitoring and alerts
Alert on CPU, memory, storage, connections, replication lag and failed logins, and enable slow query logging.
Plan maintenance and versions
Choose a maintenance window and track end-of-life dates for your major version.
Choosing public access and trying to fix it later, skipping backup tests, running production on a tiny server, giving the administrator login to every application, ignoring slow queries and forgetting to check the bill.
20Frequently Asked Questions
Azure SQL Database runs Microsoft’s own SQL Server engine. Azure Database for MySQL and PostgreSQL run the open-source engines. Pick the one that matches the database your application already uses or your team knows.
Yes. Because these are real MySQL and PostgreSQL engines, standard drivers, command-line clients, graphical tools and frameworks keep working. You only change the connection details.
No. A standby exists only to take over on failure and is not available for your queries. Read replicas are active servers used to share reading work. Many production systems use both.
Usually a brief restart that lasts from several seconds to a couple of minutes. Applications with retry logic ride through it with a small delay. Schedule changes during quiet hours.
In general, no. Storage can be increased but not decreased. To use less storage you would create a new smaller server and migrate the data, so avoid heavily over-provisioning.
The default is seven days, and it can be extended up to thirty-five days. For longer retention, export logical backups to separate storage on your own schedule.
Yes. Data on disk and in backups is encrypted at rest automatically, and connections can be encrypted with TLS. You may use your own keys from Key Vault if your rules require it.
Only if your laptop can reach the virtual network, for example through a VPN, a private connection to your office network or a jump machine inside the network. This is by design and keeps the database off the public internet.
Managed services support a controlled list. Check the supported extensions and parameters first. If something truly essential is missing, a database on a virtual machine that you manage yourself may be the better home, at the cost of doing all the maintenance.
If nothing forces a choice, PostgreSQL is a popular default because of its flexibility and extensions. If your framework or team is built around MySQL, stay with MySQL. Both are well supported on Azure.
21Summary and Key Takeaways
Azure Database for MySQL and PostgreSQL gives you the open-source databases you already know, with Microsoft running the heavy chores underneath. You choose an engine, a compute tier and storage, decide how the server is reached, and switch on high availability and backups to match the importance of your data. From there, replicas, caches and connection pools help it grow, while monitoring, careful security and steady maintenance keep it healthy. A little planning at the beginning prevents most of the pain that teams feel later.
Key Takeaways
- Managed does not mean hands-off — Azure runs the platform, but you still design tables, tune queries and control access.
- Flexible Server is the current choice — it offers control over compute, availability, maintenance windows and networking for both engines.
- Pick the engine for your application — MySQL for web platforms built around it, PostgreSQL for rich features and extensions.
- High availability and backups solve different problems — the standby handles failures, while point-in-time restore handles human mistakes.
- Scale in the right order — fix queries and indexes first, then scale up, then add read replicas and caching.
- Secure in layers — private access, TLS, Entra ID, least-privilege users and encryption work together.
- Watch cost and health continuously — right-size servers, stop what is idle, and set alerts on CPU, memory, storage, connections and replication lag.