BULK DELETE AdB2C

Abhay Chandramouli 1,056 Reputation points
2022-09-15T10:08:33.447+00:00

hi I am trying to delete around 30 million users from adb2c.

I tried to bulk delete by uploading a file (csv) but seems max size is around 10mb or 50k records. That will take 600 uploades.. not feasabile
the other method is using graph api delete...

But is there a way this can be done quick ?

Microsoft Security | Microsoft Entra | Microsoft Entra External ID
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Vukasin Terzic 351 Reputation points MVP
    2022-09-15T11:36:25.967+00:00

    Hello @Abhay Chandramouli , as far as I know, there are no limitations in Azure AD for how many users you can remove at the time.

    You can check the service limitation page:
    https://learn.microsoft.com/en-us/azure/active-directory/enterprise-users/directory-service-limits-restrictions

    Depending on the method you are going to use to remove users, you might run into limitations that are specific to APIs or services.

    Please let me know if you have any additional questions. If this answer was helpful, please click on Select Answer.

    Thank you,

    Vukasin

    0 comments No comments

  2. Marilee Turscak-MSFT 37,206 Reputation points Microsoft Employee Moderator
    2022-09-15T21:19:33.873+00:00

    Hi @Abhay Chandramouli ,

    Thanks for your post!

    You are correct that the two well-documented options are bulk deleting by uploading a CSV or using Graph API with JSON batching to combine multiple requests in one HTTP call. The CSV option has the size limit you mentioned and JSON batching has a limit of 20 requests/users in batch. There are examples of the JSON batching implementation here.

    Another option would be to user Powershell and run the following script:

    Connect-MsolService #sign-in using Global Admin of your B2C tenant. User should be Member of the tenant and not signed-up or guest user.  
    $users = import-csv C:\temp\users.csv  
    foreach ($usr in $users)  
    {  
    Remove-MsolUser -UserPrincipalName $usr.upn -Force  
    }  
    

    I have shared your feedback with the product group though and will get back if they are able to recommend a better way to accomplish this or share a timeline for increasing the limit.

    -

    If the information helped you, please Accept the answer. This will help us and other community members as well.


Your answer

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