Welcome to Az Kung Fu, grasshopper! Scripting is the only way to ensure that your environments are the same every time and remove the risk of human error. We write scripts all the time using the Azure CLI, but it feels like we always having to figure out the same commands over and over.

Azure CLI Kung Fu is an ever-growing library of Azure CLI samples that you can use to build out your scripts quickly without having to do the heavy lifting. Our goal for Azure CLI Kung Fu is to provide real-world samples that you can use for your DevOps implementations. Microsoft provides an extensive reference, but we’ve found it be to be much easier when there are Azure CLI examples to start from!

TLDR: Download the Azure Kungfu Toolkit or Provision the Azure Kung Fu Vm

Introduction to Azure Kung Fu Toolkit

In this video, shared by the official Microsoft Azure account on YouTube, you’ll learn about the Azure Kung Fu Toolkit by taking a lap around what it has to offer. The Azure Kung Fu Toolkit contains lots of practical Azure CLI scripts and examples that you can easily use by replacing parameters and running the scripts.

Install the Azure CLI

The Azure CLI is a powerful and fast tool that can be used to work with almost any service in Azure. The AZ CLI is cross-platform and can be installed and run from Windows, Macs, Linux, and even a Docker container.

Visit the Azure CLI install page.

Azure Kung Fu Toolkit 1
Azure CLI running in Windows Subsystem for Linux

All the scripts in this reference are written in bash. If you wish to run these scripts natively on Windows you will first need to install the Windows Subsystem for Linux. After you have bash for WSL up and running, next install the Azure CLI for bash. You can also provision the Azure Kung Fu VM to get started right away with the toolkit.

All code here was written using Visual Studio Code with the Azure CLI Extension. The great thing about this product is that it supplies IntelliSense when you are writing your code and also supports running from within the terminal.

Azure Kung Fu Toolkit 2

Downloading and Using the Azure Kung Fu Toolkit

Connect to the Azure Kung Fu Toolkit repo on Github and either fork, clone or download.

Azure Kung Fu Toolkit 3

Open the folder using Visual Studio Code and examine the folders and scripts. Each of the folders contains scripts that we’ve built for many different types of scenarios. The folders are broken down into different Azure resource types such as Compute, Storage, Networking or Containers. In each folder, there are sample scripts.

Azure Kung Fu Toolkit 4
Az Kung Fu repo in VSCode


The folders match up to the az command groups. For example, if you want to work with networking the az cli has a command group named ‘network’. You would run az network to access these commands, so in the folders, you will find the Azure Kung Fu samples in the folder /network.


If you wanted to work with vnets the az command would be ‘az network vnet’, so the samples will be in the following folder.


File Names

In the folders there are scripts that will then be named based on the resource name (noun) and the type of action (verb) based on what the script will perform. For example, a script that will create a new Virtual Network will be named:


Azure Kung Fu Toolkit 5
az network vnet create sample file

Running scripts

The Azure CLI requires that you authenticate to run commands against your subscription. Run the following command to authenticate.

az login

Make sure to use the Azure AD login account that has access to the subscriptions you wish to use.

Azure Kung Fu Toolkit 6
Login to tha AZ CLI

Next, you will need to set the subscription that you wish to use with the Azure CLI. This can be done using the script in the /account/set folder.


Azure Kung Fu Toolkit 7
Use account-set.azcli to set the account used by the Azure CLI

Update the script with your subscription name or Id. Once this is set you will then be able to run this script or just the command. This will then allow you to use the other scripts in the toolkit. To run the script you can open a bash command window or use the integrated Terminal window in VS Code.

Azure Kung Fu Toolkit 8
Open a terminal window in VS Code

From the ../account/set folder you will need to run the following command. This same pattern can be used with all of the scripts in the toolkit.

bash account-set.azcli

Azure Kung Fu Toolkit 9
Running script from the command line

You can also run commands from the script by highlighting text, right-click and then click Run Line in Terminal or using the key combination of Control and apostrophe (Ctrl+ ‘).

Azure Kung Fu Toolkit 10
Run commands by highlighting the text and right-clicking

Create a VNet using the toolkit

Now, that you have are authenticated to Azure and have set your subscription you can use the toolkit samples to get started. With the Azure Kung Fu repo folder open in VS Code, use the following instructions to create a Resource Group and VNet.

First we need to create a Resource Group. Open the /group/create/group-create.azcli and update the variables with the RG name: az-kung-fu-vnet-rg and the location: eastus2.

Azure Kung Fu Toolkit 11
Creating the resource group using /group/group-create.azcli

The command will run and provide the output that the resource group is now created.

Azure Kung Fu Toolkit 12


Review the notes in the script and update the variables to customize the script to your needs.

Azure Kung Fu Toolkit 13
vnet-create.azcli script notes

In this example, we have some instructions that explain to update the variables in order to create a new vnet which includes the resource group name, location, vnet name, and ip address scheme for the vnet.

Azure Kung Fu Toolkit 14
update the variables that are used in the script

With your variables updated simply run the script and you will have a vnet with two subnets.

Good luck with the toolkit and make sure to help us add to it! We are welcoming PR!



Microsoft MVP

Dan Patrick is the Chief Infrastructure Architect for Solliance and a 15 year veteran at Microsoft. He has an extensive background in IT Infrastructure and Operations. Dan has both architected and lead teams building and supporting some of the largest service providers in North America with as many 15,000 Windows Servers and 120 million endpoints. Dan has worked with Azure IaaS solutions extensively since 2012. He has a passion for Virtualization with deep experience leveraging Hyper-V, Vmware, and Citrix. He is also a Clustering specialist focusing on large host clusters and SQL Always On Availability Groups. Recently Dan, authored the Networking, Azure Active Directory and Containers portion of the 70-533 Exam Reference for Microsoft Press. You can follow him on Twitter @deltadan