Can't Delete Azure Active Directory

Marlis Septian 6 Reputation points
2020-03-09T00:50:40.473+00:00

Hi Guys,

So I want to delete my azure AD lab environment, but everytime I want to delete the directory it's say that i need to delete all of my enterprise application. But, there are not any enterprise application listed.

When I create global admin user, the status of enterprise application is checked and now of course the Users status is uncheck cause there are still user in it.

Take a look at my screenshoot below.

  • Enterprise Application status in uncheck
    4051-b.png
  • There are no enterprise application
    4061-c.png
  • Now user is uncheck
    3954-asd.png

*Note : Why I'm creating the user again is cause I want to delete the enterprise application via power shell, but when I create the user the status for my enterprise application is check (means there are no application)

Microsoft Entra
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,597 questions
0 comments No comments
{count} vote

9 answers

Sort by: Most helpful
  1. Amitabha Roy Chowdhury 11 Reputation points
    2020-07-27T14:17:23.22+00:00

    What was the resolution to this problem? I am facing exactly the same situation.

    2 people found this answer helpful.
    0 comments No comments

  2. Anonymous
    2020-12-01T21:24:11.167+00:00

    Had this same issue. My solution for me was as explained by @soumi-MSFT - there are service principals which seem to get added to the tenant which block deletion. I logged into the Az PoSH module and issued the command Get-AzADServicePrincipal and you see them here.

    Problem is, some of these are not removable and give error: "Remove-AzADServicePrincipal: Specified App Principal ID is Microsoft Internal"

    The way I got around this was just to use: Get-AzADServicePrincipal | select Id | Remove-AzADServicePrincipal

    • this removed everything which could be removed. Now the 'Enterprise Applications' check passed okay and the 'Delete' button appeared. Just another warning, when I tried straight away I got error 'Unable to delete tenant' with no detail - but after about 2-4 minutes, I tried again and it deleted.
    2 people found this answer helpful.

  3. Iain Aitken 11 Reputation points
    2021-02-26T14:18:52.427+00:00

    Tip for anyone doing this - I had 105 items listed as Principals.

    If you have this:

    • Run the command Get-AzureADServicePrincipal as above
    • Copy the entire list from powershell by highlighting and ctrl+c
    • Paste into an excel sheet (Column A in excel)
    • In the next row (Column B) enter the formula: =LEFT(A1,FIND(" ",A1)-1) This deletes everything in the row after the first space, leaving just the object Ids.
    • Drag formula down to cover all rows
    • in the next row (Column C) enter the formula: =PROPER("Remove-AzureADServicePrincipal -objectid "&B1) This adds in the comand to delete them to the same line.
    • Drag formula down to cover all rows.
    • copy all of Column C and past into word as plain text so that it is not in a table.
    • Copy the entire word doc useing ctrl+A then ctrl_C
    • Right click in Powershell to paste. It will then work through deleting them all and show an error on the ones that cannot be deleted.

    Go back to your delete tenant page and delete.

    2 people found this answer helpful.

  4. soumi-MSFT 11,716 Reputation points Microsoft Employee
    2020-03-09T05:17:13.433+00:00

    MarlisSeptian-3433, Make sure you dont have any Enterprise apps or Users in your tenant [Except the Global Admin of that tenant]. If there are any other user left in the directory apart from the Global Admin, this Status would come up and you will have to delete your user in AAD first, before deleting the Directory, or you will get a message saying you cannot delete the directory, because you have one or more users.

    Try refreshing the page or navigate to the AAD home page and the get back to the delete Directory page and this time the check for directory deletion should pass and you would be able to see the "Delete" button at the end of screen.

    Also, if you would want to delete the Applications under Enterprise Apps section using Powershell, you can try to follow the steps below:

    1. Go to https://www.powershellgallery.com/packages/AzureAD/ to get the latest powershell Azure AD module
    2. Start Powershell and run:
      Install-Module -Name AzureAD
    3. Once done run:
      Connect-AzureAD
    4. You will be prompted to login, login with the user you created and will be asked to change your password:
    5. You should now be able to list all the current application SPs in a directory:
      Get-AzureADServicePrincipal
    6. Now, delete all non-required apps in the tenant directory, for me it was the Microsoft Visual Studio Team Services.
      Remove-AzureADServicePrincipal -objectid [enter object id here]

    Hope this helps and do let us know if this helps and if there are any more queries around this, please do let us know so that we can help you further. Also, please do not forget to accept the response as "Answer"; if the above response helped in answering your query.


  5. Marlis Septian 6 Reputation points
    2020-03-12T01:03:16.893+00:00

    Any solution guys?

    0 comments No comments