What is the recommended way of automating the configuration of an Azure AD B2C instance, e.g. configuration of policies, application registrations, maybe even creating initial accounts?
- Is it possible to use an ARM Template for it? If so, where can I find a quick-start sample?
- Is it possible to do in a programmatically way, i.e. using PowerShell? If so, where can I find some sample?
Usage scenario: setting up either an ARM Template or Script to deploy (update) to several environments.
Thanks in advance OliverB
Until the ability to do this is implemented, you just need to document the setup process in detail, with step-by-step instructions, and any scripts you can write (such as power-shell scripts for registering an application with the graph-api).
Keep all these files in a separate module or folder in your project and under version control.
Once it can be automated (if ever), these files can be used as the foundation for the requirements of you auto-deployment-and-update module.
You can now use Microsoft Graph apis to manage custom policies and policy keys. Please find the documentation for custom policies api here and for policy keys here. You can find samples here .
Azure AD B2C supports PowerShell cmdlets for custom policies as of today.
Azure AD Preview module documentation
See medium blog
It is currently not possible to automate creation of AAD B2C tenant. You can follow this tutorial to create a BC tenant:
Tutorial: Create an Azure Active Directory B2C tenant.
Since B2C custom policies went GA, there are some new AAD roles that allow some automation:
If you want to automate upload of custom policies (IEF policy), you can:
Create a local user in the B2C Tenant with the
B2C IEF Policy Administrator
role.create a
native
app registrationAdd Required Permissions for the previously created application registration
Access directory as the signed in user
Grant permissions
The Graph API (beta version) provides endpoint to manage custom policies:
trustFrameworkPolicy resource type
Here is the script I am using to upload custom policies (
Upload-B2C-CustomPolicies.ps1
):I execute the script like this:
Currently, it is not possible to manage B2C policies programmatically. That feature is currently under development.If this is important to you ,you can vote for it in this Feedback Forum so that we can let you know when it is available for preview. The feature request for programmatic registering application is in this Feedback Forum.
Additional, If you want get some samples for Azure B2C cutom Plicies, you can refer these samples.
Hope this helps!