Azure PowerShell Installation

Your comprehensive guide to getting Azure PowerShell set up.

Introduction

Azure PowerShell provides a set of cmdlets that connect to your Azure subscription and manage resources. This guide will walk you through the installation process for various operating systems.

We recommend installing the latest Az module, which is the current generation of Azure PowerShell modules.

Prerequisites

Installation Methods

Choose the method that best suits your operating system and preferences.

Recommended: Install the Az Module using PowerShellGet

This is the most common and flexible method, available for Windows, macOS, and Linux.

  1. Open PowerShell

    Launch PowerShell as an administrator. On Windows, right-click on the PowerShell icon and select "Run as administrator". On macOS and Linux, open your terminal and type pwsh.

  2. Install the Az Module

    Run the following command to install the latest version of the Az module:

    Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force

    If you're on macOS or Linux, you might need to use sudo:

    sudo pwsh -Command "Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force"

    You may be prompted to install the NuGet provider and to trust the PSGallery repository. Type Y and press Enter to accept.

  3. Verify the Installation

    Close and reopen PowerShell. Then, run the following command to check if the Az module is loaded:

    Get-Module -ListAvailable -Name Az

    You should see the Az module listed. To connect to Azure:

    Connect-AzAccount

Platform-Specific Considerations

Windows

The Az module works seamlessly with Windows PowerShell 5.1 and PowerShell 7. If you encounter issues with older versions, consider upgrading to PowerShell 7 or using the recommended Install-Module method.

Important Notes:

  • Ensure you have .NET Framework 4.7.2 or later installed for Windows PowerShell 5.1. PowerShell 7 includes its own .NET runtime.

macOS

Install PowerShell Core (pwsh) first if you haven't already. The Az module installs and runs using pwsh.

Installation Steps:

Linux (Ubuntu/Debian Example)

Similar to macOS, you'll use PowerShell Core (pwsh).

Installation Steps:

  • Install PowerShell Core: Refer to the official PowerShell documentation for your specific distribution.
  • Install the Az module using pwsh. You will likely need sudo for the installation command.

Optional: Installing AzureRM (Legacy)

The AzureRM module is the older generation of Azure PowerShell modules. It is deprecated and will be retired. While it might still be available for existing scripts, we strongly recommend migrating to the Az module for new development and existing deployments.

To install AzureRM (not recommended for new installations):

Install-Module -Name AzureRM -Scope CurrentUser -Repository PSGallery -Force

Warning: Do not install both Az and AzureRM modules in the same PowerShell session, as they can conflict.