Forum Discussion

andyparkerson's avatar
andyparkerson
Icon for Advocate III rankAdvocate III
4 months ago
Solved

Change Source Connection on Mirrored Database

Is there any way to change the connection that an existing Mirrored Database is using?   We are migrating to a new gateway (someone forgot to write down the Recovery Key) and we want everything to ...
  • oussamahaimoud's avatar
    4 months ago

    Hi andyparkerson,

    Hope you're doing well!

     

    There is no option in the Fabric portal to swap the connection on an existing Mirrored Database. The connection is set at creation time and the UI does not expose a way to change it directly.

     

    Solution :

     

    The Fabric Mirroring Public REST API supports updating a mirrored database's definition, including the connection property in the source configuration.  https://learn.microsoft.com/en-us/fabric/mirroring/mirrored-database-rest-api

     

    So, you can do this without recreating the item by doing it step by step:

     

    • Call GET https://api.fabric.microsoft.com/v1/workspaces/<workspaceId>/mirroredDatabases/<mirroredDatabaseId>/getDefinition to retrieve the current definition.
    • In the returned JSON, locate the source.typeProperties.connection field and replace the old connection ID with your new one.
    • Call POST .../updateDefinition with the modified payload.

    The definition structure (JSON) looks like this:

    {

      "properties": {

        "source": {

          "type": "<your source type>",

          "typeProperties": {

            "connection": "<NEW-CONNECTION-ID>",

            "database": "your-db-name"

          }

        }

      }

    }

     

    You can find your new connection ID by going to: Settings → Manage connections and gateways → [your connection] → Settings → Connection ID.

     

    Hope this helps! Feel free to tell us if that works. Don't forget to mark as solution and thumbs up, that's motivate me to keep helping 🙂

     

    Best regards,

    Oussama (Data Consultant - Expert Fabric & Power BI)

  • stoic-harsh's avatar
    4 months ago

    Hey andyparkerson,

    Agree with oussamahaimoud on the REST API approach. But there's an important prerequisite: the Connection ID (and database name) can only be updated when mirroring status is Initialized or Stopped.

    Before calling updateDefinition API directly:

    1. Stop mirroring via the portal or Stop Mirroring API.
    2. Confirm status via getMirroringStatus.
    3. Call updateDefinition with the new connection ID.
    4. Restart mirroring.

    Heads up on restart: After swapping the connection, expect a full re-initialization. Existing data in OneLake is preserved, but every table will be fetched from scratch. So, plan your re-sync window accordingly.

    Useful link: Fabric Mirroring Public REST API - Microsoft Fabric | Microsoft Learn

    Please do share if it works without stopping mirroring first, or any useful findings.

    Hope this helps!

    Best,

    Harshit