Since Azure AD B2C is being deprecated in 2030, I thought we could have a look at some things related to migration. Firstly, user migration. In an ideal situation, we would like the migration to be pretty much seamless for our users. But how can we achieve that? Microsoft recommends Entra External ID as the replacement for Azure AD B2C, so that’s what we will use as our migration target. But the overall processes described here can in theory be applied to any identity provider (depending on the IdP’s capabilities).
Note that we will not discuss High Scale Compatibility mode here. You can check it in the documentation, but it’ll only apply to you if you have close to 5 million objects or more in your Azure AD B2C tenant. HSC mode comes with limitations and feels like a bandaid solution to me when the real solution is to migrate away from the platform.
Migration stages
We would like our users to keep their existing passwords. But since Azure AD B2C stores passwords in a secure way, we cannot actually access the raw passwords that would allow us to migrate them easily. So what can we do?
Define extension property in Entra External ID
We need to know which users have completed migration. For this purpose, we can use an extension property. Microsoft Learn has quite a good example for this: https://learn.microsoft.com/en-us/entra/external-id/customers/how-to-migrate-users?tabs=graph#define-an-extension-property-for-tracking-migration-status.
This property will be used for local users only though. We will discuss federated users a bit later, but they will either be migrated or not, so there isn’t really a middle ground as with local users.
Azure AD B2C-initiated migration (local users only)
The stage I am about to describe only applies if you are using custom policies in Azure AD B2C. Unfortunately with user flows it is not possible to achieve this. This is Azure AD B2C-initiated migration.
This stage is not mandatory to do, but I find that increasing the window in which users can get their passwords migrated is a beneficial thing.
This is how we start copying user passwords to Entra External ID:
sequenceDiagram autonumber actor User participant B2C as Azure AD B2C participant API as Custom API participant EEID as Entra External ID User->>B2C: Login / Signup / SSPR B2C->>B2C: Check password B2C->>API: POST /sync-password API->>EEID: Create/update User, set toBeMigrated false User->>B2C: Continue as normal
In practice, you will need to use a validation REST technical profile in the custom policy’s self-asserted profile that is handling the user password (after the regular password validation profile). Password claims in custom policies are special in that they cannot be passed from one step to another, so you have to handle it within the validation stage. That REST profile will call an API that you have setup, and it will then pass the password to Entra External ID through Graph API. Once this is deployed, any users who enter their password will have it synced to Entra External ID, and will be able to use the same password from the start.
Bulk migration
This stage applies to all kinds of users and whether or not you use user flows or custom policies. Here, we just want to take all the users in our Azure AD B2C tenant and put them in the new Entra External ID tenant.
For this, check out the Azure AD B2C to Entra External ID Migration Kit. It has a Simple and Advanced mode for bulk migration, depending on your user amount and if they have MFA phones or not (MFA phones require a second Graph API request with stricter throttling).
Federated users
If you have users whose password is not stored in Azure AD B2C and sign in with a different identity provider, those users are federated. Migrating them can be possible, as long as the unique user ID remains the same and you are able to configure the IdP in Entra External ID.
If both of those apply, you should be able to handle them in the bulk migration as well.
You’ll need to define the federated identity provider in Entra External ID and create users through Graph API with the same issuerUserId value in identities for the user. Note the issuer value could be different. Also remember to add redirect URIs for Entra External ID in the federated IdP.
Azure AD B2C (custom policies especially) are quite a bit more customizable than Entra External ID identity providers, so you may run into issues with configuring them. I personally find the experience for configuring OIDC providers in Entra External ID as awful. SAML/WS-Fed works pretty well though.
JIT migration (local users only)
Just-in-time (JIT) migration is kind of the reverse of the Azure AD B2C-initiated migration. Here we have the Entra External ID tenant send passwords to validate them with Azure AD B2C on login.
sequenceDiagram autonumber actor User participant EEID as Entra External ID participant API as Custom API participant B2C as Azure AD B2C User->>EEID: Log in EEID->>EEID: Check toBeMigrated flag EEID->>EEID: Encrypt username and password EEID->>API: Send encrypted token API->>API: Decrypt token API->>B2C: Validate username + password with ROPC B2C->>API: 200 OK with valid tokens API->>EEID: 200 OK EEID->>EEID: Store password EEID->>User: Continue
The password migration authentication extension configuration includes the extension property ID that contains the flag to check if the user needs to be migrated. Entra External ID will only call the authentication extension if the extension property contains the value true.
Entra External ID will encrypt the username and password used by the user with a public key provided by you. The samples in the docs use a certificate in Key Vault, but ultimately Entra External ID only needs the base64 encoded public key, so you can store it anywhere secure that works for you.
The process for configuring everything on Entra External ID side is explained pretty well in the docs: https://learn.microsoft.com/en-us/entra/external-id/customers/how-to-migrate-passwords-just-in-time#stage-3-configure-custom-extension-application.
For validating the password with Azure AD B2C, you need to use the Resource Owner Password Credentials (ROPC) flow. This is one of the scenarios where its usage is really the only option.
Summary
If you go through all of these stages, you should be able to get most of your users’ credentials migrated to Entra External ID. For all the local users who do not access the application in the migration period, they will be forced to go through a password reset to regain access.