As an Azure Administrator, DevOps Engineer, Developer, or Solutions Architect you write scripts on a daily basis. Reading the Azure CLI documentation gets you part of the way there, but it’s often difficult to craft that perfect script to get today’s unique job done. This is the inspiration for the “az kung fu” project.
Dan Patrick and Chris Pietschmann both use Azure CLI on a daily basis to manage and work with Microsoft Azure resources. They both have reusable scripts for common tasks, and have the regular need to write one-off scripts to get specific tasks done. All of these tasks are recurring tasks across cloud professionals and organizations and a shared library of these scripts, as well as great tips and tricks, would not only help us, but the entire Microsoft Azure community as well.
“If you love life, don’t waste time, for time is what life is made up of.”
— Bruce Lee
What does Azure CLI Kung Fu mean?
Here is an example:
vmIds=$(az vm list -g $RG --query ".id" -o tsv)
The “vmIds” variable will give you a list of Virtual Machines from a Resource Group that can be used for a MILLION things. This line uses a query to get at just the data you want; which in this case is the list of VM Ids.
If you just change the VM to something else in the script, it can be used for almost anything else there is. After you have this variable populated with the list of Azure resources you want to perform an action or task on, you can then use a bash loop expression to perform repeated actions againt all the resources in the list.
This is a great starting point, and the code examples and articles you’ll find here within the Azure CLI Kung Fu project will point you in the right direction to save time, and be smarter with your Azure CLI scripting.
A lap around Azure Kung Fu Toolkit
Check out the links below for great, task specific Azure CLI Kung Fu tips and tricks!
Azure CLI Kung Fu Videos
Let’s build an Azure Administrator VM! Use this VM to get started with the Azure CLI, Azure Cloud Shell with both Bash and PowerShell scripting!
Let’s take a look at getting started with the Azure CLI using the Azure Cloud Shell with both Bash and PowerShell scripting support, persistent storage, and automatic login to your Azure Subscription!
Azure CLI Kung Fu Articles
Using the Azure CLI to deploy Azure Bicep templates can be used to more efficiently build Infrastructure as Code (IaC) deployment workflows for managing Microsoft Azure resources. Azure Bicep templates and the Azure CLI are both powerful tools for any DevOps Engineer...
Azure CLI is a powerful tool for managing Azure resources from the command line. It enables developers and system administrators to perform a wide range of tasks, from creating and managing resources to automating deployment and monitoring. In this article, we'll...
If you find yourself with an existing Azure Resource Group that you need to import into a Terraform project, you can use the terraform import command to do it. This article goes through the steps necessary to take you through the process of importing an existing Azure...
The Azure CLI is a command-line tool built to give a native CLI interface for working with Microsoft Azure resources. The Azure CLI itself will make calls to the Azure REST API to perform actions that each of the Azure CLI (az) commands support. However, there are...
Recently, I performed a lot of work as a Site Reliability Engineer (SRE) / DevOps Engineer on a project that utilizes Azure Synapse for a large data lake and data processing implementation. Through my duties as SRE, I needed to configure the security of Azure Synapse...
Azure Private Link provides a way to be able to access resources sitting behind an Azure Load Balancer (such as Virtual Machines) to be accessed by other Azure services using Private Endpoints from their own VNets. It's basically a way to access resources that do not...