大网数据广告活动
域与目录服务

Can't delete a directory through the Azure Management Portal

· 52CE 我爱测

Fixes an issue in which you can't delete a directory from the Microsoft Entra extension.

This article can help you fix an issue in which you can't delete a directory from the Microsoft Entra extension in Azure portal.

Original product version:   Microsoft Entra ID
Original KB number:   2967860

Symptoms

You can't delete a directory from the Microsoft Entra extension through the Azure Management Portal. Additionally, you receive one of the following messages:

You are signed in as a user for whom <Your Company Name> is the home directory.

Delete all users except yourself.

Directory has one or more subscriptions to Microsoft Online Services.

Directory has one or more Azure subscriptions.

Directory has one or more applications.

Directory has one or more Multi-Factor Authentication providers.

Directory is a "Partner" directory.

Directory contains one or more applications that were added by a user or administrator.

You are signed in as a user for whom <Your Company Name> is the home directory

Make sure that your directory has no home users, and then delete the directory. The user who deletes this directory must be a guest user, must be homed in another directory, and must be a global admin of the directory that is being deleted.

For example, your directory has the domains contoso.onmicrosoft.com and contoso.com. There must be no users who have these domains in your directory. The guest user may be a Microsoft account or may be homed from another directory such as fabrikam.onmicrosoft.com.

To learn more about how to add a guest user, see Create or edit users. When you create this user in your directory, select one of the following:

  • A user who has an existing Microsoft account
  • A user in another Microsoft Entra directory

This user must also be an admin of your Azure subscription.

Delete all users except yourself

Do what the message tells you to do. That is, delete all users except yourself.

Directory has one or more subscriptions to Microsoft Online Services

Do you have one of the following subscriptions?

  • Office 365
  • Intune
  • Dynamics
  • Microsoft Azure Information Protection (previously known as Microsoft Azure Rights Management)
  • Microsoft Entra ID P1 or P2

If you have one of these subscriptions, contact billing and subscriptions support.

Do you have one of the following subscriptions?

  • Microsoft Enterprise Mobility + Security
  • Microsoft Entra Basic

If you have one of these subscriptions, contact your Volume Licensing partner to cancel the subscription.

Directory has one or more Azure subscriptions

If you have an Azure subscription, make sure that your Azure subscription is not linked to another directory. To do this, follow these steps:

  1. In the navigation pane, select Settings, and select Subscriptions.

  2. Notice the following information:

    • Subscription
    • Account administrator
    • Directory
  3. If the directory that you are trying to delete is listed under any of the subscriptions, the account administrator has to sign in and change the directory that is associated with the subscription. To do this, the account administrator should follow these steps:

    1. On this screen, select Edit Directory.
    2. In the Edit Directory window, select the Directory list, and then change the directory.

[!NOTE] If no other directory is available as an option, the account administrator must be a global admin of another directory or must create a new directory. You will see the Edit Directory option if the account is a Microsoft account. Organizational accounts can't change the directory. Therefore, the directory can't be deleted.

Directory has one or more applications

To learn how to remove applications from your directory, read Adding, updating, and removing an application

You may also have to remove additional service principals. Use Microsoft Graph PowerShell to remove all service principals:

  1. Install Microsoft Graph PowerShell.

  2. Run the Remove-MgServicePrincipal command to remove all service principals. This command requires at least the Application.ReadWrite.All permission. For more information, see Remove-MgServicePrincipal.

     Connect-MgGraph -Scopes "Application.ReadWrite.All" -tenant <tenant-ID>
     Get-MgServicePrincipal  | ForEach-Object { Remove-MgServicePrincipal -ServicePrincipalId $_.Id }
    

    [!NOTE] You may receive an error when you remove some service principals. These principals can't be removed. However, this does not prevent you from deleting your directory. The error that you receive may resemble the following:

    Remove-MgServicePrincipal: Specified App Principal ID is Microsoft Internal.

Directory has one or more Multi-Factor Authentication providers

Remove Azure multi-factor authentication providers for your directory. For information about how do this, see Plan an Azure Multi-Factor Authentication deployment.

Directory is a 'Partner' directory

Contact Microsoft Partner Support at Microsoft Partner Site.

Directory contains one or more applications that were added by a user or administrator

To fix this issue, follow the steps in "Cannot delete" error when you try to delete a B2C directory in Microsoft Entra ID.

Source: Microsoft Learn / IT Pro troubleshooting by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / IT Pro troubleshooting
适用范围
See source applicability · Source date 05/22/2020
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。