/stormtrooper

Storm Trooper is a Project to Supply Azure CLI Samples (MIT License)

Primary LanguageShellMIT LicenseMIT

Welcome to Stormtrooper!

In DevOps we want NO snowflakes, meaning that everything is the same everytime. Scripting is the only way to ensure that your environments be the same everytime and remove the risk of human error. Like you 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.

Stormtropper is a ever growing library of Azure CLI samples that you can use to build out your scripts quickly without having to do the heavy lifting of figuring out all the switches and commands.

Our goal for Stormtropper 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 is an example to start from.

The Stormtroppers in Starwars weren't supposed to think just follow orders, and that's exactly the model of this project! Just find a sample script, tweak to your environment and then execute.

Follow us on Twitter @stormtrooperio

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 our install page to run our installer script from your bash prompt (even on windows).

BASH, Visual Studio Code & Azure CLI Extension

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 Windows up and running you will then need to install the Azure CLI for bash (even if you already had it running for Windows).

All code here using 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. CODECLI

Folders

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. Within each of these folders you will find the specific azure resource names.

/networking/vnets

File Names

In the Azure Resource folders there are scripts that will then be named based on the resource name (noun) and the type of action (verb) based on what they script will perform.

For example, a script that will create a new Virtual Network will be named:

/networking/vnets/vnet-create.azcli

If the script was going to perform an update to a Virtual Network the verb would be update along with an action. Here is an example of an update to a virtual network to add custom dns settings:

/networking/vnets/vnet-update-customdns.azcli

For scripts that delete resources, the verb would be delete:

/networking/vnets/vnet-delete.azcli

Running scripts

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

az login --username [user@domain.com] --password [your-password]

FAQ

Q: Can I help to add scripts to the reference?

A: Yes! Feel free to create your own scripts or update mine! Submit a Pull Request!

Q: Can I use this code?

A: Yes, this project is released using the MIT License. Please review the License file in the root of the Repo.

Q: Do you have PowerShell versions of these scripts?

A: We have many, but have not built out a project for that yet. Stormtrooper will be extended once we are happy with the CLI Samples. If you want to get involved tweet us @stormtrooperio.

Q: I'm having an issue with a script.

A: You can submit issues on the issues tab of the project.

Q: I want to learn about the Azure CLI? Do you have training?

A: See the Azure CLI course on SkillMeUp. This course was written by Stormtrooper founder @deltadan.