Setting Dependencies on the Azure PowerShell Module

I recently saw a tweet from Joel Bennett about the Az (Azure) PowerShell module being nothing more than an empty module that imports all of the modules for each Azure product.


I decided to investigate.

1Get-Content -Path (Get-Module -Name az).Path | Select-String -SimpleMatch 'Import-Module'


Joel's statement is 100% accurate.

Off-Topic: The searched for term is highlighted in each result when the previous command is run in PowerShell 7.


One thing I don't like about the Az module is the Import-Module statements use the RequiredVersion parameter.

This means that even though I've updated the Az.Compute module to version 3.4.0, it's going to load version 3.3.0 if I import the Az module. Without the RequiredVersion parameter, it would simply import the latest one.

1Get-Module -Name Az.Compute -ListAvailable


While I guess this is an easy way to load all of the individual Azure PowerShell modules at once. If you only need some of them, you might be better off loading them individually. If you're setting some type of dependency, I would definitely recommend specifying the individual modules instead of the Az one. As Joel said in his tweet, "Require what you actually need". That will also give you better control over which version of the individual modules you're relying on.

If you haven't already, I'd recommend reading through the twitter thread that spurred this blog article. It contains some interesting comments.