I created an Azure App Registration using the following command:
az ad sp create-for-rbac --name "my-app"
I assigned a role to it using:
az role assignment create --assignee <APP_ID> --role "Reader" --scope /subscriptions/<SUBSCRIPTION_ID>
I also deleted some roles using:
az role assignment delete --assignee <APP_ID> --role "Reader" --scope /subscriptions/<SUBSCRIPTION_ID>
However, when I try to list the roles assigned to the app registration using any of the following:
az role assignment list --assignee <APP_ID>
az role assignment list --assignee <OBJECT_ID>
az role assignment list --assignee "my-app"
None of them return any results.
Any guidance would be greatly appreciated!
Registered an application using below CLI command:
az ad sp create-for-rbac --name "<application-name>"
Note: Ensure you should have active Subscription and sufficient permission like (Owner or User Access Administrator) role assigned on the scope(i.e Subscription Level) where you want to assign the role.
Assigned Reader
role to application at the scope of Subscription Level:
az role assignment create --assignee <APP_ID> --role "Reader" --scope /subscriptions/<SUBSCRIPTION_ID>
After assigning the Reader
role to application, I've verified this same from Azure Portal under Access Control (IAM) tab of Subscription as well.
After verifying from above, I try to list the roles assigned to application using below Azure CLI command:
az role assignment list --assignee <Application-id or Object-Id of application>
UPDATE:
To list the all role assignment under your subscription:
az role assignment list --all
If still issue persist, reassign the Reader
role to registered application and run the CLI command for listing the roles assigned to application
Reference: