Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more
Announced at Microsoft Ignite on November 24, the latest enhancements to Microsoft Fabric include the introduction of Open Mirroring. This innovative feature allows data to be mirrored from any source into Fabric, which then manages inserts, updates, and deletes, presenting the data in a queryable format via the SQL Endpoint. This represents a significant advancement from previous mirroring capabilities, which were limited to sources such as SQL databases, managed instances, and Cosmos DB.
Open Mirroring in Microsoft Fabric offers several benefits:
The process is that a Landing Zone is created when a Mirroring Database is created. This Landing Zone is a folder within OneLake and can be accessed using a specific URL. To create a Delta "table" in the mirrored database, you must create a folder in the Landing Zone. Each folder then must have a _metadata.json file (explained in this blog). Each folder then operates independently in terms of files being uploaded and synced.
The following steps outline a basic demonstration of how Open Mirroring operates:
Within Fabric, create a new item and select the mirroring database option. For this demonstration, the database will be named DE_SQL_MIRROR_SOURCE.
The Mirrored Database will provision, this should only take a few seconds to 1 minute to create. Pay particular attention to the Landing Zone URL as this is where we must create folders and load data to.
A _metadata.json file is required in each folder to which data will be pushed. This file specifies the key column (or columns) that form a unique key for the data, this is required to enable Update and Delete operations in the Mirrored Database. You can either download an example from GitHub here or create it from scratch:
{
"keyColumns": ["EmployeeID"]
}
To create the folder and upload files, I'm using Azure Storage Explorer.
If you switch back to Fabric and in the Mirrored Database, click Refresh under the Monitor Replication section, you should see the folder appearing as a new table.
Please note the following:
For this demo I have created 3 separate files to show the Insert, Update, and Delete operations in isolation. However, you are able to mix the row marker types in the same file. You can download the files from GitHub here.
Upload the file 00000000000000000001.parquet to the new folder. This file contains 3 rows with the __rowmarker__ column set to 0. This action will insert new rows into the mirroring database. After a few seconds the mirroring status should show 3 rows.
We can then query the SQL Endpoint using T-SQL and see the 3 rows. We don;t see the rowmarker column from the source data as that's metadata for the mirroring process.
Upload the file 00000000000000000002.parquet to the new folder. This file contains 1 row with the __rowmarker__ column set to 1. This action will update rows into the mirroring database. After a few seconds the mirroring status should show 4 rows. If we query the data using the SQL Endpoint, we'll see the update reflected.
Finally, upload the file 00000000000000000003.parquet to the new folder. This file contains 1 row with the __rowmarker__ column set to 2. This action will delete rows into the mirroring database. After a few seconds the mirroring status should show 5 rows. If we query the data using the SQL Endpoint, we'll see the delete reflected, and now only 2 employee records remain.
After uploading the files, the mirroring status can be monitored within Fabric. The system will indicate the number of rows replicated and any warnings. T-SQL can then be used to query the mirrored data, ensuring that all operations (insert, update, delete) have been successfully applied.
Open Mirroring in Microsoft Fabric is a powerful tool for integrating and managing data from various sources. By adhering to the guidelines and utilizing the appropriate file formats and conventions, this feature can be leveraged to maintain a consistent and queryable dataset within Fabric. This innovation opens up new possibilities for data management and integration, simplifying the process of working with diverse data sources.
For more detailed information, refer to the official documentation on Open Mirroring.
Open Mirroring (Preview) - Microsoft Fabric | Microsoft Learn
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.