'Configuration in Azure AD B2C for Custom Policies

How do I use a "config file" in custom policies? Like appsetting.json in ASP.Net Core.

Things to configure


Background: we have multiple B2C tenants for each environment (Local, Dev, QA, Prod, etc.). We need to promote the custom policies from Local -> Dev -> .... As it stands now, we have to modify the policies when promoting.

I'm hoping there is something like pulling Keys from the B2C app.



Solution 1:[1]

If you are using Visual Studio Code, the Azure AD B2C extension can do this for you using an appsettings.json file.

Here is a quote from the extension page in the Policy Settings section:

When you execute the B2C Policy build command, the VS Code extension finds and replaces the values of your settings with the ones configured in the policy file, and creates a directory that contains all of your policy files (after the replacement).

Solution 2:[2]

The VS Code extension does support this. You can add as many settings under PolicySettings as you would like to.

{
    "Environments": [
        {
            "Name": "...",
            "Production": true,
            "Tenant": "...",
            "PolicySettings": {
                "ProxyIdentityExperienceFrameworkId": "...",
                "LoadUri": "https://myhosted/template",
                "somekey" : "some value"
            }
        }
    ]
}

You reference it using {Setting:LoadUri-signuporsignin}, do not include PolicySettings. Extensions description

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Andy Garcia
Solution 2