Gais
Gais

Reputation: 575

Moving Azure AD B2C custom user attributes across new environments

I've created a 'customerId' user attributes in my development AD B2C tenant. When querying these via the graph API I now get the following;

"extension_b0ba955412524ac8be63e24fa7eb0c23_customerId": "2"

Perfect! I use JSON.Net to convert this to a strongly typed object, and hence my POCO has the following property.

public string extension_b0ba955412524ac8be63e24fa7eb0c23_customerId { get; set; }

Not great, but I can live with it. My concern is that when I create these properties in our staging and production environments, the attribute names will change and I will have to rewrite a lot of code. How do I migrate these user attributes to our other environments, ensuring the property names do not change?

Upvotes: 1

Views: 424

Answers (1)

Saca
Saca

Reputation: 10656

Custom user attributes in Azure AD B2C will always have a guid in the name that's unique per Azure AD B2C tenant.

This guid is the Application ID of the 'b2c-extensions-app' and will be the same for all custom attributes within a tenant, but different across tenants.

Given this behavior, you could make the code that handles custom user attributes dynamic such that it derives the full name* using the following pattern:

extension_<appId>_<attributeName>

And obtain the appID via the Graph:

https://graph.windows.net/yourtenant.onmicrosoft.com/applications?$filter=displayName eq 'b2c-extensions-app'

Of course, you can always provide feedback requesting that this is made easier in in the Azure AD B2C feedback forum.

Upvotes: 2

Related Questions