While Manesh did a great job presenting the material, which must include PowerShell because that is the command-line environment primarily targeted by Azure, I'm more interested in what I can do with bash and azure-cli.
Here I present one basic scenario, Lab 12, using an Azure Resource Manager (ARM) template to do a deployment from Linux. While this would work from Windows as well, the environment where I ran these commands was Ubuntu 15.04.
Installing the CLI
While one favorite way to learn the CLI is to boot a docker VM, then pull a docker image including the CLI, and then run bash within it, my goal in using Azure CLI is to setup the Continuous Integration server that will do this work. So, we need a basic grasp of deploying the CLI.
Install node using apt:
sudo apt-get install nodejs nodejs-legacy --upgrade
Then, use npm (the Node Package Manager) to install Azure CLI:
sudo npm install -g azure-cli
Make sure that /usr/local/bin is in your path.
Since Manesh already has a great post on azure-cli authentication options, we’re going to use the simplest method.
Issue the following command to login:
- Copy and paste the URL printed on the console into your browser.
- Enter the 1-time key printed on the console into your browser. This key identifies your computer/IP.
- If you have not logged into Azure, you should do that now.
- Once the login is complete in your browser, the command-line will finish.
Switch to Azure Resource Manager (ARM) mode:
azure config mode arm
The login is time-limited, but you should still logout
Create a template locally
The Lab instructs you to click the Deploy button on one of the examples in the Azure Quickstart Templates repository. We’re going to edit one of these just a bit, but use one anyway.
Clone the repository using git as follows:
git clone --depth 100 https://github.com/azure/azure-quickstart-templates templates
Change into the appropriate directory
Modify the template parameters
The parameters file contains special tokens that instruct Azure’s Portal to prompt the user to generate a unique password and domain name. We need to provide these parameters to use the template from Linux (in an automated fashion).
So, use your favorite editor to change the values for the
"adminPassword" and the
azuredeploy.parameters.json file. Unlike with the deployment in Azure Portal, the DNS label will not be validated as unique, so validate it as unique, perhaps using
Build a VM using an ARM Template
Create the resource group
azure group create <groupname>
Run the deployment
azure group deployment create \ -f azuredeploy.json \ -e azuredeploy.parameters.json \ <groupname> <deploymentname>