Azure AD B2C – Using the graph API

There’s a really good guide for getting started with CRUD operations in a AAD B2C tenant on the Azure documentation site;

As per usual, I’ve ended up putting some powershell together to make it a bit more repeatable when I have to do this for multiple AAD tenants.

This particular script creates the application in the AAD tenant. I’ll be posting further scripts that show off doing some clever stuff when I’ve finished testing and polishing them.

10 Replies to “Azure AD B2C – Using the graph API”

  1. HI gord

    Thanks for sharing
    Did you have issues where the App was not visible in the portal after creation via powershell.
    I can however find it if i search for it via client ID


    1. Unfortunately the app won’t be visible in the portal. I’ve heard that this is a roadmap item and will be fixed at some point.

  2. And how does the powershell tell which directory the application is added too if they are multiple directories in a tenant

    1. The email address used for the $AdminUserName variable is where the directory is taken from. Eg. My b2c directory is so the variable is “”

  3. Thanks for your prompt response @gord. Am stuck on deploying the app.Its deploying to the default directory but not to the custom B2C directory i have created.Any suggestions on how to force it to deploy to a custom directory?

  4. Thanks figured it out.Had too create a user in the New B2C directory. And run powershell using that users context.

  5. Hi Gordon,

    I noticed you are using the older MSOnline PowerShell module in your examples. It may be useful to start using the newer Azure Active Directory PowerShell V2 module instead, as we will begin deprecating the MSOnline module when we have migrated the functionality of the MSOnline module to the newer module – currently planned for the Spring of 2017.


    Rob de Jong

      1. I used above example to create app and assign permission. But, i was unable to login to Ad B2C using policy. it is showing me a message, however, I used same domain user name to create app using power shell. Anybody can help on this, please

        Sorry, but we’re having trouble signing you in.
        We track these errors automatically, but if the problem persists feel free to contact us. In the meantime, please try again.
        Correlation ID: 965d8eee-e3fa-4fd4-9a7b-084525aeb701
        Timestamp: 2017-04-19 03:37:37Z
        AADB2C90018: The client id ‘007baa96-54cd-46fd-b282-1aed6b22bad2’ specified in the request is not registered in tenant ‘’.

Leave a Reply

Your email address will not be published. Required fields are marked *