Error: building account: getting authenticated object ID: listing Service Principals: autorest.DetailedError{Original:(*azure.RequestError)(0xc001c22360), PackageType:"graphrbac.ServicePrincipalsClient", Method:"List", StatusCode:403, Message:"Failure res

Nho Luong 65 Reputation points
2025-06-08T03:37:40.0966667+00:00

Hello,

I have use my terrafrom then create my azure resource for all services but now i have problem

step 1. use global administrator create

az account set --subscription="xxxxxx" 

az ad sp create-for-rbac --name “nholuong” --role "Contributor" --scopes "/subscriptions/xxxxx"

Creating 'Contributor' role assignment under scope '/subscriptions/xxxxxx'

step 2.
az logout

az login \

--service-principal \

--tenant xxxxxx \

--username  xxxx \

--password  xxxxx \

--output table

az account set --subscription="xxxxx"

az account list --output table

=====================================

nholu@nholuongs-MBP uat % terraform init && terraform plan

Initializing modules...

Initializing the backend...

Initializing provider plugins...

  • Reusing previous version of hashicorp/kubernetes from the dependency lock file
  • Reusing previous version of hashicorp/local from the dependency lock file
  • Reusing previous version of hashicorp/random from the dependency lock file
  • Reusing previous version of hashicorp/azurerm from the dependency lock file
  • Reusing previous version of hashicorp/azuread from the dependency lock file
  • Reusing previous version of hashicorp/helm from the dependency lock file
  • Reusing previous version of hashicorp/template from the dependency lock file
  • Using previously-installed hashicorp/helm v2.4.1
  • Using previously-installed hashicorp/template v2.2.0
  • Using previously-installed hashicorp/kubernetes v2.7.1
  • Using previously-installed hashicorp/local v2.1.0
  • Using previously-installed hashicorp/random v3.1.0
  • Using previously-installed hashicorp/azurerm v2.90.0
  • Using previously-installed hashicorp/azuread v2.15.0

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see

any changes that are required for your infrastructure. All Terraform commands

should now work.

If you ever set or change modules or backend configuration for Terraform,

rerun this command to reinitialize your working directory. If you forget, other

commands will detect it and remind you to do so if necessary.

module.uat.data.template_file.auto_scale_db: Reading...

module.uat.data.template_file.auto_scale_db: Read complete after 0s [id=be407951f3b2bddddc6317fec56610a86fe14293ebe6f69bce88a03a3f1295dd]

│ Error: building account: getting authenticated object ID: listing Service Principals: autorest.DetailedError{Original:(*azure.RequestError)(0xc001c3e090), PackageType:"graphrbac.ServicePrincipalsClient", Method:"List", StatusCode:403, Message:"Failure responding to request", ServiceError:[]uint8(nil), Response:(*http.Response)(0xc001c3e000)}

│ with provider["registry.terraform.io/hashicorp/azurerm"],

│ on providers.tf line 1, in provider "azurerm":

│ 1: provider "azurerm" {

Screen Shot 2025-06-08 at 10.32.37

Screen Shot 2025-06-08 at 10.31.27

Azure Cost Management
Azure Cost Management
A Microsoft offering that enables tracking of cloud usage and expenditures for Azure and other cloud providers.
3,581 questions
{count} votes

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.