Migrate from Azure AD B2C to Keycloak: what the move involves
If your organization runs an Azure AD B2C tenant with user flows, custom policies and social sign-in in production, the move to Keycloak is a re-implementation of your authentication flows plus a user data export, not a lift-and-shift. Effort depends mainly on how complex your custom policies are, how passwords are stored and can be moved, and how many applications rely on the tenant. Treat it as a planned project with its own scope, not a configuration change.
The timing is set by Microsoft's published dates. Effective May 1, 2025, Azure AD B2C is no longer available to purchase for new customers, and existing customers can keep using it. Azure AD B2C P2 is discontinued for all customers from March 15, 2026, and P2 tenants were switched to P1 by the end of March 2026. Microsoft says it will support Azure AD B2C until at least May 2030. That gives you room to choose a migration window instead of reacting to a deadline, so confirm your current tier and contract terms with Microsoft and the Azure AD B2C FAQ before you set a plan.
Plan for two kinds of work. The first is rebuilding sign-up, sign-in, password reset and profile edit as Keycloak authentication flows, and translating each custom policy's claims, conditional logic and identity provider steps by hand, since no automated converter is supplied for this. The second is exporting users. Microsoft points to the Microsoft Graph API as the route for writing a user migration tool and says Microsoft Entra Connect is not designed for Azure AD B2C, so ask your team early whether password hashes can be read out or whether you will need forced resets or a gradual migration at login. Inventory every application, redirect URI and social provider now, because those lists decide the cutover order.
Which Azure AD B2C features map cleanly to Keycloak
This table compares common Azure AD B2C capabilities with their closest Keycloak equivalents and flags where the match is partial or needs redesign. Read the right-hand column as a starting hypothesis, not a confirmed match, because behavior depends on how your own tenant and policies are configured. The main takeaway is that custom policies are a redesign task, not a copy task.
| Azure AD B2C feature | Keycloak equivalent | Mapping status |
|---|---|---|
| User flows (sign-up and sign-in, password reset, profile edit) | Authentication flows, required actions and account console pages | Partial. Built-in flows have close equivalents, but each step and its conditions must be rebuilt and tested. |
| Custom policies written in XML | Custom authentication flows plus SPI providers written in Java | Does not map one to one. Each policy must be redesigned, and logic beyond standard steps needs custom code that you maintain. |
| Local accounts (email, username, password) | Realm users with password credentials and password policies | Mostly maps. Confirm how your tenant stores sign-in identifiers and whether password hashes can be exported. |
| Social identity providers | Identity brokering with social providers such as Google, GitHub, Microsoft and Facebook | Maps for listed providers. Confirm each provider's claims, scopes and app registration on the provider side. |
| MFA and phone or email verification | OTP policies, WebAuthn, passkeys and recovery codes in authentication flows | Partial. Confirm which second factors you use today and whether SMS delivery needs a separate provider. |
| Custom attributes and extension profiles | User attributes and user profile configuration | Partial. Attribute names, types and validation need explicit mapping, and some values may need custom storage. |
| API connectors (calls during sign-up or sign-in) | Custom authentication steps or event listeners implemented as providers | Does not map one to one. Each connector call becomes code you build, host and upgrade. |
| Token claims and custom claims policy | Client scopes, protocol mappers and token claim configuration | Mostly maps. Confirm claim names, token lifetimes and audience values that applications depend on. |
| Branding and page templates | Keycloak themes for login, account and email pages | Partial. Templates are rebuilt, and theme code must be retested after each Keycloak upgrade. |
How user accounts and password hashes move to Keycloak
The documented export path out of Azure AD B2C is the Microsoft Graph API. Microsoft points to Graph for teams writing their own user migration tools, and it states that Microsoft Entra Connect is not designed to work with Azure AD B2C, so do not plan around Entra Connect for this move. Your migration tool will read user profiles, identifiers and attributes through Graph, then write them into Keycloak realm users with the attributes your applications depend on. Before you commit to a design, confirm with Microsoft exactly what Graph returns for credentials in your tenant. Whether password hashes can be read at all determines which of the two paths below is available to you, and that answer should come from Microsoft's current documentation or support channel, not from assumptions carried over from other platforms.
If Graph does not return usable password data, the simplest path is a forced password reset at first sign-in. Users are imported with their profile data, flagged as needing a new password, and set one through Keycloak's normal flow. The cost is user friction and a window in which inactive accounts stay behind. This path also needs a verified reset channel, typically the email or phone attribute carried over from B2C, so confirm those attributes export cleanly before cutover. If the export does return hashes, you still need to confirm the algorithm and parameters Azure AD B2C used, because Keycloak must be able to verify them.
The alternative is a gradual migration at login through a custom user storage provider. Keycloak asks the provider to check the submitted password against the legacy source on the user's first sign-in, then stores a Keycloak-native credential. This avoids a mass reset but adds custom code that you must build, test, secure and maintain until every account has migrated or been retired. It also depends on the B2C tenant remaining reachable during the transition, so the decision on how long the old tenant stays available is a business and cost question as well as a technical one. Ask your implementation partner to document the provider's dependencies and its shutdown criteria in the scope before work begins.
Rebuilding user flows and custom policies as Keycloak authentication flows
Azure AD B2C built-in user flows cover sign-up and sign-in, password reset and profile editing, configured largely through the portal. In Keycloak, the closest counterpart is the set of browser and registration flows inside an authentication flow, together with the realm's login settings such as registration, forgot password and email verification, and the account console for profile editing. The mapping is conceptual rather than one-to-one, so the rebuild starts by writing down exactly what each built-in flow does today, including attributes collected at sign-up and the claims returned to each application.
- Sign-up attributes: List every attribute collected at registration and decide whether Keycloak will store it as a user attribute, a required action or a value from an upstream identity provider.
- Password reset behavior: Confirm the reset link lifetime, the email templates and whether the reset also clears sessions, then reproduce those settings in the realm and test them against your own policy.
- Profile editing: Identify which fields users may change themselves and which are read-only, and set user profile rules to match.
- Required actions: Map terms acceptance, MFA enrollment or forced password change to required actions or conditional steps in the flow.
- Token claims: Recreate the claims each application receives through protocol mappers, then compare token contents for every client.
Check each built-in flow against a written list of user journeys, because undocumented behavior is the most common source of gaps after cutover.
Azure AD B2C custom policies are XML-based Identity Experience Framework definitions. They often hold claims transformations, validation logic, conditional branching and REST API connectors that call your own services during sign-in. Keycloak does not import these policies. The equivalent logic moves into authentication flows with conditional steps, protocol mappers and, where a REST call is needed, a custom authenticator or user storage provider written against the Keycloak SPI. This is custom engineering, and its effort depends on how much logic the policies contain.
- Claims transformations: Translate each transformation into a protocol mapper where a static or attribute-based mapping is enough, or into a custom mapper where it needs code.
- REST API connectors: Replace each connector with a custom authenticator or event listener, keeping the same timeout, retry and error handling behavior your applications depend on.
- Conditional branching: Rebuild branches as conditional flow steps keyed on user attributes, roles or the client, and document each branch.
- Secrets and endpoints: Move any keys, client secrets and endpoint URLs out of policy files and into a managed secret store before the custom code goes live.
- Build and upgrade cost: Custom providers must be rebuilt and retested when Keycloak is upgraded, so record the number of providers as part of the upgrade plan.
Ask for an inventory of every policy file, connector and transformation, and confirm which of them your applications actually depend on before estimating the rebuild.
Azure AD B2C social sign-in uses identity providers configured on the tenant, such as Google, Facebook or Microsoft accounts. In Keycloak, these are configured as identity providers under the realm. The Keycloak administration guide documents social providers including Google, GitHub, GitLab, Microsoft, Facebook, LinkedIn, PayPal and Twitter. Each provider needs its own client registration with the upstream service, redirect URIs that point to the Keycloak broker endpoint, and attribute mappers that decide what user data is imported. Support for every provider you use should be confirmed against the current documentation and your own test accounts.
- Upstream app registrations: Create or update the OAuth or OIDC client for each provider and register the new Keycloak redirect URI before the cutover window.
- First broker login flow: Decide how a social login links to an existing account, for example by asking for verification or by reviewing the email match, and configure the first broker login flow accordingly.
- Attribute mappers: Map the claims each provider returns into the user attributes and tokens your applications expect, and test with accounts that lack optional fields.
- Account linking: Plan how users who signed up with a social account in B2C are linked to their Keycloak identities, because existing subject identifiers will change.
- Provider coverage: Confirm that each provider you rely on is listed in the current documentation and that its terms allow the way you use it.
Check the sign-in journey for each social provider end to end, including first login, repeat login, account linking and failure cases, before scheduling the user cutover.
Migration sequence: inventory, pilot, parallel run, cutover and decommission
This sequence moves identity for each application from Azure AD B2C to Keycloak in controlled stages, so every application is proven on Keycloak before the B2C tenant is retired.
Inventory tenants, policies, applications and providers
Your team and the migration lead list every B2C tenant, user flow, custom policy, application registration, redirect URI, token claim, and social or external identity provider in use. Record which applications depend on each policy and which user attributes they read. The step is done when the inventory has one owner per application and every redirect URI and claim is traced to a consuming system. Confirm the tenant's plan and license status with Microsoft before you start, since the B2C FAQ documents recent changes to purchasing and P2 availability.
Build production-grade Keycloak foundation
Deploy Keycloak in the infrastructure you control on a supported production database, with TLS on all communication and a reverse proxy in front. Expose the admin console and Administration REST API on a different hostname or context path from public frontend URLs, and enable metrics for monitoring. The step is done when the node starts against the production database, serves HTTPS through the proxy, and passes your own health and login checks. Do not use the development file database for any step after the pilot.
Pilot one application on a non-production realm
Create a separate non-production realm and rebuild the login path for one low-risk application using Keycloak authentication flows and an OpenID Connect client. Replace any custom policy logic with flow configuration, and map the claims the application reads. The pilot is complete when a test user can sign in, the application receives the expected claims, and logout behaves as the application expects. Record every behavior difference so the team can decide which ones are acceptable before the production build.
Export users and import them into Keycloak
Export user profiles through Microsoft Graph using a migration tool your team or DeployOpen writes against the Graph API, since Microsoft recommends this route and does not support Microsoft Entra Connect for B2C. Import profiles, attributes and group memberships into the production realm, then confirm the counts and a sample of records against the source. Plan how passwords will be handled, because the export path determines whether credentials move or users reset at first login. The step is done when imported records reconcile with the export and the reconciliation report is signed off.
Run both identity systems in parallel
Keep the B2C tenant serving existing applications while the migrated applications sign in through Keycloak. Synchronize changes that occur during the parallel period, such as new registrations or profile edits, or document the rule that limits writes to one system per application. Monitor sign-in success, token errors and support tickets on both sides. The step is done when the team has a documented rule for which system is authoritative for each user population and no unresolved sign-in defects remain on the pilot.
Cut over applications one at a time
Move each application separately by registering its Keycloak client, adding the new redirect URIs, and switching token validation to the Keycloak issuer and keys. Keep the previous B2C registration available until the application has run successfully on Keycloak, so a rollback is possible. Test sign-in, token refresh and logout in each cutover window. The step is done for an application when its production traffic validates tokens from Keycloak and its B2C registration is marked for removal.
Decommission the B2C tenant
After the last application has moved and the parallel period has closed, disable B2C sign-in, archive the policy definitions and export logs that your audit or retention rules require, and remove application registrations. Then retire the tenant according to your records policy and confirm that no remaining system or scheduled job calls B2C endpoints. The step is done when a final check shows zero B2C sign-ins for a period your security team sets, and the decommission record is filed with the identity and compliance owners.
How applications move from Azure AD B2C to Keycloak during cutover
The diagram starts with applications still signing users in through Azure AD B2C. A Microsoft Graph export feeds user data into Keycloak, which brokers or verifies logins during the transition while each application is switched over one at a time. The B2C tenant is decommissioned only after the last application has moved. Check that every application has a tested Keycloak client and that the export and password handling plan are settled before the first cutover wave.
Parallel run from Azure AD B2C to Keycloak, ending with tenant decommissioning.
Documented export and import paths for this move
Four routes connect Azure AD B2C to Keycloak, and each one moves different things: user data, realm configuration or login behavior. Most migrations combine two or three of them, so the choice depends on what must move and when. Confirm each route against current vendor documentation before you commit to a design.
Microsoft Graph user export
Microsoft's FAQ points to the Microsoft Graph API as the route for writing a user migration tool for Azure AD B2C. Your tool reads profile attributes from the tenant and writes them to Keycloak users, so it is the only documented route for pulling users out of the B2C tenant. Confirm the export format, the Graph permissions your app registration needs and whether password data can be read at all before you design the import.
Azure AD B2C FAQKeycloak realm import
A realm export file or a realm import through the Keycloak admin tooling recreates realm settings, clients, roles and users in a target realm. It suits a repeatable test import of the migrated user set and client configuration. Check that the file you feed it matches the Keycloak version you run, because the import format is tied to the server release.
- Current Keycloak release
- 26.8.1
KeycloakRealmImport in the Operator
If your team runs the Keycloak Operator, the KeycloakRealmImport custom resource applies realm definitions as declarative configuration. Keep the realm, client and identity provider resources in version control so each environment imports the same definition. Review the Operator documentation for which fields it manages and how it handles resources that already exist.
Keycloak Operator docsAdmin REST API and configuration as code
The Keycloak Administration REST API lets a script create users, clients, flows and identity providers, which is useful when the B2C custom policies are rebuilt as code. Pair it with the Operator's KeycloakOIDCClient resource to keep client registrations under change control. Test each call in a non-production realm first, since bulk user creation through the API does not replicate B2C password hashes.
Keycloak admin docsUser storage provider for gradual migration
A custom user storage provider can look up users in a source store at first login and copy them into Keycloak. This is the usual fallback when password hashes cannot be exported, because the user proves their password against the old source at sign-in. Plan for the provider to be written, tested and removed once no application still depends on the old tenant. Ask your Keycloak partner or internal team to confirm whether B2C can serve as that source in your tenant configuration.
What drives the cost and duration of an Azure AD B2C migration
This table lists the factors that move the effort of an Azure AD B2C to Keycloak migration, whether each one is paid once or recurs, and what to request in a written quote. Read it as a checklist for scoping: the more of these items your tenant uses, the more the quote should itemize. Custom policies, password strategy and the number of applications are usually the largest drivers.
| Driver | Why it changes effort | One-time or recurring | Ask for in the quote |
|---|---|---|---|
| Custom policies and user flows | Each custom policy (XML-based Identity Experience Framework) must be rebuilt as Keycloak authentication flows, claims transformations and custom providers where needed. Complexity grows with branching and API connectors. | One-time | Inventory of every policy and user flow, with a mapping to target flows and a list of custom code to rewrite |
| Number of applications and SDKs | Each relying application needs its redirect URIs, client settings and token handling moved to OpenID Connect. Older Microsoft authentication libraries may need replacing. | One-time, with recurring upkeep when apps change | Per-application cutover plan, client list and the library changes each app needs |
| Password migration strategy | Azure AD B2C does not export password hashes, so the choice between a forced reset, gradual migration at login or a custom verification step changes the build and the user communication work. | One-time | Chosen strategy in writing, with the number of users affected and the support load assumed |
| Social identity providers | Each social provider needs its own client registration, redirect configuration and attribute mapping. Account linking rules for users who sign in with several providers add testing. | One-time setup, recurring if providers change | Provider list, linking rules and who holds the provider app registrations |
| Custom attributes and claims | Custom user attributes and token claims must be mapped to Keycloak user attributes and protocol mappers. Attribute types and required fields affect export and import. | One-time | Attribute and claim dictionary with source, target and validation rules |
| MFA methods | Each second factor (for example one-time passwords, passkeys or SMS-based methods) has its own enrollment, recovery and policy design. Enrollment of existing users is often the hardest part. | One-time design, recurring if methods are added | MFA methods in scope, enrollment approach for existing users and recovery procedure |
| Branding and user-facing pages | Login, registration, password reset and email templates must be rebuilt as Keycloak themes. Heavily customized pages take longer to match and test. | One-time, with recurring cost at each Keycloak upgrade | Page inventory, branding assets and the theme maintenance expected after upgrades |
| Environment count | Development, test and production each need realm configuration, secrets and user data handling. Keeping environments aligned is recurring work until cutover. | One-time per environment, recurring until retired | Number of environments, configuration-as-code approach and the sync process between them |
| Hosting, database and high availability | The chosen hosting platform, supported production database and high availability design (single cluster, multi-cluster or other) determine build, testing and operating effort. Keycloak requires a supported database, and high availability designs need a synchronously replicated database. | One-time build, recurring operations and patching | Hosting target, database engine and version, availability design, backup and disaster recovery scope, and who runs patching |
What usually goes wrong in B2C to Keycloak migrations and how to prevent it
Most failed B2C to Keycloak moves do not fail on the server itself. They fail at the edges: users who cannot sign in on day one, applications that receive different tokens, and policies nobody wrote down. Each risk below has a check you can run before cutover.
Password hashes that do not move
Azure AD B2C does not hand over password hashes in a form Keycloak can verify, so users usually cannot keep their existing passwords after migration. Decide early between a forced reset for all users and a gradual migration at login, and tell support staff which one applies. Test the reset email path before any user is affected, because a forced reset that fails to deliver locks people out.
Token claim changes break applications
Keycloak issues tokens with its own claim names, audiences and subject values, which often differ from the B2C tokens your applications were built against. Compare decoded tokens from both systems for each client, including the sub value, custom attributes and roles. Fix mismatches in the mapper configuration or the application before the redirect cutover, not after users report errors.
Redirect URI and logout mismatches
Keycloak matches redirect URIs and post-logout redirect URIs exactly as configured, so a missing trailing slash or an old B2C reply URL will stop sign-in. Export every B2C application registration, list its reply and logout URLs, and create the matching Keycloak clients in a staging realm. Test sign-out from each application, since single sign-out gaps are easy to miss in a login-only test.
Social provider consent and mapping differences
Social sign-in through Google, Microsoft or other providers returns different attributes in Keycloak's identity brokering than in B2C, and consent screens and scopes may differ. Confirm the scopes each provider needs, check which email and name attributes Keycloak maps, and decide how to link an existing B2C account to a social identity without creating duplicate users. Ask the provider owner to register the new Keycloak redirect URI.
Backchannel logout validation in Keycloak 26.8
Keycloak 26.8 requires signature validation for backchannel logout tokens from external providers, so a brokered identity provider that sends unsigned or incorrectly signed logout tokens will fail. Before upgrading or enabling the feature, list every external provider that sends backchannel logout, confirm its signing keys are configured, and test a logout event end to end. Plan this check alongside the SMTP changes below, since both are 26.8 upgrade items.
Keycloak upgrade notesReset emails that never arrive
Keycloak 26.8 enforces SMTP StartTLS without plaintext fallback, so a mail relay that previously accepted unencrypted connections will stop delivering password reset and verification emails. Confirm with your mail team that the relay supports StartTLS, send test messages from the Keycloak realm settings, and check the server logs for delivery errors. Without working email, a forced password reset becomes a support queue.
An incomplete inventory of B2C policies
Custom policies often hold logic that is not visible in the user flow list: claims transformations, conditional redirects, API connectors, and branding tied to specific applications. Export every user flow and custom policy XML file, then map each step to a Keycloak authentication flow, required action or identity provider mapper. Record anything without a Keycloak equivalent as a decision for the business owner before build starts.
Questions teams ask before moving off Azure AD B2C
What does the effort of moving off Azure AD B2C depend on?
The effort depends mostly on how much of your B2C setup is custom. The main drivers are the number of user flows and custom policies, how many applications and APIs rely on B2C tokens and claims, how many social and local sign-in paths you run, and how many user records need to move. Custom policies usually take more analysis than built-in user flows because their logic must be re-expressed as Keycloak authentication flows and mappers. Your team should inventory each application's redirect URIs, token validation code and claim expectations before any estimate is meaningful. Ask any partner to base a quote on that inventory rather than on a headcount assumption.
Can our own team move off Azure AD B2C without a partner?
A capable identity team can do the work in-house, provided it has time to learn Keycloak's realm, client and authentication flow model and can test every application end to end. The work is not only configuration. It includes user export through Microsoft Graph, a plan for passwords, social provider re-registration, token and claim changes in each application, and a parallel run before cutover. Microsoft points to the Microsoft Graph API for writing user migration tools for Azure AD B2C and notes that Microsoft Entra Connect is not designed for B2C, so the export tooling is custom work either way. Teams that lack spare capacity often bring in a fixed-scope partner for the migration and keep operations in-house afterward.
How long does a move from Azure AD B2C to Keycloak take?
No general duration is published here, and the answer depends on the factors above: the number of flows, applications and users, the password approach you choose, and how much testing your applications need. A simple tenant with one application and built-in flows is a very different project from a tenant with many custom policies and regulated applications. Plan in phases: discovery and inventory, a Keycloak build with test realms, user export and import rehearsal, application cutover in waves, and decommissioning. Ask for a timeline that lists each phase, the owner of each dependency, and the test evidence that closes it. Keep in mind that Azure AD B2C remains supported until at least May 2030, so the deadline is usually set by your own roadmap rather than by Microsoft.
Can user passwords be migrated from Azure AD B2C to Keycloak?
Whether passwords can move depends on what your B2C export returns and what Keycloak needs to verify it, so confirm this against your own tenant before you commit to a design. Microsoft's B2C documentation describes the Microsoft Graph API as the route for user migration tooling, and your export tooling must be tested against the fields it actually returns. If password hashes cannot be exported in a form Keycloak can verify, the common alternatives are a forced password reset at the next sign-in or a gradual migration in which the old system verifies credentials at login. Each option changes user experience, support load and the length of the coexistence period, so decide it with the business owners early.
What does the migration need from our team?
The project needs three kinds of access and time from your team. First, administrative access to the B2C tenant and its app registrations, so the export can run and the existing configuration can be documented. Second, application owners who can describe each app's sign-in behavior, token use, claims and logout, and who can schedule a test window. Third, a set of test users covering each sign-in path, including local accounts, each social provider, password reset, profile edit and any step-up or MFA flow. Name a decision owner for password handling and for the cutover date, because those choices affect every application. Without these people in place, testing becomes the bottleneck.
Does Microsoft still support Azure AD B2C, and until when?
Yes. Effective May 1, 2025, Azure AD B2C is no longer available to purchase for new customers, but existing customers can keep using it. Microsoft says it will support Azure AD B2C until at least May 2030. Separately, Azure AD B2C P2 is discontinued for all customers from March 15, 2026, and P2 tenants were switched to P1 by the end of March 2026. If your tenant was on P2, confirm your current license and feature set in the Azure portal, because any custom features you relied on may have changed. Read the current Microsoft FAQ for the authoritative wording before you set a deadline.
What does a fixed-scope DeployOpen engagement cover for this migration?
A fixed-scope engagement covers the work agreed in writing before it starts, and the scope, deliverables and timeline are fixed in that document. For this migration, a typical written scope lists the tenant inventory, the target Keycloak deployment, the rebuilt authentication flows and social providers, the user export and import approach, the application changes for each agreed application, the test plan and the cutover runbook. It should also say what is excluded, such as application code changes owned by your developers or decommissioning of the B2C tenant. Ask for the scope to name each application in writing and for every deliverable to have an acceptance test. The quote follows from that written scope, and DeployOpen does not publish a price list.
How DeployOpen scopes and delivers a B2C to Keycloak migration
DeployOpen plans, implements, customizes, integrates, hardens, documents and supports self-hosted open-source platforms inside your own infrastructure. For this migration, we start from a written scope covering your tenant, user flows, custom policies, social providers and applications, then build and verify Keycloak in your environment before cutover.
How we scope
- Inventory every user flow, custom policy, app registration and social identity provider in your Azure AD B2C tenant.
- Agree in writing which applications move to Keycloak, which stay on B2C during transition, and how sessions are handled.
- Confirm how user export through Microsoft Graph, password handling and user communication will work for your user base.
How we build
- Rebuild user flows and custom policy logic as Keycloak authentication flows, with MFA and passkey choices documented.
- Configure social identity providers and attribute mappings, and test sign-in for each provider before any user moves.
- Deploy Keycloak in your cloud account or data center with TLS, a reverse proxy and separated admin hostname.
How we hand over
- Deliver a migration runbook with export scripts, import steps, rollback steps and the cutover sequence for each application.
- Provide a test report covering sign-in, token claims, logout and the account recovery paths your users depend on.
- Document configuration, realm settings and operating procedures so your own team can run the Keycloak instance after handover.
How we support
- Support after cutover can be arranged as a retainer covering patching, upgrades and continuous testing.
- Upgrades to later Keycloak releases can be planned and tested in a staging environment before production changes.
- Confirm with us during scoping which support hours, response expectations and upgrade scope your retainer will include.

