Suvmam950
Suvmam950

Reputation: 23

Create b2c tenant failed from both ARM API and Portal

From our previous ask, we got to know how to create b2c tenant using ARM API. This is the reference: https://learn.microsoft.com/en-us/rest/api/activedirectory/b2c-tenants/create?tabs=HTTP#scopes

PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureActiveDirectory/b2cDirectories/{resourceName}?api-version=2021-04-01

But when we tried this from our end it's not working. This failed with error "The subscription is not registered to use namespace 'Microsoft.AzureActiveDirectory' "

In order to check what's going wrong we tried to create b2c tenant from Portal. But there is no use, same error: Error

How to fix this error and where to register namespace in Azure?

Upvotes: 1

Views: 140

Answers (1)

Sridevi
Sridevi

Reputation: 22512

This error usually occurs if you have not registered this provider before creating B2C tenant: Microsoft.AzureActiveDirectory

You can check whether that provider is registered or not like this: Go to Azure Portal -> Subscriptions -> Your subscription -> Resource providers

enter image description here

I tried to reproduce the same in my environment and got below results:

After registering the provider, I ran the below ARM API call via Postman and got Status: 202 Accepted like below:

PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureActiveDirectory/b2cDirectories/{b2ctenantdomain}?api-version=2021-04-01

{
  "location": "United States",
  "sku": {
    "name": "Standard",
    "tier": "A0"
  },
  "properties": {
    "createTenantProperties": {
      "displayName": "b2ctenantname",
      "countryCode": "US"
    }
  }
}

Response:

enter image description here

To confirm that, I checked the same in Portal and B2C tenant is created successfully like below:

enter image description here

When I opened B2C tenant in new tab, it took me to below screen:

enter image description here

Upvotes: 1

Related Questions