az account management-group <cmd> fails
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 3.5k
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 60
Description
> ### `az feedback` auto-generates most of the information requested below, as of CLI version 2.0.62
**Describe the bug**
`az account management-group ` fails when logged in with a service principal which does not have any role assignments to any subscriptions.
The `az login` is done with the `--allow-no-subscriptions` flag.
When `az account management-group create/delete/show/list` is run, it throws the following error
### Error
```
(SubscriptionNotFound) The subscription 'tenantid-xxxx-xxxx-xxxx-xxxxxxx' could not be found.
Code: SubscriptionNotFound
Message: The subscription 'tenantid-xxxx-xxxx-xxxx-xxxxxxx' could not be found.
```
The SubscriptionId mentioned in the error is the tenantId which was passed during `az login`
The Service principal has Contributor access to the Management Group.
A bicep template to create MG works fine when deployed with the same Service principal credentials
**To Reproduce**
1. Create a SP and assign Contributor/Owner role to a MG that does not contain a subscription.
`az ad sp create-for-rbac --name "mg-sp"`
`Note: The SP should not have any role assignments to any subscriptions`
2. Login using SP creds
`az login --service-principal -u xxx -p xxx -t 'tenant-id-xxx' --allow-no-subscriptions`
3. Create/Show/Delete a management group
` az account management-group show --name `
**Expected behavior**
`az account management-group ` runs even if there are no role assignments to subscriptions
**Environment summary**
```yaml
{
"azure-cli": "2.35.0",
"azure-cli-core": "2.35.0",
"azure-cli-telemetry": "1.0.6",
"extensions": {}
}
```
**Additional context**
****
Contributor guide
Assessment
This issue has not been assessed yet.