Learn and practice different commands on Azure PowerShell in this lesson.
We'll cover the following
Many refer to managing Azure with PowerShell as “Azure PowerShell,” and it might be confusing to newcomers. No, this isn’t a special type of PowerShell. Azure PowerShell is shorthand for the Az PowerShell module, including the Azure PS drive. Now that we’ve got that out of the way, let’s get down to business.
This lesson is meant to be a brief overview of Azure PowerShell. If you’d like to learn more about this topic, check out the Microsoft documentation
As mentioned, like many other services, Microsoft provides a PowerShell module called Az to manage Azure resources. In this course, we’ll be using v7.1.1. Inside of this PowerShell module, it contains many other dependent modules that expose hundreds of commands to work with Azure.
No setup needed using Cloud Shell
Since you’ll be using the Cloud Shell to manage Azure, you don’t have to install the Az PowerShell module. It doesn’t need to be installed. However, if you’d like to use it on your local Windows, Linux, or macOS system, run
Install-Module -Name Az in a PowerShell console. Once installed, you can then authenticate to an Azure subscription using
Like the Azure CLI, using Cloud Shell takes care of the installation and authentication needed when managing Azure resources using the Az PowerShell module.
Unlike many other PowerShell modules, the Az PowerShell solution isn’t made up of just one module. It is a “package” of many modules all rolled up into one. If you download the module with
Install-Module, you’d immediately see dozens of different modules streaming past. Azure is huge. There are a lot of services to manage, so Microsoft has broken out services by module.
As you work with Azure in PowerShell on a daily basis, this module separation isn’t necessarily important. But, if you’re new to PowerShell especially, this setup may confuse you when trying to find the commands you’re looking for.
For example, open up the Cloud Shell and run
Get-Command -Module Az. This command will typically return all of the commands inside of a particular module, which is
Az in this case. You’ll immediately notice nothing is returned. No commands are returned because nothing exists in the
Az module. Instead, all commands are “children” of the
To find Azure commands, you must use a wildcard character to find all modules that start with
Az. by typing
Get-Command -Module Az.*. You’ll then see all commands available in all of the Azure PowerShell modules.
Taking a cue from the Azure CLI section, let’s say you want to manage Azure resource groups. You can narrow down all of those commands by filtering on the commands matching a specific name. In this example, you can tell
Get-Command to only return commands with the word
ResourceGroup in the name using wildcards.
Get-Command -Name *ResourceGroup*
You will notice in the output that you have many different commands, aliases, and cmdlet. Aliases are simply another way to call a cmdlet.