The Azure Command-Line Interface (CLI) lets you manage your Azure resources directly from the terminal. It’s fast, powerful, and works across Windows, macOS, and Linux — regardless of the programming language or framework you use.
1. Install Azure CLI
Follow Microsoft’s official installation guide for your operating system: Install Azure CLI. You will see different install options. You can choose the tool/option you are most comfortable with like PowerShell for example. If you are a Windows user and not sure which option to choose, you can first try installing from Install on Windows using Microsoft Installer (MSI). If an option fail, then you may try other options as well.
2. Verify the Installation
Once installed, go to CMD or PowerShell and confirm it’s installed correctly:
az --version
This prints the installed version and ensures the CLI is ready to use.
⚡ Windows Troubleshooting (DLL load error)
Some Windows users may see an error like:
ImportError: DLL load failed while importing win32file
This happens when the Azure CLI’s bundled Python environment can’t load the pywin32 module. The fix is to repair it manually. Run these in PowerShell (Admin):
# (Optional) upgrade pip
& "C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe" -m pip install --upgrade pip
# Reinstall pywin32 (required)
& "C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe" -m pip install --force-reinstall pywin32==311
After this, rerun:
az --version
If it prints version info without errors, you’re good to go.
3. Log in with Device Code Flow
To authenticate your CLI session, run:
az login --use-device-code
Steps:
- The CLI shows a code and a link → https://microsoft.com/devicelogin.
- Open the link in any browser window you want (can be on any device).
- Enter the code and sign in with your Azure account.
- The CLI receives the token and displays your subscriptions.
⚡ Troubleshooting: No Subscriptions Found
If you see an error like this after login:
Authentication failed against tenant <TENANT_ID> 'Default Directory':
V2Error: invalid_grant AADSTS700082: The refresh token has expired due to inactivity.
The token was issued on <DATE> and was inactive for 90.00:00:00.
Trace ID: <TRACE_ID> Correlation ID: <CORRELATION_ID> Timestamp: <TIMESTAMP>.
Status: Response_Status.Status_InteractionRequired, Error code: <ERROR_CODE>, Tag: <TAG>
If you need to access subscriptions in the following tenants, please use:
az login --tenant <TENANT_ID>
<TENANT_ID> 'Default Directory'
No subscriptions found for <USER_EMAIL>.
This happens if your account belongs to multiple tenants or your cached token expired.
✅ Fix:
- Find your Tenant ID in the Azure Portal:
- Go to the Azure Portal
- Open Microsoft Entra ID (formerly Azure Active Directory)
- On the Overview page, copy the Tenant ID (Directory ID)
- (Alternative/Optional) List tenants using CLI:
az account tenant list --output table - Log in against the correct tenant:
az login --use-device-code --tenant <TENANT_ID>
👉 After successful login, the CLI will display the subscriptions available in that tenant and may ask you to choose which one should be the default.

4. Verify Your Login
- List all subscriptions:
az account list --output table - Check the active subscription:
az account show --output table
5. Set Your Active Subscription 🗂️
If you have multiple Azure subscriptions, you need to specify which one to work with. Run the following command and replace with your subscription name or ID:
az account set --subscription "My Subscription ID or Name"
--subscription→ accepts either the subscription ID or name.- This ensures that all subsequent commands run against the correct subscription.
6. List All Resource Groups
Once you’ve created a resource group, you can view all the resource groups in your subscription:
az group list --output table
az group list→ lists all resource groups in your subscription.--output table→ formats the output in a clean table view (other options:json,yaml, etc.).
This is a quick way to verify your newly created resource group and explore any existing ones.
7. (Optional) Create Your First Resource Group 🎯
A resource group is a logical container for Azure resources. Let’s create one:
az group create --name myResourceGroup --location eastus
--name→ the name of your resource group (choose any unique name).--location→ the Azure region where resources will be created.
If successful, you’ll see JSON output confirming the resource group details.
🎉 Conclusion
You’ve just:
✅ Installed Azure CLI
✅ Logged in securely
✅ Verified your subscription
✅ Created your first resource group
From here, you’re ready to create virtual machines, storage accounts, databases, or even deploy full apps — all from your terminal.
👉 The Azure CLI is your gateway to managing the cloud efficiently. Once you get comfortable, you’ll find it faster than clicking around the portal.