Skip to content

az account management-group <cmd> fails #21949

@rahul-presidio

Description

@rahul-presidio

az feedback auto-generates most of the information requested below, as of CLI version 2.0.62

Describe the bug

az account management-group <cmd> 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 <mg-id>

Expected behavior

az account management-group <cmd> runs even if there are no role assignments to subscriptions

Environment summary

{
  "azure-cli": "2.35.0",
  "azure-cli-core": "2.35.0",
  "azure-cli-telemetry": "1.0.6",
  "extensions": {}
}

Additional context


Metadata

Metadata

Labels

ARMaz resource/group/lock/tag/deployment/policy/managementapp/account management-groupAccountaz login/accountAuto-AssignAuto assign by botact-identity-squadcustomer-reportedIssues that are reported by GitHub users external to the Azure organization.feature-request

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions