Managed Databases
Beyond Azure SQL Database, Azure offers SQL Managed Instance for near-full SQL Server compatibility, plus fully managed MySQL and PostgreSQL services for open-source workloads.
Overview
Three managed database offerings cover most workload migration scenarios:
| Service | Engine | Best For |
|---|---|---|
| SQL Managed Instance (SQL MI) | SQL Server (near 100% compat) | Lift-and-shift SQL Server with full features |
| Azure DB for MySQL | MySQL 5.7 / 8.0 | PHP/LAMP stacks, WordPress, Drupal |
| Azure DB for PostgreSQL | PostgreSQL 11-16 | Django, Rails, GIS (PostGIS), analytics |
SQL Managed Instance
SQL MI is a fully managed SQL Server instance — think SQL Server deployed in a VNet, managed by Azure, with near 100% feature compatibility including SQL Agent, CLR, linked servers, cross-database queries, and service broker.
SQL MI vs Azure SQL Database
| Feature | Azure SQL Database | SQL Managed Instance |
|---|---|---|
| SQL Server agent | Limited | Full support |
| Cross-database queries | No | Yes |
| CLR / Linked servers | No | Yes |
| Network isolation | Public endpoint or PE | Deployed inside VNet |
| On-prem migration | Moderate effort | Minimal changes |
| Cost | Lower | Higher (starts ~$200/mo) |
| Best for | New apps, modern workloads | SQL Server migration, enterprise apps |
Azure Database for MySQL
Fully managed MySQL with automatic backups, patching, and HA. The Flexible Server deployment is the recommended option (replaces Single Server which is being retired).
# Create MySQL Flexible Server az mysql flexible-server create \ --resource-group rg-database \ --name myapp-mysql-flex \ --location eastus \ --admin-user mysqladmin \ --admin-password "P@ssw0rd2024!" \ --sku-name Standard_D2ds_v4 \ --tier GeneralPurpose \ --version 8.0 # Create database az mysql flexible-server db create \ --resource-group rg-database \ --server-name myapp-mysql-flex \ --database-name appdb # Open firewall (add client IP) az mysql flexible-server firewall-rule create \ --resource-group rg-database \ --name myapp-mysql-flex \ --rule-name ClientIP \ --start-ip-address 203.0.113.10 \ --end-ip-address 203.0.113.10 # Connection string (MySQL) # Server=myapp-mysql-flex.mysql.database.azure.com; # Database=appdb;Uid=mysqladmin;Pwd=P@ssw0rd2024!;SslMode=Required;
Azure Database for PostgreSQL
Fully managed PostgreSQL with Flexible Server (standard deployment) and extensions support (PostGIS, pg_vector, etc.). Ideal for Python (Django/SQLAlchemy), Ruby on Rails, and Node.js apps.
# Create PostgreSQL Flexible Server az postgres flexible-server create \ --resource-group rg-database \ --name myapp-pg-flex \ --location eastus \ --admin-user pgadmin \ --admin-password "P@ssw0rd2024!" \ --sku-name Standard_D2ds_v4 \ --tier GeneralPurpose \ --version 16 # Create database az postgres flexible-server db create \ --resource-group rg-database \ --server-name myapp-pg-flex \ --database-name appdb # Connect (psql) psql -h myapp-pg-flex.postgres.database.azure.com \ -U pgadmin -d appdb # Enable PostGIS extension # In psql: CREATE EXTENSION postgis;
Decision Guide
- Migrating existing SQL Server (enterprise features needed) → SQL Managed Instance
- New app, standard SQL, no DBA team → Azure SQL Database
- PHP/LAMP app, CMS (WordPress/Drupal) → Azure DB for MySQL
- Python/Django, Rails, GIS, JSON-heavy, analytics → Azure DB for PostgreSQL
- Global scale, schema flexibility, multi-model → Cosmos DB
Hands-on
- Create an Azure DB for MySQL Flexible Server and connect with MySQL Workbench.
- Create a PostgreSQL Flexible Server, connect via psql, and create a table.
- Enable the
pg_vectorextension on PostgreSQL for AI embedding storage. - Compare the connection strings and discuss how apps point to managed DBs.
- Review the Metrics panel for each DB — examine active connections and query time.
Debugging Scenario
Issue: MySQL app throws "SSL connection error" after migrating to Azure DB for MySQL.
- Azure DB for MySQL enforces SSL by default. Download the DigiCert root CA certificate from Azure docs and point your app's SSL CA setting to it.
- For MySQL connectors: add
SslMode=Required;SslCa=/path/to/DigiCertGlobalRootG2.crt.pemto the connection string. - Test with
mysql --ssl-ca=cert.pem -h server.mysql.database.azure.com -u admin -p.
Interview Questions
Beginner
SQL MI is a full SQL Server instance inside your VNet — supports CLR, SQL Agent, linked servers, cross-database queries. Azure SQL Database is a modern PaaS database — lower cost, simpler, lacks some SQL Server-specific features.
Scenario-based
Use SQL Managed Instance — it has near 100% feature compatibility with SQL Server. Azure SQL Database would require significant application refactoring to remove SQL Agent and linked server dependencies.
Migrate to Azure DB for PostgreSQL Flexible Server. It supports the same PG protocol and extensions. Update the connection string; Django ORM works without changes.
Summary
SQL Managed Instance offers the closest lift-and-shift path for SQL Server workloads. Azure DB for MySQL and PostgreSQL provide fully managed open-source database options without vendor lock-in. All three include automatic backups, patching, HA, and built-in monitoring.