Install the Azure PowerShell module

This article tells you how to install the Azure PowerShell modules using PowerShellGet. These instructions work on Windows, macOS, and Linux platforms. For the Az module, currently no other installation methods are supported.

Requirements

Azure PowerShell works with PowerShell 5.1 or higher on Windows, or PowerShell Core 6.x and later on all platforms. If you aren't sure if you have PowerShell, or are on macOS or Linux, install the latest version of PowerShell Core.

To check your PowerShell version, run the command:

$PSVersionTable.PSVersion

To run Azure PowerShell in PowerShell 5.1 on Windows:

  1. Update to Windows PowerShell 5.1 if needed. If you're on Windows 10, you already have PowerShell 5.1 installed.
  2. Install .NET Framework 4.7.2 or later.

There are no additional requirements for Azure PowerShell when using PowerShell Core.

Install the Azure PowerShell module

Warning

You can't have both the AzureRM and Az modules installed for PowerShell 5.1 for Windows at the same time. If you need to keep AzureRM available on your system, install the Az module for PowerShell Core 6.x or later. To do this, install PowerShell Core 6.x or later and then follow these instructions in a PowerShell Core terminal.

The recommended install method is to only install for the active user:

Install-Module -Name Az -AllowClobber -Scope CurrentUser

If you want to install for all users on a system, this requires administrator privileges. From an elevated PowerShell session either run as administrator or with the sudo command on macOS or Linux:

Install-Module -Name Az -AllowClobber -Scope AllUsers

By default, the PowerShell gallery isn't configured as a trusted repository for PowerShellGet. The first time you use the PSGallery you see the following prompt:

Untrusted repository

You are installing the modules from an untrusted repository. If you trust this repository, change
its InstallationPolicy value by running the Set-PSRepository cmdlet.

Are you sure you want to install the modules from 'PSGallery'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"):

Answer Yes or Yes to All to continue with the installation.

The Az module is a rollup module for the Azure PowerShell cmdlets. Installing it downloads all of the available Azure Resource Manager modules, and makes their cmdlets available for use.

Troubleshooting

Here are some common problems seen when installing the Azure PowerShell module. If you experience a problem not listed here, please file an issue on GitHub.

Proxy blocks connection

If you get errors from Install-Module that indicate the PowerShell Gallery is unreachable, you may be behind a proxy. Different operating systems will have different requirements for configuring a system-wide proxy, which are not covered in detail here. Contact your system administrator for your proxy settings and how to configure them for your OS.

PowerShell itself may not be configured to use this proxy automatically. With PowerShell 5.1 and later, configure the proxy to use for a PowerShell session with the following command:

(New-Object System.Net.WebClient).Proxy.Credentials = `
  [System.Net.CredentialCache]::DefaultNetworkCredentials

If your operating system credentials are configured correctly, this will route PowerShell requests through the proxy. In order to have this setting persist between sessions, add the command to a PowerShell profile.

In order to install the package, your proxy needs to allow HTTPS connections to the following address:

  • https://www.powershellgallery.com

Sign in

To start working with Azure PowerShell, sign in with your Azure credentials.

# Connect to Azure with a browser sign in token
Connect-AzAccount

Note

If you've disabled module autoloading, you need to manually import the module with Import-Module Az. Because of the way the module is structured, this can take a few seconds.

You'll need to repeat these steps for every new PowerShell session you start. To learn how to persist your Azure sign-in across PowerShell sessions, see Persist user credentials across PowerShell sessions.

Update the Azure PowerShell module

Because of how the Az module is packaged, the Update-Module command won't update your installation correctly. Az is technically a meta-module, encompassing all of the submodules that contain cmdlets to interact with Azure services. That means that to update the Azure PowerShell module, you will need to reinstall, rather than just update. This is done in the same way as installing, but you may need to add the -Force argument:

Install-Module -Name Az -AllowClobber -Force

Although this can overwrite installed modules, you may still have older versions left on your system. To learn how to remove old versions of Azure PowerShell from your system, see Uninstall the Azure PowerShell module.

Use multiple versions of Azure PowerShell

It's possible to install more than one version of Azure PowerShell. To check if you have multiple versions of Azure PowerShell installed, use the following command:

Get-InstalledModule -Name Az -AllVersions | select Name,Version

To remove a version of Azure PowerShell, see Uninstall the Azure PowerShell module.

You can install or load a specific version of the Az module by using the -RequiredVersion argument:

# Install Az version 0.7.0
Install-Module -Name Az -RequiredVersion 0.7.0 
# Load Az version 0.7.0
Import-Module -Name Az -RequiredVersion 0.7.0

If you have more than one version of the module installed, module autoload and Import-Module load the latest version by default.

Provide feedback

If you find a bug in Azure Powershell, file an issue on GitHub. To provide feedback from the command line, use the Send-Feedback cmdlet.

Next Steps

To learn more about the Azure PowerShell modules and their features, see Get Started with Azure PowerShell. If you're familiar with Azure PowerShell and need to migrate from AzureRM, see Migrate from AzureRM to Az.