The az account command is part of the az command-line client, which is the official CLI (Command-Line Interface) tool provided by Microsoft for managing resources and services on the Microsoft Azure cloud platform.
The az account command allows you to manage Azure subscription information. Here’s an overview of its functionality:
- Subscription Management: With the az account command, you can view and manage Azure subscriptions associated with your Azure account. You can list all available subscriptions, set a default subscription to be used for subsequent commands, and switch between different subscriptions when working with Azure resources.
- Authentication and Authorization: To use the az account command, you need to authenticate with your Azure account. The CLI supports multiple authentication methods, including Azure Active Directory (Azure AD) credentials, service principals, and managed identities. Once authenticated, the CLI uses the specified credentials to authorize your actions on Azure resources.
- Subscription Information: The az account command provides various options to retrieve information about your Azure subscriptions. You can view details such as the subscription ID, display name, state, and associated tenant ID. This information is helpful when managing multiple subscriptions or working in a multi-tenant environment.
- Subscription Management Operations: The az account command allows you to perform various subscription management operations. You can enable or disable Azure subscriptions, which can be useful to control resource usage and billing. Additionally, you can view the current Azure context, which includes details about the selected subscription and tenant.
- Subscription Registration: Some Azure services and features require explicit registration before they can be used within a subscription. The az account command provides options to manage the registration status of these services. You can check the registration status of specific services, register new services, or unregister services that are no longer required.
- Role-Based Access Control (RBAC): Azure employs RBAC to control access to resources within a subscription. The az account command enables you to manage Azure AD roles assigned to users, groups, or service principals within a subscription. You can list assigned roles, assign new roles, update role assignments, and remove existing role assignments.
The az account command is a vital component of the az CLI tool, allowing you to manage Azure subscription information, switch between subscriptions, and control access to Azure resources through RBAC. By leveraging this command, you can effectively manage and organize your Azure resources and subscriptions from the command line.
az account Command Examples
1. Print a list of subscriptions for the logged in account:
# az account list
2. Set a subscription to be the currently active subscription:
# az account set --subscription subscription_id
3. List supported regions for the currently active subscription:
# az account list-locations
4. Print an access token to be used with MS Graph API:
# az account get-access-token --resource-type ms-graph
5. Print details of the currently active subscription in a specific format:
# az account show --output [json|tsv|table|yaml]