Azure CLI Deep Dive Neil Peterson Content Developer Microsoft
Agenda Introduction CLI Basics and Resource Creation Queries and Output Interactive CLI Cloud Shell Scoped Configurations GitHub project
Session objectives and takeaways At the end of this session, you should be better able to… Install and use the Azure CLI Deploy Azure infrastructure with the CLI Query data with the CLI Find support and contribute to the CLI
Azure CLI Introduction
Azure CLI Introduction Cross platform CLI for provisioning and managing Azure infrastructure. Version 2.0 Run on macOS, Windows, or Linux Run in Azure Cloud Shell Create and manage Azure resources from command line Write scripts to create and manage Azure resources
CLI Basics
Azure CLI Installation Cross platform with several installation options. macOS – Instructions Windows – Instructions Linux - Instructions Docker Image – Instructions
Azure CLI Authentication Interactive – ‘az login’ Non Interactive – ‘az login –u username –p password Service Principle – ‘az login –service-principal –u http://my-app –p password –tenant tenant
Using the CLI Can be run in various shells (Bash, CMD, PowerShell) Get help (az --help) - simple format, identifies required arguments, examples. Scoped help (az group --help) – get help on a specific command. Command output is JSON by default
Demo – CLI Basics
Queries and Output
Azure CLI Query The query argument can be used to search and filter data. CLI uses JMESPath query notation Query using the –query argument Filter data using the contains function Output formats: json – json string. ksonc – colorized json string table – table tsv – tab-seperted values
CLI Interactive Mode
Azure CLI – Interactive Mode Interactive mode can be used for discovering command and examples. Discover commands and arguments Scope the CLI to a specific resource Bash commands can be used in interactive mode.
Cloud Shell
Azure CLI – Cloud Shell Cloud Shell is build into the Azure portal and integrated with documentation. Browser based console A volume is mounted where scripts can be stored Common tools such as the Docker CLI are also installed
CLI Scoped Configurations
Azure CLI – Scoped Configurations The CLI can be scoped so that default values are always used. For instance, if you want to avoid entering a resource group name, a default can be specified. az configure --defaults group=“myResourceGroup” az configure --defaults vm=“myVM”
GitHub Project
Azure CLI – GitHub Project Azure CLI is fully open sourced, developed and supported on GitHub. Written in Python Open to contribution Support provided .via GitHub issues Sample PR - GitHub
In review: session objectives and takeaways Now, you should be better able to… Install and use the Azure CLI Deploy Azure infrastructure with the CLI Query data with the CLI Find support and contribute to the CLI