Create ADB2C tenant REST

Cloudy 226 Reputation points
2023-06-14T08:52:14.33+00:00

Dear,

I'm trying to deploy a B2C tenant by using REST APIs.

When using the following REST endpoint url https://learn.microsoft.com/en-us/rest/api/activedirectory/b2c-tenants/create?tabs=HTTP

With the following json body payload by example :

 $b2cTenantObject = [PSCustomObject] @{
        "location"    = $location
        "sku" = @{
            "Name"  = "Standard"
            "Tier"    = "PremiumP1"
        }
        "properties" =@{
            "createTenantProperties"=@{
                "displayName"=$b2CTenantName
                "countryCode"="FR"
                        }
        }
    }

The result is the following :

User's image

User's image

The B2C tenant is never provisionned (did many tries), is there another action to complete after calling the speciefied REST endpoint to make the B2C tenant resource available ?(nothing in RG)

Many thanks for your help

Microsoft Security | Microsoft Entra | Microsoft Entra ID
Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

Answer accepted by question author
  1. Alfredo Revilla - Upwork Top Talent | IAM SWE SWA 27,536 Reputation points Moderator
    2023-06-19T17:57:09.6866667+00:00

    Hello @Cloudy , there is no additional steps required to create a B2C tenant trough Azure REST. What you should do is to query operation async progress trough a URL provided in the create response location header. While the operation is in progress you will get a 202 status code and once the it has completed a 200 status code. The response content will provide information about the created tenant or the error details.

    In your current $b2cTenantObject you should change sku.tier to "A0". Also ensure resource name includes the .onmicrosoft.com sufix. Eg.

    
    # PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureActiveDirectory/b2cDirectories/contoso.onmicrosoft.com?api-version=2023-01-18-preview
    
    $b2cTenantObject = [PSCustomObject] @{
            "location"    = $location
            "sku" = @{
                "Name"  = "Standard"
                "Tier"    = "A0"
            }
            "properties" =@{
                "createTenantProperties"=@{
                    "displayName"=$b2CTenantName
                    "countryCode"="FR"
                            }
            }
        }
    

    Let us know if you need additional assistance. If the answer was helpful, please accept it and rate it so that others facing a similar issue can easily find a solution.


0 additional answers

Sort by: Most helpful

Your answer

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