web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Best practices for managing storage growth and cleaning "orphaned" records in Tenant Media

(3) ShareShare
ReportReport
Posted on by 66
Hi community,
I’m currently managing a Business Central SaaS environment that has reached 80% of its storage capacity. After performing a technical analysis, I identified that approximately 40% of our total storage consumption is being driven by the Tenant Media (2000000184) and Tenant Media Set (2000000185) tables.

We are looking for advice on the best way to handle this growth and clean up our storage safely. Specifically, I have a few questions:
  • Handling Orphaned Records: Is there a standard, supported procedure or a recommended AL pattern to safely identify and remove "orphaned" records from Tenant Media that are no longer linked to any business record (e.g., deleted vendors, items, or documents)?
  • Maintenance Tools: Besides standard Data Retention Policies, are there any native Codeunits or best practices you recommend for managing media cleanup without compromising data integrity?
  • External Archiving: For high-volume environments, is it a common practice to offload attachments to external storage (like Azure Blob Storage) while keeping only a link in BC? If so, what are the recommended patterns for this architectural change?
I want to ensure we don't break any references or audit trails. Any insights, experiences, or cautionary tales regarding media management in BC SaaS would be greatly appreciated.
 
Thanks in advance for your help!
I have the same question (0)
  • Suggested answer
    YUN ZHU Profile Picture
    102,763 Super User 2026 Season 2 on at
    Regarding the first question, there is a standard method in BC UI.
    Dynamics 365 Business Central: Delete detached/orphaned media within BC (Delete media that is not being actively referenced)
     
    For the second issue, Microsoft has introduced a robust standard feature in the latest release, which I strongly recommend.
    Business Central 2026 release wave 1 (BC28): Storing Document Attachments outside the database (No customization) – See benefits of external storage support for document attachments
     
    Hope this helps.
    Thanks.
    ZHU
  • Suggested answer
    OussamaSabbouh Profile Picture
    18,720 Super User 2026 Season 2 on at
    Hello,
    Yes, Business Central now provides Media.FindOrphans() and MediaSet.FindOrphans() to identify media/media sets that are no longer referenced, but I would not delete directly from Tenant Media blindly; the runtime already performs automatic cleanup in normal deletion scenarios, and any custom cleanup should only act on confirmed orphan GUIDs, preferably first tested in a sandbox and with a backup/restore plan. There is no documented standard bulk-cleanup codeunit specifically for Tenant Media, and Data Retention Policies are mainly intended for supported log/archive tables, not as a general media cleanup tool. For long-term storage growth, starting with Business Central 2026 wave 1, Microsoft now supports storing document attachments externally in Azure Blob Storage, Azure File Share, or SharePoint, including moving existing attachments through Storage Sync; however, this applies to document attachments and does not automatically externalize every generic Media or MediaSet field. My recommendation would be: first identify the actual source records creating the media, use FindOrphans() for confirmed orphan cleanup, then externalize document attachments to prevent future database growth.
    Regards,
    Oussama Sabbouh
  • Sachin.sharma_BCAzureAI Profile Picture
    30 on at
    Before considering any cleanup, I'd recommend identifying which functional areas are generating the most media (document attachments, item pictures, email attachments, incoming documents, etc.). In many cases, the growth is caused by a specific process rather than genuine orphaned records.
  • Suggested answer
    Grigorios Mavrogeorgis Profile Picture
    3,045 Super User 2026 Season 2 on at

    Hi, for the orphans there is something native. Search Data Administration in Tell Me, inside there is Delete Detached Media. Behind it sits the Media Cleanup codeunit in the System Application, you can call it from your own code as well, it returns the detached media and deletes in batches. Came around 23.5 and it's barely documented. Careful though, I seen few reports where the scheduled cleanup took away more than orphans, item pictures and document pdfs included. Restore a sandbox copy and run it there first, not straight in production.

    But detached media is usually not the big part. I'd look at what is still attached, sent email attachments, incoming documents, attachments on posted documents. Retention policies plus deleting from the owning table is the safe way, you never touch Tenant Media directly.

    Blob offload is doable but fully custom, and the audit trail becomes your problem after. How big is the environment now?

     

    Glad to help - follow up if anything is unclear.   

    ►  If this solved it, marking it verified helps others too.       

    Regards,
    Grigorios Mavrogeorgis
    Business Central Consultant & AL Developer

    Work: Gmsoft Limited
    Blog:  insidebusinesscentral
    LinkedIn: linkedin.com/in/gregorymavrogeorgis

  • Manish Sharma Profile Picture
    142 on at

    Have you identified the area which is consuming the storage capacity & how many years data is there in tenant media?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 610 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 476 Super User 2026 Season 2

#3
Grigorios Mavrogeorgis Profile Picture

Grigorios Mavrogeorgis 336 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans