Using App credential can't create service principal using Azure Java SDK

James 0 Reputation points
2024-12-19T22:20:32.0433333+00:00

Hi Team,

I am having problem using azure java sdk to create service principal,

    val resourceManager: AzureResourceManager = {               	AzureResourceManager.authenticate(credential, profile).withDefaultSubscription()    

 }
val password = "xxxxx"

val sp = resourceManager
  .accessManagement()
  .servicePrincipals()
  .define(spName)
  .withExistingApplication(appId)
  .definePasswordCredential(password)
  .attach()
  .create()

Got exception

{"error":{"code":"Authorization_RequestDenied","message":"Insufficient privileges to complete the operation.","innerError":{"date":"2024-12-19T19:50:01","request-id":"xxxx","client-request-id":"xxxx"}}}

I have already grant the service principal with role: "Role Based Access Control Administrator"

What permission should a service principal be configured before it can be used to generate another service principal? Thanks a million for the help!

Active Directory
Active Directory
A set of directory-based technologies included in Windows Server.
6,764 questions
0 comments No comments
{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.