Azure PowerShell Troubleshooting

On this page

Overview

This guide helps you diagnose and resolve issues when using Azure PowerShell. It covers installation problems, authentication failures, cmdlet errors, and best‑practice diagnostics.

Common Errors & Solutions

1. “Login-AzAccount” fails with Token acquisition failed

Ensure you have the latest Az module and that your system time is synchronized.

Install-Module -Name Az -AllowClobber -Scope CurrentUser

2. “Get-AzSubscription” returns AuthorizationFailed

Verify your account has Reader or higher role on the subscription.

# Check role assignments
Get-AzRoleAssignment -ObjectId (Get-AzContext).Account.Id | Where-Object {$_.Scope -like '*subscriptions/*'}

3. Cmdlet not recognized – “The term 'New-AzResourceGroup' is not recognized”

Import the module explicitly or update your PowerShell session.

Import-Module Az.Resources

4. “Set-AzContext” fails with Network error: Unable to resolve host name

Check proxy settings or add a bypass for *.azure.com.

# Example: configure proxy for PowerShell
[System.Net.WebRequest]::DefaultWebProxy = New-Object System.Net.WebProxy('http://proxy.mycorp.local:8080')
[System.Net.WebRequest]::DefaultWebProxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials

Logging & Diagnostics

Enable module‑level logging to capture detailed request/response data.

# Enable Azure PowerShell debug logging
$DebugPreference = 'Continue'
$env:AZURE_LOG_LEVEL = 'Debug'

# Export logs to a file
Start-Transcript -Path "$HOME\azps-debug.log"
# Run your commands...
Stop-Transcript

Using Azure Cloud Shell for isolated troubleshooting

When local environment issues persist, run the same commands in Azure Cloud Shell to isolate configuration problems.

FAQ

Do I need admin rights to install Azure PowerShell?
No. Install with -Scope CurrentUser to avoid admin requirements.
Which PowerShell versions are supported?
Azure PowerShell supports PowerShell 5.1 on Windows and PowerShell 7.x on all platforms.
How can I rollback to a previous module version?
Use Install-Module -Name Az -RequiredVersion 9.5.0 (replace with the desired version).

Additional Resources