|
| 1 | +# PostgreSQL Mirroring to Fabric |
| 2 | + |
| 3 | +This guide explains how to complete PostgreSQL mirroring in Microsoft Fabric after deployment. |
| 4 | + |
| 5 | +## Why a Fabric Connection Is Required |
| 6 | + |
| 7 | +The Fabric mirroring API requires a Fabric "connection" object that stores the PostgreSQL endpoint and credentials. The mirror call only accepts a `connectionId` and database name, so a valid Fabric connection must exist before mirroring can be created. |
| 8 | + |
| 9 | +## Prerequisites |
| 10 | + |
| 11 | +- Deployment finished, and PostgreSQL Flexible Server exists. |
| 12 | +- Post-provision prep ran (it creates the `fabric_user` role and sets required PostgreSQL flags). |
| 13 | +- You can sign in to Fabric (app.fabric.microsoft.com) with access to the workspace. |
| 14 | + |
| 15 | +## Step 1: Confirm PostgreSQL Details |
| 16 | + |
| 17 | +Get the PostgreSQL server FQDN and database name: |
| 18 | + |
| 19 | +- FQDN: from `azd env get-value postgreSqlServerFqdn` |
| 20 | +- Database name: `postgres` (default) or your custom DB |
| 21 | + |
| 22 | +## Step 2: Create the Fabric Connection (UI) |
| 23 | + |
| 24 | +1. Open the Fabric workspace. |
| 25 | +2. Go to **Settings** -> **Manage connections and gateways**. |
| 26 | +3. Select **New connection** -> **PostgreSQL**. |
| 27 | +4. Enter: |
| 28 | + - Server: PostgreSQL FQDN |
| 29 | + - Database: your database name |
| 30 | + - User: `fabric_user` |
| 31 | + - Password: value from Key Vault secret `postgres-fabric-user-password` |
| 32 | +5. Save and copy the **Connection ID**. |
| 33 | + |
| 34 | +## Step 3: Set the Connection ID in azd |
| 35 | + |
| 36 | +```powershell |
| 37 | +azd env set-value fabricPostgresConnectionId "<connection-id>" |
| 38 | +azd env set-value POSTGRES_DATABASE_NAME "postgres" |
| 39 | +``` |
| 40 | + |
| 41 | +## Step 4: Create the Mirror |
| 42 | + |
| 43 | +Run the mirror script: |
| 44 | + |
| 45 | +```powershell |
| 46 | +./scripts/automationScripts/FabricWorkspace/Mirror/create_postgresql_mirror.ps1 |
| 47 | +``` |
| 48 | + |
| 49 | +## Verify |
| 50 | + |
| 51 | +- In Fabric, a mirrored database named `pg-mirror-<env>` should appear. |
| 52 | +- Re-running the script is safe; it will skip if the mirror already exists. |
| 53 | + |
| 54 | +## Notes |
| 55 | + |
| 56 | +- The deployment now skips the mirror step until a valid Fabric connection exists, so `azd up` will no longer fail on this step. |
| 57 | +- If you rotate passwords, update the Fabric connection in the workspace. |
0 commit comments