TIP

🔥 Make sure you star the repo (opens new window) to keep up to date with new tips and tricks.

💡 Learn more : The Azure CLI Interactive Mode (opens new window).

📺 Watch the video : A lap around Azure Kung Fu Toolkit (opens new window).

# A lap around Azure Kung Fu Toolkit

# Azure CLI examples

The Azure CLI (opens new window) is a great way to get things done in Azure. But it isn't always easy to know what you can do with the CLI and how to do that. Sure, you can look at the help instructions, but those don't provide hands-on examples.

The Azure Kung Fu Toolkit (opens new window) is created by Chris Pietschmann (opens new window) who is the founder and primary author at Build5Nines.com (opens new window). The Azure Kung Fu Toolkit contains tons of practical scripts and examples for the Azure CLI. In this post, we'll show how to get started with the toolkit.

# Prerequisites

If you want to follow along, you'll need the following:

# Getting started with the Azure Kung Fu Toolkit

Let's take a lap around the Azure Kung Fu Toolkit. Let's start by getting it on our local machine:

  1. Go to the Azure Kung Fu Toolkit GitHub page https://github.com/Build5Nines/az-kung-fu (opens new window)

(Azure Kung Fu Toolkit GitHub repository)

  1. Download the repository .zip file
  2. Unzip the .zip file
  3. Open the unzipped repository folder with Visual Studio Code

Alternatively, you can also clone the Azure Kung Fu Toolkit repository using the VS Code Git Clone command (opens new window).

Once you have opened the toolkit in VS Code, you need to make sure that you have the VS Code Azure CLI Tools Extension (opens new window) installed. If you don't:

  1. In VS Code, go to the Extensions tab
  2. Search for Azure CLI Tools
  3. Install the Azure CLI Tools extension

Now you can browse through the folders of the toolkit and see which scripts are available. There are scripts for creating and deleting Azure Resource Groups (opens new window). Scripts for starting and stopping Azure Virtual Machines (opens new window). Scripts for managing Azure Virtual Networks (opens new window) and lots more. There are also a lot of samples that you can use for specific scenarios, like alter managed disks (opens new window) in a resource group.

You can easily run the scripts from VS Code by replacing the parameter values in a script with your own values, selecting the script and selecting Terminal > Run Selected Text. Make sure that your default VS Code terminal is set to Git Bash as all the scripts are written in Bash.

(Run scripts in Visual Studio Code)

Let's try it out by using the scripts to create an Azure Web App (opens new window):

  1. Navigate to the group > create folder and select the group-create.azcli file. We'll use this to create an Azure Resource Group
  2. In the file, replace the parameters by something like this:
## Assign variables
rg=AzureTipsAndTricksGroup
location=eastus2
1
2
3
  1. Select all the lines in the file and select Terminal > Run Selected Text to create an Azure resource Group
  2. Next, we'll create an Azure App Service Plan (opens new window). Go to appservice > plan > create and select appservice-plan-create.azcli
  3. Replace the parameters with something like this:
## Assign variables
rg=AzureTipsAndTricksGroup
location=eastus2
appServicePlanName=MyTipsAppServicePlan
sku=B3
1
2
3
4
5
  1. Select only one of the commands, like the one below and run it by selecting it, together with the parameters script and selecting Terminal > Run Selected Text
## Create new App Service Plan (default hosted on Windows)
az appservice plan create --name $appServicePlanName \
    --sku $sku \
    --location $location \
    --resource-group $rg
1
2
3
4
5
  1. Finally, we'll create the Azure Web App. Go to webapp \ create and select webapp-create.azcli
  2. Change the parameters in the file into something like this:
## Assign variables
rg=AzureTipsAndTricksGroup
webApp=MyTipsKungFuWebApp
appServicePlan=MyTipsAppServicePlan
1
2
3
4
  1. Run the first command (shown below), together with the parameter script by selecting it and selecting Terminal > Run Selected Text
## Create a Web App (default configuration)
az webapp create -g $rg \
    -n $webApp \
    -p $appServicePlan
1
2
3
4

That's it. You will now have an Azure Resource Group with an Azure App Service Plan and Azure Web App in it.

(Create an Azure Web App with the Azure Kung Fu Toolkit)

# Conclusion

The Azure Kung Fu Toolkit (opens new window) contains lots of practical Azure CLI scripts and examples that you can easily use by replacing parameters and running the scripts. Go and check it out!