Tutorial: Configure Microsoft Fabric mirrored databases from Azure SQL Managed Instance (Preview)
Mirroring in Fabric is an enterprise, cloud-based, zero-ETL, SaaS technology. In this section, you learn how to create a mirrored Azure SQL Managed Instance database, which represents a read-only, continuously replicated copy of chosen database from your Azure SQL Managed Instance in OneLake.
Prerequisites
- Create or use an existing Azure SQL Managed Instance.
- Update Policy for source Azure SQL Managed Instance needs to be configured to "Always up to date"
- The source Azure SQL Managed Instance can be either a single SQL managed instance or a SQL managed instance belonging to an instance pool.
- If you don't have an Azure SQL Managed Instance, you can create a new SQL managed instance. You can use the Azure SQL Managed Instance free offer if you like.
- During the current preview, we recommend using a copy of one of your existing databases or any existing test or development database that you can recover quickly from a backup. If you want to use a database from an existing backup, see Restore a database from a backup in Azure SQL Managed Instance.
- You need an existing capacity for Fabric. If you don't, start a Fabric trial.
- The Fabric capacity needs to be active and running. A paused or deleted capacity impacts Mirroring and no data are replicated.
- Enable the Fabric tenant setting Service principals can use Fabric APIs. To learn how to enable tenant settings, see About tenant settings.
- Networking requirements for Fabric to access your Azure SQL Managed Instance:
- In the current preview, Mirroring requires that your Azure SQL Managed Instance has a public endpoint which needs to be accessible from Azure Cloud or Power BI service tags. For more information, see Use Azure SQL Managed Instance securely with public endpoints how to securely run a public endpoint for Azure SQL Managed Instance.
Enable System Assigned Managed Identity (SAMI) of your Azure SQL Managed Instance
The System Assigned Managed Identity (SAMI) of your Azure SQL Managed Instance must be enabled, and must be the primary identity, to publish data to Fabric OneLake.
- To configure or verify that the SAMI is enabled, go to your SQL Managed Instance in the Azure portal. Under Security in the resource menu, select Identity.
- Under System assigned managed identity, select Status to On.
- The SAMI must be the primary identity. Verify the SAMI is the primary identity with the following T-SQL query:
SELECT * FROM sys.dm_server_managed_identities;
Database principal for Fabric
Next, you need to create a way for the Fabric service to connect to your Azure SQL Managed Instance.
You can accomplish this with a login and mapped database user. Following the principle of least privilege for security, you should only grant CONTROL DATABASE permission in the database you intend to mirror.
Use a login and mapped database user
Connect to your Azure SQL Managed Instance using SQL Server Management Studio (SSMS) or Azure Data Studio. Connect to the
master
database.Create a server login and assign the appropriate permissions.
- Create a SQL Authenticated login. You can choose any name for this login, substitute it in the following script for
<fabric_login>
. Provide your own strong password. Run the following T-SQL script in themaster
database:
CREATE LOGIN <fabric_login> WITH PASSWORD = '<strong password>'; ALTER SERVER ROLE [##MS_ServerStateReader##] ADD MEMBER <fabric_login>;
- Or, create a Microsoft Entra ID authenticated login from an existing account. Run the following T-SQL script in the
master
database:
CREATE LOGIN [bob@contoso.com] FROM EXTERNAL PROVIDER; ALTER SERVER ROLE [##MS_ServerStateReader##] ADD MEMBER [bob@contoso.com];
- Create a SQL Authenticated login. You can choose any name for this login, substitute it in the following script for
Switch your query scope to the database you want to mirror. Substitute the name of your database for
<mirroring_source_database>
and run the following T-SQL:USE [<mirroring_source_database>];
Create a database user connected to the login. Substitute the name of a new database user for this purpose for
<fabric_user>
:CREATE USER <fabric_user> FOR LOGIN <fabric_login>; GRANT CONTROL TO <fabric_user>;
Or, for Microsoft Entra logins,
CREATE USER [bob@contoso.com] FOR LOGIN [bob@contoso.com]; GRANT CONTROL TO [bob@contoso.com];
Create a mirrored Azure SQL Managed Instance database
- Open the Fabric portal.
- Use an existing workspace, or create a new workspace.
- Navigate to the Create pane. Select the Create icon.
- Scroll to the Data Warehouse section and then select Mirrored Azure SQL Managed Instance (preview).
Connect to your Azure SQL Managed Instance
To enable Mirroring, you need to connect to the Azure SQL Managed Instance from Fabric to initiate connection between SQL Managed Instance and Fabric. The following steps guide you through the process of creating the connection to your Azure SQL Managed Instance:
- Under New sources, select Azure SQL Managed Instance. Or, select an existing Azure SQL Managed Instance connection from the OneLake catalog.
- You can't use existing Azure SQL Managed Instance connections with type "SQL Server" (generic connection type). Only connections with connection type "SQL Managed Instance" are supported for mirroring of Azure SQL Managed Instance data.
- If you selected New connection, enter the connection details to the Azure SQL Managed Instance. You need to connect to a specific database, you can't set up mirroring for the entire SQL managed instance and all its databases.
- Server: You can find the Server name by navigating to the Azure SQL Managed Instance Networking page in the Azure portal (under Security menu) and looking at the Public Endpoint field. For example,
<managed_instance_name>.public.<dns_zone>.database.windows.net,3342
. - Database: Enter the name of database you wish to mirror.
- Connection: Create new connection.
- Connection name: An automatic name is provided. You can change it to facilitate finding this SQL managed instance database connection at a future time, if needed.
- Authentication kind:
- Basic (SQL Authentication)
- Organization account (Microsoft Entra ID)
- Tenant ID (Azure Service Principal)
- Server: You can find the Server name by navigating to the Azure SQL Managed Instance Networking page in the Azure portal (under Security menu) and looking at the Public Endpoint field. For example,
- Select Connect.
Start mirroring process
The Configure mirroring screen allows you to mirror all data in the database, by default.
Mirror all data means that any new tables created after Mirroring is started will be mirrored.
Optionally, choose only certain objects to mirror. Disable the Mirror all data option, then select individual tables from your database.
If tables can't be mirrored at all, they show an error icon and relevant explanation text. Likewise, if tables can only mirror with limitations, a warning icon is shown with relevant explanation text.
For this tutorial, we select the Mirror all data option.
On the next screen, give the destination item a name and select Create mirrored database. Now wait a minute or two for Fabric to provision everything for you.
After 2-5 minutes, select Monitor replication to see the status.
After a few minutes, the status should change to Running, which means the tables are being synchronized.
If you don't see the tables and the corresponding replication status, wait a few seconds and then refresh the panel.
When the initial copying of the tables is finished, a date appears in the Last refresh column.
Now that your data is up and running, there are various analytics scenarios available across all of Fabric.
Important
Any granular security established in the source database must be re-configured in the mirrored database in Microsoft Fabric.
Monitor Fabric Mirroring
Once mirroring is configured, you're directed to the Mirroring Status page. Here, you can monitor the current state of replication.
These are the replicating statuses:
For overall database level monitoring:
- Running – Replication is currently running bringing snapshot and change data into OneLake.
- Running with warning: Replication is running, with transient errors
- Stopping/Stopped – Replication is stopped.
- Error – Fatal error in replication that can't be recovered.
For table level monitoring:
- Running –The data from the table is successfully being replicated into the warehouse.
- Running with warning – Warning of non-fatal error with replication of the data from the table
- Stopping/Stopped - Replication has stopped
- Error – Fatal error in replication for that table.
If the initial sync is completed, a Last completed timestamp is shown next to the table name. This timestamp indicates the time when Fabric has last checked the table for changes.
Also, note the Rows replicated column. It counts all the rows that have been replicated for the table. Each time a row is replicated, it is counted again. This means that, for example, inserting a row with primary key =1 on the source increases the "Rows replicated" count by one. If you update the row with the same primary key, replicates to Fabric again, and the row count increases by one, even though it's the same row which replicated again. Fabric counts all replications that happened on the row, including inserts, deletes, updates.
The Monitor replication screen also reflects any errors and warnings with tables being mirrored. If the table has unsupported column types or if the entire table is unsupported (for example, in memory or columnstore indexes), a notification about the limitation is shown on this screen. For more information and details on the replication states, see Monitor Fabric mirrored database replication.