Define custom attributes in Azure Active Directory B2C
Every customer-facing application has unique requirements for the information that needs to be collected. Your Azure Active Directory (Azure AD) B2C tenant comes with a built-in set of information stored in attributes, such as Given Name, Surname, City, and Postal Code. With Azure AD B2C, you can extend the set of attributes stored on each customer account.
You can create custom attributes in the Azure portal and use them in your sign-up policies, sign-up or sign-in policies, or profile editing policies. You can also read and write these attributes by using the Azure AD Graph API. Custom attributes in Azure AD B2C use Azure AD Graph API Directory Schema Extensions.
Create a custom attribute
- Sign in to the Azure portal as the global administrator of your Azure AD B2C tenant.
Make sure you're using the directory that contains your Azure AD B2C tenant by switching to it in the top-right corner of the Azure portal. Select your subscription information, and then select Switch Directory.
Choose the directory that contains your tenant.
Choose All services in the top-left corner of the Azure portal, search for and select Azure AD B2C.
- Select User attributes, and then select Add.
- Provide a Name for the custom attribute (for example, "ShoeSize")
- Choose a Data Type. Only String, Boolean, and Int are available.
- Optionally, enter a Description for informational purposes.
- Click Create.
The custom attribute is now available in the list of User attributes and for use in your policies. A custom attribute is only created the first time it is used in any policy, and not when you add it to the list of User attributes.
Use a custom attribute in your policy
- In your Azure AD B2C tenant, select Sign-up or sign-in policies.
- Select your policy (for example, "B2C_1_SignupSignin") to open it.
- Click Edit.
- Select Sign-up attributes and then select the custom attribute (for example, "ShoeSize"). Click OK.
- Select Application claims and then select the custom attribute. Click OK.
- Click Save.
You can use the Run now feature on the policy to verify the customer experience. You should now see ShoeSize in the list of attributes collected during the sign-up journey, and see it in the token sent back to your application.