Automate app registration in B2C

Vikas Tiwari 771 Reputation points
2020-07-08T22:09:34.343+00:00

Hi,

I wanted to know if there is any documentation or code sample to describe how to automate app registration in Azure AD B2C. I want to register app through script or any other way, which I can attach with devops pipeline and automate whole process?

Thanks,
Vikas Tiwari

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,255 questions
Microsoft Entra External ID
Microsoft Entra External ID
A modern identity solution for securing access to customer, citizen and partner-facing apps and services. It is the converged platform of Azure AD External Identities B2B and B2C. Replaces Azure Active Directory External Identities.
2,908 questions
0 comments No comments
{count} votes

Accepted answer
  1. 2020-07-09T01:16:52.72+00:00

    You can use MS Graph Create Application operation and other supported. Follows sample request:

       {  
         "displayName": "NewAppFromMSGraph",  
         "requiredResourceAccess": [  
           {  
             "resourceAppId": "00000003-0000-0000-c000-000000000000",  
             "resourceAccess": [  
               {  
                 "id": "37f7f235-527c-4136-accd-4a02d197296e",  
                 "type": "Scope"  
               },  
               {  
                 "id": "7427e0e9-2fba-42fe-b0c0-848c9e6a8182",  
                 "type": "Scope"  
               }  
             ]  
           }  
         ],  
         "signInAudience": "AzureADandPersonalMicrosoftAccount",  
         "web": {  
           "implicitGrantSettings": {  
             "enableIdTokenIssuance": true,  
             "enableAccessTokenIssuance": true  
           },  
           "redirectUris": [  
             "https://jwt.ms"  
           ]  
         }  
       }  
    

2 additional answers

Sort by: Most helpful
  1. Vikas Tiwari 771 Reputation points
    2020-07-10T05:44:01.78+00:00

    Thanks for sharing the details.
    So if I create simple console app and run following code it should create (register) app into my b2c tenant.

    IPublicClientApplication publicClientApplication = PublicClientApplicationBuilder
                .Create(clientId)
                .Build();
    
    Func<DeviceCodeResult, Task> deviceCodeReadyCallback = async dcr => await Console.Out.WriteLineAsync(dcr.Message);
    DeviceCodeProvider authProvider = new DeviceCodeProvider(publicClientApplication, scopes, deviceCodeReadyCallback);
    
    GraphServiceClient graphClient = new GraphServiceClient( authProvider );
    
    var application = new Application
    {
        DisplayName = "Display name"
    };
        await graphClient.Applications
        .Request()
        .AddAsync(application);
    

    What is Client id here (I guess its application id) but I dont have any application in my tenant directory yet and I trying to register, how can I pass client id?

    Am I missing any thing here?


  2. Vikas Tiwari 771 Reputation points
    2020-07-14T16:02:29.29+00:00

    Hi,

    I have found a way to create app in azure B2C tenant using cli, following are the commands helped me to create app in B2C tenant:

    az login -t myb2ctenant.onmicrosoft.com --allow-no-subscriptions (this cmd helped me to login to B2C without subscription)

    az ad app create --display-name testb2capp (this creates app in B2C)

    az ad app list --display-name testb2capp (Gives details of newly created app)

    az ad app update --id APP_ID_FROM_ABOVE_CMD --reply-urls https://jwt.ms (update any values in app)

    https://learn.microsoft.com/en-us/cli/azure/install-azure-cli-windows?view=azure-cli-latest&tabs=azure-cli

    You can verify if this looks good to you and we can mark this as answer.

    Thanks for your help.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.