How to fix when i create aks cluster through terraform the error

jigyasu mishra 0 Reputation points
2023-03-13T05:11:46.2566667+00:00

Error: creating Managed Kubernetes Cluster "diverse-moth-aks" (Resource Group "diverse-moth-rg"): containerservice.ManagedClustersClient#CreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: Code="ServicePrincipalNotFound" Message="Service principal clientID: \t not found in Active Directory tenant , Please see https://aka.ms/aks-sp-help for more details."
whenever i already create service principal and assign role as a contributor so why i find to this type of error.

Azure Kubernetes Service (AKS)
Azure Kubernetes Service (AKS)
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
1,846 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Andrei Barbu 2,576 Reputation points Microsoft Employee
    2023-03-13T11:07:40.68+00:00

    Hello jigyasu mishra

    The clientId you are using "\te6379e6b-7428-4063-8df4-dbf793b15da6" seems invalid.

    I just created a service principal and the appId has 36 characters and no "". Even if we exclude "" from your Id, it still has 37 characters. If there is any particularity for Terraform, I am not aware of.

    I would recommend you make sure the appId / clientId is valid. You may go to Azure Portal -> App registrations and try to identify it there.

    Additionally, you may want to create the AKS cluster using Azure CLI. For example:

    az aks create -g aks-rg -n aks --service-principal <appId> --client-secret <secret>


    I hope this is helpful. If any clarification needed, let me know and I will do my best to answer.

    Please "Accept as Answer" and Upvote if it helped, so that it can help others in the community looking for help on similar topics.

    Thank you!