Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Next 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

Reply
Shijoblesswin
New Member

Unable to get size of Cosmos DB and SQL DB in Microsoft Fabric (Mirrored Databases)

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?

1 ACCEPTED 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


View solution in original post

7 REPLIES 7
v-nmadadi-msft
Community Support
Community Support

Hi @Shijoblesswin 

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

v-nmadadi-msft
Community Support
Community Support

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.

Shijoblesswin
New Member

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


v-nmadadi-msft
Community Support
Community Support

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

deborshi_nag
Resident Rockstar
Resident Rockstar

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

 
I trust this will be helpful. If you found this guidance useful, you are welcome to acknowledge with a Kudos or by marking it as a Solution.

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?

Helpful resources

Announcements
FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Fabric Update Carousel

Fabric Monthly Update - March 2026

Check out the March 2026 Fabric update to learn about new features.