How to Delete Multiple Azure Active Directories and restore to original state? - azure

I have a Microsoft Azure pay-as-you-go subscription. When I first started to try Azure, I created a lot of trial directories and services. Now I would like to cleanup my account, but I am unable to delete the Active Directory because I am a user in that directory. How can I cleanup my azure and restore it to a first time use state?
The error message is:
User akisha#akisha.com is a Service administrator for subscription Access to Azure Active Directory and cannot be removed.

Firstly you should know the followings about deleting an Azure AD directory:
Only the user who has been assigned the "Global Administrator role" can delete the directory. By default, the user who signs up for Azure subscription will get this role.
Any other users in the directory except the global administrator should be deleted before you delete the directory. Any applications should be deleted as well.
You cannot delete the Azure AD directory on the Azure portal if there're still Azure subscriptions be associated with this directory.
A work and school account cannot delete his/her home directory (which the account be created in). Only the guest user (the external user added from another directory or the Microsoft account) can delete the directory.
Just think about the following two scenarios:
1. You use an work and school account (Azure AD account) to sign up for Azure
When you sign up for the Azure subscription, you already have an Azure AD directory which contains the default domain. Your sign up account will both be assigned the Service Administrator role for Azure and the Global Administrator role for Azure AD. In this case, you cannot delete this default directory because this is the home directory of that account.
2. You use an Microsoft Account(outlook, hotmail, etc) to sign up for Azure
In this scenario, this account is a guest user in the default directory (directory A) . Assume that he/she creates another directory lately (directory B). By default, the Azure subscription will be associated with the directory A and you cannot delete it as note above. However, you can change the associated directory to directory B on the Settings note (Azure classic portal). After doing this , you will be able to delete the directory A because the association has been removed.

I wrote a blog page on how to delete an active directory tenant. I have updated the process to use the new portal and the newer AzureAD PowerShell cmdlets.
https://blog.nicholasrogoff.com/2017/01/20/how-to-delete-an-azure-active-directory-add-tenant/
If you just want to clear out all the users, applications and other stuff then you can use PowerShell commands like
Get-AzureADGroup | Remove-AzureADGroup
Get-AzureADUser | Remove-AzureADUser
etc..
To fully remove the AD Tenant you do need to clear it out and my blog explains how to do this with Principals and Applications, but the principle is the same for all objects.

Related

How to Delete Azure Active Directory?

When I try to delete an Azure Active Directory I get this screen:
When I click on the link to enterprise applications, there are none:
How can I delete this Azure Active Directory?
You have to pass security checking first which make sure that anything on your directory won't impacts your current resource.
Prerequisite Of Deleting Directory:
Only an Azure Active Directory (Azure AD) global administrator can
delete an Azure AD directory from the portal.
There can be no users in the directory except one global
administrator who is to delete the directory
There can be no applications in the directory. Any applications must
be removed before the directory can be deleted
There can be no multi-factor authentication providers linked to the
directory
There can be no subscriptions for any Microsoft Online Services such
as Microsoft Azure, Office 365, or Azure AD Premium associated with
the directory
When you complete above steps then your delete option should look like below screen shot.
Note: Once you finish all the steps above. Only then you can be shown delete option active.other then it will remain inactive. For more details you can have a look this official docs

What Is The Difference Between An Azure Tenent, Azure Directory and Azure Active Directory?

Following on from this question, I don't understand what the difference between an Azure Tenant, Azure Directory and Azure Active Directory.
When I log in to Azure and click my profile it lets me Switch Directory.
In my case I can switch to my company directory and also to the directory of another company where I have guest credits.
Does Directory in this context mean the same as Azure Active Directory?
The documentation says a tenant is:
Azure tenant: A dedicated and trusted instance of Azure AD that's
automatically created when your organization signs up for a Microsoft
cloud service subscription, such as Microsoft Azure, Microsoft Intune,
or Office 365. An Azure tenant represents a single organization.
So is Tenant the same as Directory in this case as well?
Yes, in this case the tenant is the same as an Azure AD. In the Azure portal you are changing Azure Active Directories when you use the Switch Directory feature. You can currently only be in the context of a single directory at a time; however, as the previous question you pointed to indicates, multiple subscriptions can be tied to a tenant/directory. So when you are in the context of a directory you'll see all the subscriptions under that tenant to which you have access to one or more resources based on security.
To be fair, I use Azure AD Tenant/Azure AD Directory interchangeably. The Portal UI calls them directories; however, the properties on resources, REST APIs, CLI commands, etc. all refer to it as a tenant.
Directory == Tenant.
When you utilize azure services, the TenantId will be requested. The TenantId is non other than the DirectoryId which can be found in the Properties tab within Azure Active Directory.
Furthermore, as answered in the link you provided:
"Subscriptions are tied to tenants. so 1 tenant can have many subscriptions, but not vice versa."
Azure Active Directory is Microsoft’s cloud-based identity and access management service, which helps your employees sign in and access resources
Tenant is a digital representation of the organization. 
Azure Active Directory creating a directory objects in the form of tenant name. Azure Active Directory and tenants are interrelated.
In total, the Azure AD Tenant provides identity and access management (IAM) capabilities to applications and resources. 
Link : https://learn.microsoft.com/en-us/microsoft-365/education/deploy/intro-azure-active-directory#what-is-an-azure-ad-tenant

Azure DevOps and Azure Active Directory

I have the Azure DevOps organization called "Pay4it", which i want to connect to Azure Active Directory - I have treid to click "Connect directory", and a new window open and a error comes op:
We cannot find your account(jt#rc-pay4it.dk) in any Azure Active Directory. Please talk to the administrator of your company's Azure Active Directory to get your user account(jt#rc-pay4it.dk) added to that directory.
If i try to login into portal.azure.com with the username jt#rc-pay4it.dk it works fine, but still i have no Azure Active Directories in the dropdown.
I can't figure out what i'm missing, hopefully someone knows what i'm doing wrong.
I have attached a picture that shows the setup, the user created in Azure AD and that the user is owner of the organization in DevOps
The user who makes the connection must confirm the following statements are true.
User exists in Azure AD as a member. If the user is an Azure AD
guest, rather than member
User is a project collection administrator or owner of the
organization
User isn't using the Microsoft account identity that matches the
Azure AD identity. For example, if the Microsoft account that users
are currently using is jamalhartnett#fabrikam.com, the Azure AD
identity they'll use after connecting is also
jamalhartnett#fabrikam.com. Use a single identity that spans both
applications, rather than two separate identities using the same
email.
https://learn.microsoft.com/en-us/azure/devops/organizations/accounts/connect-organization-to-azure-ad?view=azure-devops#prerequisites

Managing Default Azure Directory

I signed up for an azure subscription and a default directory was provisioned for my subscription.
i cannot manage the default directory (e.g. create user or groups) via the azure portal. the portal replies with: "You do not have permission to access these resources."
while i understand that a admin role for an azure subscription is not the same as the admin role to manage an azure active directory; i am unable to find any MS guidance on how to assign the AD global admin role to my azure admin/subscription identity.
You have to be a Global Administrator in the directory to create users. Oddly though, you should already be one. When you sign-up for an Azure subscription you are automatically added to the default directory as a Global Administrator. At least that is how it used to work - perhaps it changed.
Anyway, this has the information you need and should get you going.

How to remove Azure Active Directory from Subscription

I can't seem to figure out how I can delete the tenant which I have created from my Azure Subscription. Can anyone help me figure out how to do this? It sounds like it should be easy to do, but maybe I'm missing something.
Currently you cannot remove AAD tenant from the Azure Portal. You also cannot rename it. The good thing is that you are not being charged for it if you are not using any special features (i.e. even if you use for just authenticating without the Two-Factor-Authentication it is still free!). And I don't recall to have seen an API via which you would be able to remove an AAD tenant.
UPDATE
As of November 2013 you are able to rename Azure AD, Add new Azure AD, change default AD for a subscription, delete Azure AD(as long as there is not subscription attached, and no user/groups/apps objects in it).
We were eventually able to delete an Azure Active Directory instance after we deleted all mapped users (except for the administrator who was logged in) and groups.
Make sure you go through the following list of possible causes for not being able to delete your Azure AD:
You are signed in as a user for whom <Your Company Name> is the home directory
Directory contains users besides 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.

Resources