Add Azure SQL Database CDC source to an eventstream

This article shows you how to add an Azure SQL Database Change Data Capture (CDC) source to an eventstream.

The Azure SQL Database CDC source connector for Microsoft Fabric event streams allows you to capture a snapshot of the current data in an Azure SQL database. The connector then monitors and records any future row-level changes to this data. Once the changes are captured in the eventstream, you can process this CDC data in real-time and send it to different destinations within Fabric for further processing or analysis.

Note

This source is not supported in the following regions of your workspace capacity: West US3, Switzerland West.

Prerequisites

  • Access to a workspace in the Fabric capacity license mode (or) the Trial license mode with Contributor or higher permissions.
  • A running Azure SQL server with an Azure SQL database.
  • Your Azure SQL database must be publicly accessible and not be behind a firewall or secured in a virtual network.
  • Enabled CDC in your Azure SQL database by running the stored procedure sys.sp_cdc_enable_db. For details, see Enable and disable change data capture.
  • If you don't have an eventstream, create an eventstream.

Note that you must not enable mirroring in your Azure SQL database.

Enable CDC in your Azure SQL Database

  1. Go to the Azure portal, open your Azure SQL database, and select Query editor. Choose an authentication method to log in.

    A screenshot of opening Azure SQL database.

  2. Run the following SQL commands to enable CDC in your database:

    -- Enable Database for CDC
    EXEC sys.sp_cdc_enable_db;
    
    -- Enable CDC for a table using a gating role option
    EXEC sys.sp_cdc_enable_table
        @source_schema = N'dbo',
        @source_name   = N'MyTable',
        @role_name     = NULL
    GO
    

Launch the Select a data source wizard

If you haven't added any source to your eventstream yet, select Use external source tile.

Screenshot that shows the selection of Use external source tile.

If you're adding the source to an already published eventstream, switch to Edit mode, select Add source on the ribbon, and then select External sources.

Screenshot that shows the selection of Add source to External sources menu.

On the Select a data source page, search for and select Connect on the Azure SQL DB (CDC) tile.

Screenshot that shows the selection of Azure SQL DB CDC as the source type in the Get events wizard.

Configure and connect to Azure SQL Database CDC

  1. On the Connect page, select New connection.

    Screenshot that shows the Connect page of the Get events wizard with the **New connection** link highlighted.

  2. In the Connection settings section, enter the following values for your Azure SQL database:

    • Server: Enter the Azure SQL server name from the Azure portal. It's in this form: mysqlservername.database.windows.net.

    • Database: Enter the Azure SQL database name from the Azure portal.

      Screenshot that shows the Connection settings section of the New connection page.

  3. Scroll down, and in the Connection credentials section, follow these steps.

    • For Connection name, enter a name for the connection.

    • For Authentication kind, select Basic.

      Note

      Currently, Fabric event streams supports only Basic authentication.

    • Enter Username and Password for the database.

  4. Select Connect.

    Screenshot that shows the Connection credentials section of the New connection page.

  5. Now, on the Connect page, enter the following information:

    • Select All tables or enter the table names separated by commas, such as: dbo.table1, dbo.table2
    • For Port, the default value is 1433 and cannot be modified.
  6. Select Next.

    Screenshot that shows the Connect page of the Get events wizard filled.

  7. On the Review and create screen, review the summary, and then select Add.

    Screenshot that shows the Review and create page of the Get events wizard filled.

Note

The maximum number of sources and destinations for one eventstream is 11.

View updated eventstream

  1. You can see the Azure SQL Database (CDC) source added to your eventstream in Edit mode.

    Screenshot of streaming Azure SQL Database CDC source in Edit view.

  2. To implement this newly added Azure SQL Database CDC source, select Publish. After you complete these steps, your Azure SQL Database CDC source is available for visualization in the Live view.

    Screenshot of streaming Azure SQL Database CDC source in Live view.

Other connectors: