Getting to know what Azure PowerShell cmdlets to use for different functions and provisioning services can be difficult to remember. However, just like standard PowerShell, the Azure PowerShell cmdlets have been created with a specific naming convention. By memorizing the naming patterns and conventions used for Azure PowerShell cmdlets you will have an easier time using the cmdlets necessary to perform the tasks you’re looking to perform.

Azure PowerShell Cmdlet Naming Convention

In general, PowerShell uses a “verb-noun” naming pattern. This means that each cmdlet is named with the first part being a verb hyphenated with a noun following it. This naming pattern results in an easier to remember pattern that is common across all PowerShell cmdlets, for example: Get-Service, Start-Service, or Stop-Service.

With the Azure PowerShell cmdlets, this same naming pattern from PowerShell is continued, but with a slight modification. Since Azure PowerShell contains a number of cmdlets that all relate to Microsoft Azure services, the naming convention used is in the format of {verb}-Az{noun}. This injects a Az after they hyphen that denotes that these cmdlets are for working with Microsoft Azure services.

When you’re thinking of what PowerShell cmdlets to use for working with Microsoft Azure services, you start with the verb for the action to be taken, followed by the -Az, and then the noun of what service or entity your be targeting.

Here are some example Azure PowerShell cmdlets that represent this {verb}-Az{noun} naming pattern in use:

# Create new Azure Virtual Machine resource
New-AzVM

# Remove an Azure Virtual Machine resource
Remove-AzVM

# Set the CORS rule for an Azure Storage Account resource
Set-AzStorageCORSRule

Find Azure PowerShell Cmdlets

There are times when knowing the {verb}-Az{noun} naming pattern for Azure PowerShell cmdlets isn’t enough. In these times it can be helpful to lookup what cmdlets exist. You could search the documentations, but there is a time savings that can be had by using the PowerShell console to do this instead.

Search for the cmdlets available in Azure PowerShell, and general PowerShell overall, can be done by using the Get-Command cmdlet. Using this command by itself will list out all the cmdlets PowerShell has available; including Azure PowerShell modules that are installed locally. However, if you pass in a couple parameters, then you can direct the cmdlet to only show you the cmdlets you are looking for.

Here’s an example of using the Get-Comand to list out all the Azure PowerShell cmdlets for VM-related tasks:

Get-Command -Verb Get -Noun AzVM* -Module Az.Compute

You can see with this cmdlet, passing in the -Verb and -Noun parameters can be used to search for specific cmdlets. Remember though, the -Noun of all Azure PowerShell cmdlets are prefixed (or start with) the Az signifier that they are Microsoft Azure PowerShell cmdlets. Additionally, the -Module parameter can be used to filter for only the cmdlets included in a particular PowerShell Module.

To do a full search to display all the cmdlets for the Azure PowerShell Az.Compute module, you can simple omit the -Verb and -Noun parameters; like this:

Get-Command -Module Az.Compute
Azure PowerShell Cmdlet Naming Convention and Discoverability 1
Screenshot: Using Get-Command to list cmdlets for Az.Compute module

Here’s a list of a few of the popular Azure PowerShell modules for various Microsoft Azure resource types; along with the noun prefix that can be used with it’s Get-Az{noun} cmdlet:

Azure PowerShell Module Resource Type Noun Prefix
Az.Resources Resource Group AzResourceGroup
Az.Compute Virtual Machines AzVM
Az.Storage Storage Accounts AzStorageAccount
Az.KeyValut Key Vault AzKeyVault
Az.Websites Web Applications AzWebApp
Az.Sql SQL Databases AzSqlDatabase
Az.IotHub Azure IoT Hub AzIoTHub
Az.Accounts Azure Accounts AzAccount

There are many more Azure PowerShell modules than this for the different Azure resource types. The Azure PowerShell open source project on Github contains a full list of the Azure PowerShell modules available.

Wrap Up

It can be difficult to remember the Azure PowerShell commands, and memorizing the naming convention used for the various cmdlets can be extremely helpful. This is really helpful when sitting for a Microsoft Azure certification exam, but it’s also helpful just when using Azure PowerShell to get the job done. Remembering the naming convention used and how to lookup cmdlets using Get-Command can increase discoverability and even save time.

Happy scripting!

Chris Pietschmann is a Microsoft MVP, HashiCorp Ambassador, and Microsoft Certified Trainer (MCT) with 20+ years of experience designing and building Cloud & Enterprise systems. He has worked with companies of all sizes from startups to large enterprises. He has a passion for technology and sharing what he learns with others to help enable them to learn faster and be more productive.
Microsoft MVP HashiCorp Ambassador

Discover more from Build5Nines

Subscribe now to keep reading and get access to the full archive.

Continue reading