Domain 3 β€” Module 4 of 5 80%
30 of 31 overall
Domain 3: Implement AI and analytics capabilities in database solutions Free ⏱ ~23 min read

Operational Analytics with Microsoft Fabric

Choose an Azure or Fabric-native Cosmos DB serving store, configure mirroring, query nested JSON and use the Spark connector for operational reads and writes.

Three similar names, different responsibilities

OptionRole
Azure Cosmos DBAn operational database account managed in Azure
Cosmos DB in Microsoft FabricA native NoSQL serving database integrated with the Fabric experience
Fabric mirroring of Azure Cosmos DBAn analytical replica of an existing supported Azure source into OneLake

Do not assume the SQL analytics endpoint of a mirror is a writable operational database.

Choose the platform using required operational controls, integration and current supported features. A Fabric-centred new application may benefit from the native database. An existing Azure application that must retain its account can add mirroring without moving its write path.

Mirror an existing source

For the supported Azure Cosmos DB for NoSQL source:

  1. Check account and regional support.
  2. Enable continuous backup; the documented requirement supports the seven-day or thirty-day tier.
  3. Configure the Fabric connection with supported authentication and required permissions.
  4. Select the database and containers to mirror.
  5. Monitor initial replication and ongoing status before using the data as current evidence.

Verify networking, masking and other integration restrictions against current documentation. An enabled source account alone does not establish a healthy mirror.

Which activity consumes transactional RUs?

Mirroring replicates data into OneLake without consuming the source application’s transactional RU budget. Analytical queries can use the OneLake copy.

That statement does not apply to every operation launched from a Fabric screen:

OperationSource transactional RU impact
Mirroring replicationNo transactional RU consumption
Query the analytical OneLake copyDoes not query the source transactional store
Query the source through Cosmos DB data explorerConsumes source RUs
Read/write the source through the operational Spark connectorConsumes operational throughput

Always identify the actual data path.

T-SQL and nested JSON

The mirrored database has a SQL analytics endpoint. It supports analytical queries and views but is read-only for the replicated data.

Nested content can appear as JSON strings. Expand it with T-SQL JSON functions:

SELECT
    o.id,
    lines.sku,
    lines.quantity
FROM dbo.orders AS o
CROSS APPLY OPENJSON(o.lineItems)
WITH (
    sku nvarchar(100) '$.sku',
    quantity int '$.quantity'
) AS lines;

This is an illustrative view shape; use the actual mirrored table and property names. Choose OUTER APPLY when the analysis must retain parents with missing or empty nested content.

Do not send an UPDATE to the mirrored SQL endpoint expecting reverse replication. Make corrections through the authorized source write path.

Spark analytics versus operational connector access

A Fabric notebook can analyze mirrored Delta data in OneLake using Spark. For an explicit source read or a write back into an operational Cosmos DB container, use the supported Cosmos DB Spark connector with the correct account, database, container and permissions.

An illustrative write shape:

(
    results.write
    .format("cosmos.oltp")
    .options(**cosmos_write_options)
    .mode("APPEND")
    .save()
)

cosmos_write_options must contain the supported connector settings for the environment and identity. Do not embed production account keys in a notebook. Verify that the DataFrame contains valid ids and partition-key values, and plan throughput for the write.

The connector does not become RU-free because its notebook runs in Fabric.

Schema and freshness

Mirroring follows source changes, but replication and analytical availability are not the same observation as a successful source write.

New properties can become new columns. A renamed property can leave both old and new columns, with nulls according to which properties an item contains. Handle planned schema transitions in the analytical model rather than declaring every duplicate-looking column a corrupt mirror.

When a report is stale:

  • Confirm a known record in the operational source.
  • Inspect replication status and progress.
  • Check source prerequisites, connection permissions and supported configuration.
  • Inspect the analytical copy and the report’s actual query path.

Initial replication can take longer than subsequent changes. Do not promise that β€œnear real-time” means every item is synchronously visible in every report.

Try it

Mirror a small non-sensitive dataset with nested arrays. Query the same analytical result with T-SQL and Spark, then use an authorized connector write to add a derived result to a separate operational destination.

Measure the difference between connector source reads and OneLake analytical reads. Verify a source schema rename without deleting the mirror.

Question

Can a mirrored SQL analytics endpoint update the operational Cosmos DB source?

Click or press Enter to reveal answer

Knowledge Check

A Spark notebook reads a live Cosmos DB container through the operational connector. Why does source RU consumption rise?

Official references