Share via

Cannot delete tenant

FredBalster 0 Reputation points
2026-03-10T17:17:52.6+00:00

User's image

All checks are green.
Still I cannot delete the tenant.
I am getting this error message.
User's image

Ofcourse I pressed the 'Help me troubleshoot' button and followed the directions.
Been to several webpages like these:
https://learn.microsoft.com/en-us/entra/identity/users/directory-delete-howto
https://techcommunity.microsoft.com/discussions/azure/unable-to-delete-tenant/4421862
https://learn.microsoft.com/en-us/answers/questions/5691188/cannot-delete-tenant-because-of-enterprise-apps-th
I follewed these up to. None of them helped.
Does anybody have another suggestion I might try?

Microsoft Security | Microsoft Entra | Microsoft Entra ID

1 answer

Sort by: Most helpful
  1. AI answer

    2026-03-10T17:20:34.0066667+00:00

    The portal check list can show all green and still fail tenant deletion because of enterprise applications (service principals) that can’t be removed from the UI. These must be cleaned up with PowerShell before the tenant can be deleted.

    Use this end‑to‑end procedure:

    1. Install required PowerShell modules
    Install-Module Microsoft.Graph
    Install-Module -Name Az
    
    1. Connect explicitly to the tenant that must be deleted

    Use a Global Administrator that is homed in this tenant (not a guest account).

    Connect-MgGraph -Scopes "Application.ReadWrite.All"
    Get-MgDomain   # verify the onmicrosoft.com domain and tenant ID
    
    Clear-AzContext -Scope CurrentUser
    Connect-AzAccount -Tenant <object id of the tenant you are attempting to delete>
    Get-AzContext   # confirm the same tenant ID/onmicrosoft.com domain
    

    These checks ensure that subsequent commands run only against the tenant that is being removed.

    1. Remove all enterprise applications (service principals)

    Some service principals are not deletable from the portal but can be removed through Microsoft Graph. Run this command; execute it multiple times until it no longer finds removable objects (some deletions fail on first attempt because of dependencies):

    Get-MgServicePrincipal -All | ForEach-Object {
        Remove-MgServicePrincipal -ServicePrincipalId $_.Id
    }
    
    1. Disable and retry removal for stubborn service principals

    If any service principals still cannot be deleted, first disable them, then try deletion again:

    $ServicePrincipalUpdate = @{ "accountEnabled" = "false" }
    
    Get-MgServicePrincipal -All | ForEach-Object {
        Update-MgServicePrincipal -ServicePrincipalId $_.Id -BodyParameter $ServicePrincipalUpdate
    }
    
    Get-MgServicePrincipal -All | ForEach-Object {
        Remove-MgServicePrincipal -ServicePrincipalId $_.Id
    }
    

    Disabling them prevents them from blocking the tenant deletion even if some remain.

    1. Delete the tenant again from the portal
    2. Sign in to the Microsoft Entra admin center as Global Administrator.
    3. Go to Microsoft Entra IDOverviewManage tenants.
    4. Select the tenant and choose Delete.
    5. If all checks are still green, confirm Delete.

    This sequence specifically addresses the known issue mentioned in the notification: enterprise apps that cannot be deleted in the portal but can be removed or disabled using Microsoft Graph PowerShell, after which tenant deletion succeeds.


    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.