6.9 KiB
type | title | excerpt | tags | share | date | ||
---|---|---|---|---|---|---|---|
post | Tip 283 - A lap around Azure Kung Fu Toolkit | Learn about the Azure Kung Fu Toolkit |
|
true | 2020-10-15 02:00:00 |
::: tip
🔥 Make sure you star the repo to keep up to date with new tips and tricks.
💡 Learn more : The Azure CLI Interactive Mode.
📺 Watch the video : A lap around Azure Kung Fu Toolkit.
:::
A lap around Azure Kung Fu Toolkit
Azure CLI examples
The Azure CLI 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 is created by Chris Pietschmann who is the founder and primary author at Build5Nines.com. 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:
- An Azure subscription (If you don't have an Azure subscription, create a free account before you begin)
- The Azure CLI. You can download it for Windows, Linux or Mac
- Visual Studio Code
- Alternatively, you can provision the Azure Kung Fu VM to get started
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:
- Go to the Azure Kung Fu Toolkit GitHub page https://github.com/Build5Nines/az-kung-fu
(Azure Kung Fu Toolkit GitHub repository)
- Download the repository .zip file
- Unzip the .zip file
- 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.
Once you have opened the toolkit in VS Code, you need to make sure that you have the VS Code Azure CLI Tools Extension installed. If you don't:
- In VS Code, go to the Extensions tab
- Search for Azure CLI Tools
- 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. Scripts for starting and stopping Azure Virtual Machines. Scripts for managing Azure Virtual Networks and lots more. There are also a lot of samples that you can use for specific scenarios, like alter managed disks 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:
- Navigate to the group > create folder and select the group-create.azcli file. We'll use this to create an Azure Resource Group
- In the file, replace the parameters by something like this:
## Assign variables
rg=AzureTipsAndTricksGroup
location=eastus2
- Select all the lines in the file and select Terminal > Run Selected Text to create an Azure resource Group
- Next, we'll create an Azure App Service Plan. Go to appservice > plan > create and select appservice-plan-create.azcli
- Replace the parameters with something like this:
## Assign variables
rg=AzureTipsAndTricksGroup
location=eastus2
appServicePlanName=MyTipsAppServicePlan
sku=B3
- 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
- Finally, we'll create the Azure Web App. Go to webapp \ create and select webapp-create.azcli
- Change the parameters in the file into something like this:
## Assign variables
rg=AzureTipsAndTricksGroup
webApp=MyTipsKungFuWebApp
appServicePlan=MyTipsAppServicePlan
- 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
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 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!