Azure / Azure/azure-cli

Inconsistent result from Azure CLI between Service principal login and user login

Open
#14,719 1 comment 0 reactions 1 assignee Claimed by @jiasli View on GitHub
act-identity-squad feature-request RBAC
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

[Enter feedback here]

I wanted to programmatically retrieve role assignment, and I used service principal to authenticate to run the following command:

_az role assignment list --all --include-inherited --subscription xxx --query '[].{principalName:principalName, roleDefinitionName:roleDefinitionName, scope:scope}'_

However, principalName always shown None. I tried az login with my user account, and it shows PrincipalName. Is there any missing RBAC required for my service principal or is this a bug?

---
#### Document Details

⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*

* ID: 9dacfad8-cb2f-2534-3b29-89b0930a2252
* Version Independent ID: 17325cd4-44c5-4069-d9f6-940a55f0f7c9
* Content: [az role assignment](https://docs.microsoft.com/en-us/cli/azure/role/assignment?view=azure-cli-latest#az-role-assignment-list)
* Content Source: [src/azure-cli/azure/cli/command_modules/role/_help.py](https://github.com/Azure/azure-cli/blob/dev/src/azure-cli/azure/cli/command_modules/role/_help.py)
* Service: **azure-resource-manager**
* GitHub Login: @rloutlaw
* Microsoft Alias: **routlaw**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.