Skip to content

Azure CLI commands fail for newly granted subscriptions #26887

@jiasli

Description

@jiasli

Symptom

Azure CLI commands fail for newly granted subscriptions.

Steps to repro:

  1. Run az login with a user account or service principal. Azure CLI caches the result of ARM REST API Subscriptions - List which doesn't contain the new subscription. The cache is saved to ~/.azure/azureProfile.json.
  2. The user account or service principal is granted an RBAC role assignment on a new subscription to which the user account or service principal previously doesn't have access. The subscription can be newly created.
  3. Because az account set/show and --subscription only use subscription information from the local cache, they won't be able to work with that new subscription and show errors.

Different error messages can be shown:

az account subscription list is not affected because this command gets the result from ARM API Subscriptions - List, instead of the local cache.

Solution

The best practice is to have subscriptions' RBAC role assignments granted before running az login.

If you have already run az login, you may refresh the local cache:

Additional Context

Email: Regarding issue during Azure ClI

Metadata

Metadata

Labels

ARMaz resource/group/lock/tag/deployment/policy/managementapp/account management-groupAccountaz login/accountAuto-AssignAuto assign by botAzure CLI TeamThe command of the issue is owned by Azure CLI teamact-identity-squadfeature-request

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions