Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hi,
I am working on an orphan recommendation feature in Microsoft Fabric. As part of this, I am extracting metadata and size information for the following resources:
Lakehouse
Warehouse
Cosmos DB Database (mirrored)
Azure SQL Database (mirrored)
I am able to retrieve the size for Lakehouse and Warehouse. However, I am not able to get the size of Cosmos DB and Azure SQL Database.
Since Cosmos DB and Azure SQL Database are mirrored in Fabric, they do not have a physical folder in OneLake. Because of this, the size is not available through OneLake storage metrics.
My questions are:
Is there any Fabric API or supported approach to extract the actual size of mirrored Cosmos DB and Azure SQL Database?
Or should the size be fetched directly from the source services, such as Cosmos DB and Azure SQL, using their native APIs?
Solved! Go to Solution.
Hi @Shijoblesswin ,
Please try the below steps to check the database file size details:
Navigate to the mirrored database in the Fabric portal.
Select View, then Source database. This action opens the Azure Cosmos DB data explorer with a read-only view of the source database.
Select New Query to open a query window.
Run the following SQL command:
SELECT
DB_NAME(database_id) AS DatabaseName,
name AS LogicalFileName,
type_desc AS FileType,
size * 8 / 1024 AS Size_MB
FROM sys.master_files
ORDER BY DatabaseName;
This query will return:
DatabaseName – Name of the database
LogicalFileName – Logical name of the data or log file
FileType – Whether it is a ROWS (data) file or LOG file
Size_MB – Current size of the file in MB
This will help you understand the data and log file sizes and evaluate overall database storage usage.
I hope this information helps. Please do let us know if you have any further queries.
Thank you
May I check if this issue has been resolved? If not, Please feel free to contact us if you have any further questions.
Thank you
Hi @Shijoblesswin
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions.
Thank you.
I checked the Azure portal as suggested. However, both the Cosmos DB and Azure SQL Database appear empty there, and I am not able to see any storage usage.
These databases were created and accessed through Microsoft Fabric as mirrored databases.
If they appear empty in the Azure portal, does that mean the data exists only within Fabric?
In that case, what would be the correct and supported approach to retrieve the actual storage size?
Is there any Fabric API available to get the storage size of mirrored databases?
Hi @Shijoblesswin ,
Please try the below steps to check the database file size details:
Navigate to the mirrored database in the Fabric portal.
Select View, then Source database. This action opens the Azure Cosmos DB data explorer with a read-only view of the source database.
Select New Query to open a query window.
Run the following SQL command:
SELECT
DB_NAME(database_id) AS DatabaseName,
name AS LogicalFileName,
type_desc AS FileType,
size * 8 / 1024 AS Size_MB
FROM sys.master_files
ORDER BY DatabaseName;
This query will return:
DatabaseName – Name of the database
LogicalFileName – Logical name of the data or log file
FileType – Whether it is a ROWS (data) file or LOG file
Size_MB – Current size of the file in MB
This will help you understand the data and log file sizes and evaluate overall database storage usage.
I hope this information helps. Please do let us know if you have any further queries.
Thank you
Hi @Shijoblesswin ,
Thanks for reaching out to the Microsoft Fabric Community forum.
Thank you @deborshi_nag for your suggestion.
Other supported approaches to view size of the database directly from Azure SQL database is by using the following APIs to measure the size of space allocated for databases and elastic pools:
For more information please refer this document
Database file space management - Azure SQL Database | Microsoft Learn
I hope this information helps. Please do let us know if you have any further queries.
Thank you
Hello @Shijoblesswin
You're right, mirrored databases don't store data like Lakehouses or Warehouses. It does use it behind the scenes, but those storage areas are not exposed.
The best way to know the size of these databases is to check portal for the source Azure resources. The actual size of the storage will be in the Storage blade.
The Azure Monitor REST Metric API expose the Storage blade data for specific Azure resources. You can call that from a Python notebook in Fabric, assuming you have right permissions to the Azure resources.
Cosmos DB
subscriptionId – your Azure subscription
resourceGroupName – RG containing the Cosmos DB account
accountName – your Cosmos DB account
Azure SQL Database
Thank you for your guidance.
I checked the Azure portal as suggested. However, both the Cosmos DB and Azure SQL Database appear empty there, and I am not able to see any storage usage.
These databases were created and accessed through Microsoft Fabric as mirrored databases.
If they appear empty in the Azure portal, does that mean the data exists only within Fabric?
In that case, what would be the correct and supported approach to retrieve the actual storage size?
Is there any Fabric API available to get the storage size of mirrored databases?
Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 13 | |
| 6 | |
| 5 | |
| 4 | |
| 4 |
| User | Count |
|---|---|
| 23 | |
| 20 | |
| 14 | |
| 12 | |
| 12 |