Getting Started with Authorization - Manage Users Groups And Roles - in Java

Azure Users, Groups and Roles sample.

  • Create a user
  • Assign role to AD user
  • Revoke role from AD user
  • Get role by scope and role name
  • Create Service Principal
  • Assign role to Service Principal
  • Create 2 Active Directory groups
  • Add the user, the service principal and the 1st group as members of the 2nd group

Running this Sample

To run this sample:

See DefaultAzureCredential and prepare the authentication works best for you. For more details on authentication, please refer to

git clone

cd aad-java-manage-users-groups-and-roles

mvn clean compile exec:java

More information

For general documentation as well as quickstarts on how to use Azure Management Libraries for Java, please see here.

Start to develop applications with Java on Azure here.

If you don't have a Microsoft Azure subscription you can get a FREE trial account here.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact with any additional questions or comments.