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.

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.

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.

µ

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: