DEV Community

Christos Matskas for The 425 Show

Posted on

5

Delete an Azure AD B2C tenant programmatically

There are many cases where you may want to programmatically delete an Azure AD B2C instance programmatically. Luckily, most of what we need to do is doable via MS Graph APIs. Quick reminder that MS Graph may not be available for client accounts that use B2C to sign up/in but it's available to admin accounts and can be used to automate or manage a B2C tenant. With that in mind, we're good to go!

Prerequisites

  • .NET Core (3.1 or later)
  • VS Code
  • An Azure AD B2C tenant

Necessary steps

Unlike other Azure Resources, Azure AD and B2C require more work to be deleted. When attempting to delete a B2C tenant, the portal present us with a list of actions that need to be completed before we're allowed to blast the resource off the face of the earth. Example below:

Alt Text

Alt Text

Subsequently, we will be tackling these one at a time and in most cases, there will be an associated video stream to show you how we went about it. If you don't want to see me and JP struggling through the process, you can jump straight to the blog post and code repository:

  • Delete all users in an Azure AD Tenant
  • Delete all app registrations in an Azure AD Tenant
  • Delete all associated Azure subscriptions in an Azure AD Tenant
  • Delete all identity providers in an Azure AD Tenant
  • Delete all user flows in an azure AD Tenant

As always, reach out to us if you have any questions and don't forget to join our Discord

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay