The following forum(s) have migrated to Microsoft Q&A (Preview): Azure Active Directory!
Visit Microsoft Q&A (Preview) to post new questions.

Learn More

 locked
Cannot delete directory due to Office 365 Management APIs RRS feed

  • Question

  • Hello,

    I was having a play and created a Directory. I am trying to delete it, but it says it cannot be deleted because "Directory contains one or more applications that were added by a user or administrator.

    The directory hasn't been used, and I'm the only one to have logged in.

    In my Applications list I have "Office 365 Management APIs", I do not have an Office365 account. I tried using the MSOnline cmdlets but of course cannot connect without an account.

    I only have free Azure with my MSDN account and so cannot raise a technical support ticket.

    Any ideas please?

    Thank you 

    Russ

    Saturday, June 27, 2015 9:46 PM

Answers

  • First, from the Azure portal create a new "native" user in your directory. Make the user a Global Administrator, and make sure their username is of the form <something>@<something>.onmicrosoft.com.

    Next, sign in to Azure AD PowerShell with that new user account. (As you have noted, this is the step you couldn't do with your Microsoft Account.) Now you can follow the instruction for Method 5 in this support document: https://support.microsoft.com/en-au/kb/2967860/en-us?wa=wsignin1.0 :

        Get-MsolServicePrincipal | Remove-MsolServicePrincipal

    You'll probably get some failures because some of the applications simply can't be removed, but these shouldn't be affecting directory deletion anyway.

    Then try and delete it again.

    Sunday, June 28, 2015 4:19 AM

All replies

  • First, from the Azure portal create a new "native" user in your directory. Make the user a Global Administrator, and make sure their username is of the form <something>@<something>.onmicrosoft.com.

    Next, sign in to Azure AD PowerShell with that new user account. (As you have noted, this is the step you couldn't do with your Microsoft Account.) Now you can follow the instruction for Method 5 in this support document: https://support.microsoft.com/en-au/kb/2967860/en-us?wa=wsignin1.0 :

        Get-MsolServicePrincipal | Remove-MsolServicePrincipal

    You'll probably get some failures because some of the applications simply can't be removed, but these shouldn't be affecting directory deletion anyway.

    Then try and delete it again.

    Sunday, June 28, 2015 4:19 AM
  • Success!

    Thank you Philippe, very much appreciated.
    Sunday, June 28, 2015 2:11 PM
  • This doesn't work for me.  After doing this the Office 365 Management API's still shows in the Applications tab as a registered application.  But, there is no way to delete it from the Azure Portal.  Any other ideas on what might be the problem?
    Friday, July 17, 2015 7:34 PM
  • It didn't work for me either. Any ideas or updates?
    • Proposed as answer by T Cole Wednesday, September 9, 2015 1:19 PM
    • Unproposed as answer by T Cole Wednesday, September 9, 2015 1:20 PM
    Monday, July 20, 2015 12:33 PM
  • Did not work for me either.  Please help.
    Monday, August 10, 2015 8:59 PM
  • Thank you!

    It worked exactly as you described: Some erros showed up in the powershell, Application is still visible in the portal and after deleteing the global admin user the directory can be deleted.

    Saturday, August 15, 2015 11:32 AM
  • Didn't work for me also, and I followed this more explicit version of the solution: http://blogs.msdn.com/b/ericgolpe/archive/2015/04/30/walkthrough-of-deleting-an-azure-ad-tenant.aspx
    Thursday, August 20, 2015 3:51 PM
  • It worked for me, too. Thank you Philippe!
    Thursday, August 27, 2015 10:42 AM
  • It doesn't worked for me as well... 
    Tuesday, December 22, 2015 1:35 PM
  • Thanks very much. It worked for me as well.

    Regards, Kartikesh Nadar MCSA 2008, MCTS, VCP, ITILv3 -------------------------------------------------------------------------------- This posting is provided "AS IS" with no warranties, and confers no rights. | Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    Monday, January 18, 2016 12:04 PM
  • Did not work for me as well

    EDIT1

    So after following Philippe's suggestions above if you are still getting the same error, as I was getting, try this.

    When you select Applications tab on azure portal the default view shows "Application My Company Uses".   Select 2nd option from the drop down list "Application My Company Owns" and then click on check mark to search, and make sure there is no application listed there. if there is any delete it. and then delete the directory. ( Note that just changing option from drop down list doesn't invoke the search you have to click on the  checkmark button which is on right side :))


    • Edited by lax4u Thursday, April 7, 2016 3:41 PM
    • Proposed as answer by KredUp Tuesday, May 10, 2016 3:12 PM
    Tuesday, April 5, 2016 6:49 PM
  • Did not work for me as well

    EDIT1

    So after following Philippe's suggestions above if you are still getting the same error, as I was getting, try this.

    When you select Applications tab on azure portal the default view shows "Application My Company Uses".   Select 2nd option from the drop down list "Application My Company Owns" and then click on check mark to search, and make sure there is no application listed there. if there is any delete it. and then delete the directory. ( Note that just changing option from drop down list doesn't invoke the search you have to click on the  checkmark button which is on right side :))


    Thanks!
    Thursday, September 1, 2016 8:40 PM
  • Did not work for me - still showing O365 APIs and error when trying to delete

    Thursday, September 8, 2016 2:37 PM
  • In one subscription i have the same problem.

    If this answer help please mark it as a answer :) Thanks, Ricardo Cabral Se essa resposta ajuda por favor, marque-o como uma resposta :) Obrigado, Ricardo Cabral

    Saturday, February 4, 2017 6:11 PM