โ ํผ๋๋ก
In this post, I summarize my hands-on experience completing the Microsoft Applied Skills: Configure and migrate to Azure Database for PostgreSQL assessment.
Using Azure Portal, pgAdmin, and PostgreSQL, I walked through the core architectural tasks of setting up, securing, migrating, replicating, and optimizing a managed relational database in the cloud.
๐ ๏ธ Step-by-Step Lab Execution
1. Security & Monitoring Setup
-
Authentication: Configured dual authentication on Azure Database for PostgreSQL Flexible Server (
psql63693133), enabling Microsoft Entra ID alongside native PostgreSQL authentication. -
Network Isolation: Isolated server traffic within
VNET1/subnet1by creating a Private Endpoint (psql63693133-pe). -
Diagnostics: Configured Diagnostic Settings (
logs-to-loganalytics) to routePostgreSQL Sessions datalogs to an Azure Log Analytics Workspace (loganalytics1).
2. Migration & Handling the B-Tree Index Error
-
Data Restore: Restored the
adventureworkssample database to Azure using pgAdmin’s restore tool. -
Real-World Error: During
pg_restore, a known error occurred due to the PostgreSQL B-tree index row size limit:
ERROR: index row size 2896 exceeds btree version 4 maximum 2704 for index "IX_ProductReview_ProductID_Name"
Enter fullscreen mode Exit fullscreen mode
-
Resolution & Impact: This error was non-fatal. Because PostgreSQL restores table rows before creating secondary indexes, all schema structures and data were successfully imported. Only the secondary index on
productreview.commentsfailed due to text size limits.
3. Cross-Region Read Replication
-
High Availability: Created a Read Replica (
psql63693133-replica) to offload read-heavy workloads and increase resiliency. - Paired Region: Deployed the replica in Canada Central (the paired region for the primary server located in Canada East).
4. Query Performance Optimization
-
EXPLAIN Plan: Analyzed the
public.address1()function in pgAdmin, extracted its underlying SQL query, generated the EXPLAIN execution plan, and exported the visual output. -
Index Creation: Identified a sequential scan bottleneck on
person.addressand resolved it by creating a targeted index:
CREATE INDEX IX_Address_StateProvinceID
ON person.address (stateprovinceid);
Enter fullscreen mode Exit fullscreen mode
๐ก Key Takeaways
- Private Endpoints First: Always restrict database traffic to private virtual networks before migrating production data.
- Understand Migration Logs: Non-critical index failures (like B-tree row limits on text columns) do not invalidate full data restores.
-
Analyze Before Scaling: Using
EXPLAINto spot missing indexes solves query bottlenecks without needing to increase expensive server compute tiers.
๐ Try It Yourself
Put your hands-on cloud skills to the test with the official assessment module on Microsoft Learn:
๐ Microsoft Applied Skills: Configure and migrate to Azure Database for PostgreSQL
์ถ์ถ ๋ณธ๋ฌธ ยท ์ถ์ฒ: dev.to ยท https://dev.to/luisenr/hands-on-azure-configuring-migrating-and-optimizing-postgresql-flexible-server-3fpl
๋ต๊ธ ๋จ๊ธฐ๊ธฐ