Friday, August 23, 2019

Check your Azure PowerShell Az Module Installation

You have at least 2 ways of using PowerShell for Azure:
  • Using the Azure Cloud Shell that is available within the Azure Portal
  • Executing locally on you machine PowerShell scripts or instruction into Windows 10 PowerShell Application, PowerShell ISE or Visual Studio Code. This is the most used way of driving Azure remotely in the large companies beacause you can create PowerShell scripts that can be saved in source code control solutions and reused.

If you want to configure your PowerShell environment locally you should consider now to use PowerShell Az module since AzureRm has been deprecated since 2018 december.
There is plenty of posts explaining how to install Az module and to ensure the compatibility with AzureRm while it is not recommended to have both modules on your machine, but I didn't found much posts explaining how to check that your installation is successfull.
Thus, here are the steps to check to be sure that you really can use the complete Az module:

Get-InstalledModule

First, check that the installation links to the complete Az module with all dependencies:
Get-InstalledModule
You should have this result:


Get-Module -ListAvailable

Then, check that the module and the dependencies can be actually loaded in PowerShell by using:
Get-Module -ListAvailable


In a previous installation I have done, the installation was not complete:


Only the command Get-Module -ListAvailable will make you sure that you can actually use a module installed. I had to reinstall Az module by typing
Install-Module -Name Az -AllowClobber
(AllowClobber avoids conflicts with the previously already installed dependencies)

Get-Module

Regarding the command Get-Module, it shows you the modules currently loaded in your PowerShell tool.
Exemple:
If I execute the commad Get-module on a fresh PowerShell Window, I get this:

Then, if I execute a search on Azure available locations by typing
Get-AzLocation | Select Location
and I reexecute Get-Module, I can see that the Az.Accounts and Az.Resources that are dependencies of the Az module have been loaded in my PowerShell application:

No comments: