Domain 3 of 3 · Chapter 3 of 3

Design and implement operational analytics on Azure Cosmos DB

Unlock the complete study guide + 25 practice exams totaling 1,500 questions.

Bundled into the existing Building AI Applications with Azure Cosmos DB premium course — no separate purchase.

14-day refund guarantee on one-time purchases and your first subscription charge.

Included in this chapter:

  • Two operational homes and one OneLake copy
  • Choosing between a Cosmos DB in Fabric database and mirroring
  • Moving an application to Cosmos DB in Fabric
  • Autoscale throughput limits in Cosmos DB in Fabric
  • Paying for Cosmos DB in Fabric through Fabric capacity
  • Requirements that rule out Cosmos DB in Fabric
  • Mirroring prerequisites for an Azure Cosmos DB account
  • How mirroring replicates a database
  • Creating a mirror and choosing what it covers
  • Mirroring an account behind network restrictions
  • What a mirror costs and who can reach the source
  • Securing the OneLake copy of a mirrored database
  • Monitoring mirror replication
  • Troubleshooting and recovering a mirror
  • How JSON items become mirrored columns
  • Querying mirrored tables with T-SQL
  • Expanding nested JSON with OPENJSON
  • Spark over the OneLake copy with a Lakehouse shortcut
  • Setting up the Cosmos DB Spark connector in Fabric
  • Reading operational data with the connector
  • Using the Spark catalog for Spark SQL and containers
  • Writing results back with the connector
  • Choosing the connector write strategy
  • Matching operational analytics requirements to options

Azure Cosmos DB vs Cosmos DB in Fabric for an operational workload

RequirementAzure Cosmos DBCosmos DB in Fabric
How usage is billedRequest units (RUs) on the Azure accountFabric capacity units (CUs), converted from RUs
Throughput optionsServerless, manual, or autoscaleAutoscale only
AuthenticationMicrosoft Entra ID or account keysMicrosoft Entra ID only, no account keys
SDK connection modeDirect mode or Gateway modeGateway mode only
RegionsOne or many regionsSingle region of the workspace
Stored procedures, triggers, UDFsSupportedNot supported
Customer-managed keysAvailableNot available
Copy in OneLakeMirroring you configure (continuous backup required)Automatic and cannot be disabled
Vector, full-text, and hybrid searchBuilt inBuilt in

Decision tree

Existing Azure Cosmos DBdatabase stays the source?NoYesNeeds an optionCosmos DB in Fabriclacks?YesNoNoSQL API,continuous backup,one write region?YesCosmos DBin FabricAzure Cosmos DB+ mirroringNoNot eligible: fix theaccount or use another

Cheat sheet

  • Fabric Cosmos DB is an operational database, whereas mirroring exposes an existing source for analytics
  • Cosmos DB in Fabric usage is billed through Fabric capacity
  • Cosmos DB in Fabric requires autoscale containers
  • Fabric container throughput defaults differ between portal and SDK creation
  • A Fabric Cosmos DB database has a default quota of 25 containers
  • Choose Azure Cosmos DB when the application requires a multiregion deployment
  • Fabric Cosmos DB does not support Cosmos DB stored procedures, triggers, or UDFs
  • Cosmos DB in Fabric automatically mirrors every database to OneLake
  • Fabric Cosmos DB preserves a Cosmos-compatible operational API
  • An account-key-only application cannot move unchanged to Cosmos DB in Fabric
  • A requirement to retain Direct connections excludes Cosmos DB in Fabric
  • A customer-managed-key requirement excludes the current Fabric-native Cosmos DB service
  • Fabric tenant Private Link does not supply Cosmos-artifact-level Private Link
  • Cosmos DB in Fabric requires an eligible capacity-backed environment
  • Choosing Cosmos DB in Fabric preserves native AI retrieval capabilities
  • Fabric item permissions span the workspace's Cosmos DB artifacts
  • A Fabric capacity region must also support the Cosmos DB workload
  • Azure Cosmos DB mirroring requires a supported continuous-backup source
  • Cosmos DB mirroring supports NoSQL source accounts, not every Cosmos API
  • Mirroring is configured for an individual database with optional container selection
  • Mirroring isolates analytics from the source transactional RU workload
  • Mirroring uses a backup-based initial backfill and then live incremental changes
  • Database mirroring can pick up container lifecycle changes
  • A single mirrored copy can serve multiple Fabric analytical consumers
  • Free mirroring replication does not make analytical queries free
  • Explicit source deletes and source TTL deletions are treated alike by mirroring
  • A mirroring source connection needs supported read-write-key or organizational credentials
  • An Entra-authenticated mirror needs metadata-read and analytics-read source permissions
  • Mirror creation requires an eligible workspace and its Admin or Member role
  • The mirroring interface cannot select a virtual network data gateway connection
  • Ongoing mirroring runs in Fabric Replicator rather than through the gateway
  • Mirroring follows the current write region after a supported source fails over
  • A history of disabling analytical store can make an account ineligible for mirroring
  • Sharing mirror analytics does not require sharing the source database
  • Cosmos DB mirroring does not support customer-managed keys on the OneLake copy
  • Gateway-based Cosmos DB mirroring requires a same-region Fabric workspace
  • Monitor replication exposes both database and table synchronization state
  • Running with warning means replication continues despite nonfatal errors
  • An unchanged last-refresh timestamp can be normal for an idle source
  • Rows replicated counts applied changes rather than only current live rows
  • Stopping and restarting Cosmos DB mirroring reseeds the target tables
  • Workspace monitoring provides mirroring operation logs in a dedicated table
  • A key-authenticated mirror connection must be updated after key rotation
  • Initial mirrored type inference can reflect an older backup image
  • The Paused replication state can reflect a paused Fabric capacity
  • A container stuck with no replicated rows can be restarted by reselection
  • Missing SQL tables or columns can require endpoint schema refresh
  • New JSON properties become columns while missing properties appear as null
  • Renaming a JSON property leaves both old and new mirrored columns
  • Mirroring upcasts compatible property types and represents incompatible values as null
  • Case-distinct JSON property names can receive suffixed mirrored columns
  • The SQL string limit depends on when the mirrored table was created
  • The SQL analytics endpoint queries mirrored tables but does not write back
  • Fabric's source Data Explorer queries the source account rather than the mirror
  • Mirrored container tables support relational analytical joins
  • OPENJSON expands nested source data represented as JSON strings
  • OUTER APPLY preserves source rows that have no nested matches
  • AS JSON preserves a nested fragment for another expansion step
  • Bounded string types can improve typed JSON expansion performance
  • OPENJSON's default schema supports exploration of unknown nested properties
  • A OneLake shortcut exposes mirrored Cosmos DB tables to a Lakehouse notebook
  • Spark over a mirrored table and Spark through cosmos.oltp use different data paths
  • A Spark query can distinguish OneLake replication from SQL endpoint visibility issues
  • Mirroring converts operational JSON into Delta tables for analytical access
  • Direct Spark connector operations need the operational resource configuration
  • The Spark connector can infer a combined schema by sampling existing items
  • The Spark connector writes analytical results back through the operational API
  • A Spark write DataFrame must identify the destination items
  • ItemOverwrite controls replacement of matching items even in APPEND mode
  • CosmosCatalog enables Spark SQL resource management and table references
  • Spark catalog container creation declares the destination partition path and offer
  • The Spark connector libraries must match the notebook runtime
  • The Fabric Cosmos DB connector needs its Fabric-specific resolution settings
  • Connector partial updates use ItemPatch and explicit column operations
  • RawJson patch mapping treats a string column as JSON content
  • Spark explode expands an embedded document array into rows for aggregation

Unlock with Premium — includes all practice exams and the complete study guide.

Also tested in

References

  1. https://learn.microsoft.com/en-us/fabric/mirroring/azure-cosmos-db
  2. https://learn.microsoft.com/en-us/fabric/database/cosmos-db/overview
  3. https://learn.microsoft.com/en-us/fabric/database/cosmos-db/faq
  4. https://learn.microsoft.com/en-us/fabric/mirroring/azure-cosmos-db-faq
  5. https://learn.microsoft.com/en-us/fabric/data-engineering/lakehouse-overview
  6. https://learn.microsoft.com/en-us/fabric/onelake/onelake-shortcuts
  7. https://learn.microsoft.com/en-us/fabric/database/cosmos-db/how-to-use-spark-notebooks
  8. https://learn.microsoft.com/en-us/fabric/mirroring/azure-cosmos-db-tutorial
  9. https://learn.microsoft.com/en-us/fabric/database/cosmos-db/limitations
  10. https://learn.microsoft.com/en-us/fabric/enterprise/licenses
  11. https://learn.microsoft.com/en-us/fabric/mirroring/azure-cosmos-db-limitations
  12. https://learn.microsoft.com/en-us/azure/cosmos-db/analytical-store-introduction
  13. https://learn.microsoft.com/en-us/azure/cosmos-db/synapse-link
  14. https://learn.microsoft.com/en-us/fabric/mirroring/azure-cosmos-db-troubleshooting
  15. https://learn.microsoft.com/en-us/fabric/mirroring/azure-cosmos-db-private-network
  16. https://learn.microsoft.com/en-us/fabric/mirroring/monitor
  17. https://learn.microsoft.com/en-us/fabric/fundamentals/direct-lake-overview
  18. https://learn.microsoft.com/en-us/fabric/mirroring/azure-cosmos-db-how-to-query-nested
  19. https://learn.microsoft.com/en-us/sql/t-sql/functions/openjson-transact-sql
  20. https://learn.microsoft.com/en-us/fabric/mirroring/azure-cosmos-db-lakehouse-notebooks
  21. https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/tutorial-spark-connector