Add Azure Cosmos DB CDC as source in Real-Time hub
This article describes how to add Azure Cosmos DB for NoSQL Change Data Capture (CDC) as an event source in Fabric Real-Time hub.
The Azure Cosmos DB Change Data Capture (CDC) source connector lets you capture a snapshot of the current data in an Azure Cosmos DB database. The connector then monitors and records any future row-level changes to this data. Once the changes are captured in a stream, you can process this CDC data in real-time and send it to different destinations within Fabric for further processing or analysis.
Prerequisites
- Access to a workspace in the Fabric capacity license mode (or) the Trial license mode with Contributor or higher permissions.
- Access to an Azure Cosmos DB for NoSQL account and database.
- Your Azure Cosmos DB for NoSQL database must be publicly accessible and not be behind a firewall or secured in a virtual network.
- If you don't have an eventstream, create an eventstream.
Get connection details from the Azure portal
The labels for the items you need to collect from the Azure portal are shown in the following steps. You always need the endpoint URI, in a format like https://<account>.<api>.azure.com:<port>/
, the Primary Key, and the Database name and item IDs you want to collect data for.
Note
Azure Cosmos DB for NoSQL CDC is using the Latest Version Mode of Azure Cosmos DB Change Feed. It captures the changes to records in the latest version. Note that Deletions are't captured with this mode.
On the Azure portal page for your Azure Cosmos DB account, select Keys under Settings in the left navigation.
On the Keys page, copy the URI and Primary key values to use for setting up the eventstream connection.
On the Azure portal Overview page for your Azure Cosmos DB account, note the Database and item ID you want to collect data for.
Get events from an Azure Cosmos DB CDC
You can get events from an Azure Cosmos DB CDC into Real-Time hub in one of the ways:
Data sources page
Sign in to Microsoft Fabric.
Select Real-Time on the left navigation bar.
On the Real-Time hub page, select + Data sources under Connect to on the left navigation menu. You can also get to the Data sources page from All data streams or My data streams pages by selecting the + Connect data source button in the top-right corner.
Use instructions from the Add Azure Cosmos DB CDC as a source section.
Microsoft sources page
In Real-Time hub, select Microsoft sources.
In the Source drop-down list, select Azure Cosmos DB (CDC).
For Subscription, select an Azure subscription that has the resource group with your Cosmos DB account.
For Resource group, select a resource group that has your Cosmos DB account.
For Region, select a location where your Cosmos DB is located.
Now, move the mouse over the name of the Cosmos DB CDC source that you want to connect to Real-Time hub in the list of databases, and select the Connect button, or select ... (ellipsis), and then select the Connect button.
To configure connection information, use steps from the Add Azure Cosmos DB CDC as a source section. Skip the first step of selecting Azure Cosmos DB CDC as a source type in the Add source wizard.
Add Azure Cosmos DB CDC as a source
On the Connect page, select New connection.
In the Connection settings section, specify the Cosmos DB endpoint. Enter the URI or endpoint for your Cosmos DB account that you copied from the Azure portal.
Expand Advanced options, and follow these steps:
For Number of retries, specify the maximum number of times the connector should retransmit a request to the Cosmos DB database if the request fails from a recoverable error.
For Enable AVERAGE function pass down, specify whether the connector should pass down of the AVG aggregate function to the Cosmos DB database.
For Enable SORT pass down for multiple columns, specify whether the connector should allow multiple columns to be passed down to Cosmos DB database when specified in the ORDER BY clause of the SQL query.
Scroll down, and in the Connection credentials section, follow these steps.
- Select an existing connection and keep the default Create new connection option.
- To create a connection, enter the following values:
For Connection name, enter a name for the connection.
For Authentication kind, select Account key.
For Account key, enter the key value you saved earlier.
Select Connect.
Now, on the Connect page, do these steps:
Specify the Container ID of the container in your Azure Cosmos DB account.
In the Stream details section to the right, select the Fabric workspace where you want to save the eventstream that the Wizard is going to create.
For eventstream name, enter a name for the eventstream. The wizard creates an eventstream with the selected Azure Cosmos DB CDC as a source.
The Stream name is automatically generated for you by appending -stream to the name of the eventstream. You can see this stream on the Real-time hub All data streams page when the wizard finishes.
Select Next.
On the Review + connect screen, review the summary, and then select Create source.
View data stream details
On the Review + connect page, if you select Open eventstream, the wizard opens the eventstream that it created for you with the selected Azure Cosmos DB CDC as a source. To close the wizard, select Close or X* in the top-right corner of the page.
In Real-Time hub, select All data streams. To see the new data stream, refresh the All data streams page.
For detailed steps, see View details of data streams in Fabric Real-Time hub.
Related content
To learn about consuming data streams, see the following articles: