如何获取Azure AD B2C自定义策略声明转换方法完整支持列表?
I feel your pain—tracking down the full list of supported claim transformation methods for Azure AD B2C custom policies is surprisingly tricky, especially since older documentation like the one you referenced is out of date (and yes, AddParameterToStringCollection is indeed deprecated, which is exactly why your policy fails to import).
Unfortunately, Microsoft doesn’t publish a comprehensive public list of all valid methods, but here’s how you can get the most accurate, up-to-date information, plus a curated list of commonly used current methods:
1. Extract Methods from Built-in Policies
The most reliable source is the TrustFrameworkBase.xml file exported from your Azure AD B2C tenant’s built-in policy. This file uses only currently supported transformations, so you can scan through its <ClaimsTransformations> section to see valid methods. Here are some of the most frequently used ones you’ll find there:
AddItemToStringCollection: Replaces the deprecatedAddParameterToStringCollection—use this to add a parameter value to a string collection claimAssertBooleanClaimIsEqualToValue: Validates that a boolean claim matches a specified valueCreateStringClaim: Generates a new string claim with a static valueGetSingleItemFromStringCollection: Retrieves the first item from a string collection claimModifyClaims: Updates existing claims with new values or conditionsRemoveItemFromStringCollection: Removes a specific item from a string collection claimSetClaimIfEmpty: Sets a claim value only if it’s currently emptyStringReplace: Replaces substrings within a string claimConvertClaimToBoolean: Converts a claim value to a boolean typeConvertClaimToDate: Parses a string claim into a date typeConvertClaimToInteger: Converts a string claim to an integer type
2. Use Policy Import Error Messages
If you try to use an invalid or deprecated method, Azure AD B2C’s policy import error will often hint at valid alternatives. For example, when you tried AddParameterToStringCollection, the error message likely included a list of supported string collection transformations, pointing you directly to AddItemToStringCollection.
3. Reference Official Up-to-Date Samples
Microsoft’s official Azure AD B2C custom policy samples always use valid, current transformations. Check the claims transformation sections in these samples to see real-world usage of supported methods and confirm their syntax.
The key takeaway is that older methods like AddParameterToStringCollection have been replaced with more intuitive, consistent naming conventions. Always cross-reference with the latest built-in policies or official samples instead of relying on outdated documentation.
内容的提问来源于stack exchange,提问作者Ed Ilyin

