Azure CLI Kung Fu
Do you need help writing Azure CLI commands to manage and work with your Microsoft Azure resources? This Azure CLI Kung Fu (or “az kung fu”) project from Dan Patrick and Chris Pietschmann will help you be more productive and agile in the cloud using DevOps practices!
Welcome!
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.
Check out the links below for great, task specific Azure CLI Kung Fu tips and tricks!
Azure CLI Kung Fu Videos
Azure CLI Kung Fu VM for Administrators, DevOps and Developers and SRE!
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!
Getting Started with Azure CLI and Cloud Shell
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
Azure CLI: Delete Public IP from Existing NIC / VM
So you have already created a Virtual Machine in Azure that is provisioned with a Public IP address and you need to remove it. Don't worry, you do NOT need to delete the VM. You can disassociate the Public IP from the Network Interface connected to the VM, and then...
Azure CLI: Delete All Resources Within Resource Group
There are times when you want to delete all the resources within a specific Azure Resource Group, but you do not want to delete the resource group. Sure, deleting the entire resource group might be easier, but at this time that's not an option. You can use the az...
Update Azure CLI from the command-line (az upgrade)
The Azure CLI can be updated from the command-line in Windows. The command az upgrade is used for this, and it has a few options which are useful. Like all Azure CLI (az) commands, there is help that can be revealed when running the command with the -h az upgrade -h...
Microsoft Azure is Multiple Clouds – Public, US Gov, China and Germany
Did you know that Microsoft Azure is not just one public cloud? Most of us only interact with the Public Azure Cloud, but this isn't the only Microsoft Azure cloud. There are actually four different Microsoft Azure clouds. Let's take a look at how Microsoft Azure...
Azure CLI: Suppress Output for Silent Commands / Quiet Mode
The Azure CLI is really great for writing imperative scripts for automating Microsoft Azure resource management. Generally, the command output is helpful in telling you that updates were made or returning values that can be used for setting variables and then passing...
Azure Cloud Shell Tips and Tricks
The Azure Cloud Shell offers the ability to manage cloud resources, virtual machines, run scripts and other tasks directly from within the browser or Azure Mobile app. There are a few command-line tools for automating tasks and scripting things with Microsoft Azure....