Azure AZ CLI
- 1 Intro
- 2 Documentation
- 3 Tips and Tidbits
- 4 Installing Azure AZ CLI
- 5 Using A Specific Version
- 6 Sign-In To Azure
- 7 Get Subscription ID
- 8 Generate a random number and append it to a string
- 9 Create a template from all resources in a resource group
- 10 List AD Tenants
- 11 List Operations Supported By An Azure Provider
- 12 Identify the Azure region hosting the target resource group
- 13 Create A Resource Group Via Azure CLI
- 14 Query / Filter Output
- 15 List Resource Groups Starting With Name Pattern
- 16 Most Recent Query
- 17 Storage Accounts
- 18 Providers
- 19 Regions
- 20 Create + Publish an Azure Function App
Intro
There are two versions of Azure CLIs: the older Azure PowerShell AzureRM shell and the newer Azure PowerShell AzÂ
Â
Documentation
Exercise - Install and run the Azure CLI - information on how to do it for Mac and Linux as well
Â
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 commandAz 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
Official installation instrutions: https://docs.microsoft.com/en-us/powershell/azure/install-az-ps
Â
Uninstall the older shell Uninstall the Azure PowerShell
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
Â
Â