Create a Azure B2C resourse with Terraform and Managed Identity

Davide Cordaro 20 Reputation points
2025-05-08T08:19:33.13+00:00

We need to create an Azure B2C Tentant resource with Terraform but we receive this error:

Error: performing Create: unexpected status 401 (401 Unauthorized) with response: You do not have permission to view this directory or page.

Is it possible to create an Azure B2C Tentant using a Managed Identity as authentication method for Terraform?

We have tried to assign Contributor and even Global Admin Role to the Managed Identity but we have the same issue

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
24,577 questions
0 comments No comments
{count} votes

Accepted answer
  1. Navya 18,595 Reputation points Microsoft External Staff Moderator
    2025-05-08T09:42:09.59+00:00

    Hi @Davide Cordaro

    I understand that you're trying to create an Azure AD B2C resource using Terraform with a Managed Identity, but you're encountering the following error:

    "Error: performing Create: unexpected status 401 (401 Unauthorized) with response: You do not have permission to view this directory or page."

    No, it is not possible to create an Azure B2C tenant using a Managed Identity as the authentication method for Terraform. The reason is that whoever creates the tenant will automatically receive a global administrator account. If we attempt to create the tenant through a service principal or managed identities, it won't be able to create users.

    We have feature requests in our feature portal, which are open for the user community to upvote and comment on. This allows our product teams to effectively prioritize your request against our existing feature backlog and provides insight into the potential impact of implementing the suggested feature.

    Add support for Service Principal to create an Azure AD B2C · Community

    Azure AD B2C tenant creation with service principal · Community

    Hope this helps. Do let us know if you any further queries.


    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

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.