Azure AZ CLI


Intro

There are two versions of Azure CLIs: the older Azure PowerShell AzureRM shell and the newer Azure PowerShell Az 

 


Documentation



 


Tips and Tidbits

  • You can install it locally on computers running the Linux, macOS, or Windows operating systems.

    • You can also use Azure CLI from a browser through Azure Cloud Shell.

  • Azure CLI can be used interactively or through scripts

  • how do you find the particular commands you need? One way is to use az find.

  • If you already know the name of the command you want, the --help argument for that command will get you more detailed information on the command

  • Az is the formal name for the Azure PowerShell module, which contains cmdlets to work with Azure features.

  • This module is an open-source component available on GitHub.

 


Installing Azure AZ CLI



 

Uninstall-AzureRm
  • Confirm it has been uninstalled

Get-InstalledModule -Name AzureRM -AllVersions Get-Module -Name AzureRM -ListAvailable
  • Install the Azure Az PowerShell modules. Accept the warning about untrusted repo.

Install-Module -Name Az -AllowClobber -Scope CurrentUser
  • Confirm module is installed

 

 

 


Using A Specific Version

If you need to install a specific version

 

You can load a specific version of the Az module using the -RequiredVersion parameter:

 


Sign-In To Azure

 

Check any default account settings

 

If incorrect, or if you have multiple subscriptions or tentants, you can specify them in the command line.

 

Sign-in to your Azure account. https://www.craigforrester.com/posts/azure-cli-basics-logging-in/

 

If you need to use Azure PowerShell CLI

 

If you need to use the deprecated CLI

 

To view info on signed in account.


 


Get Subscription ID

 

 


Generate a random number and append it to a string

 

 

In Bash

 


Create a template from all resources in a resource group

 

To export all resources in a resource group as it exists right now, use az group export and provide the resource group name.

 

You can save a template from a deployment in the deployment history. The template you get is exactly the one that was used for deployment.

 


List AD Tenants

 

 


List Operations Supported By An Azure Provider

For a list of operation supported by Azure Event Grid, run the following Azure CLI command:

 


Identify the Azure region hosting the target resource group

 

Run the following to identify the Azure region hosting the target resource group and its existing resources

 

 

 


Create A Resource Group Via Azure CLI

 

Source: Create virtual networks

 


Query / Filter Output

If you have several items in the group list, you can filter the return values by adding a --query option

The query is formatted using JMESPath, which is a standard query language for JSON requests. You can learn more about this powerful filter language at http://jmespath.org/


List Resource Groups Starting With Name Pattern

 

 

From Bash, you can pipe the names and delete the resource groups

 

Prints just the name

 


Most Recent Query

 

Output the name of the most recently created container registry

 

 


Storage Accounts

Create A Storage Account

 

List Storage Account Contents

 

 


Providers

Register A Provider

 

List Status Of A Provider

 


Regions

 

Identify regions the current subscription can use.

 

 


Create + Publish an Azure Function App

 

Â