Use Azure CLI…I Beg You.

FYI-  this was the one post I had to restore manually after my blog was hacked a week back.  Its intact, but the post may appear a bit different than before, as I copied and pasted from the emailed version that occurs as part of my RSS feed.  Enjoy!

Azure CLI made me feel right at home after working at Oracle in the Enterprise Manager CLI, (EMCLI)  The syntax is simple, powerful and allows an interface to manage Azure infrastructure from the command line, scripting out complex processing that would involve a lot of time in the user interface.

I’d love to start promoting it to more DBAs and infrastructure folks, but not just for creating databases and a few server/containers/vms, but for the entire STACK.  With that request, there’s going to be a lot of follow up blog posts on this one, but let’s just start with a few tips and tricks, along with a 101

1.Download the Azure CLI Client

Download Azure CLI to your desktop-  Its really easy.  Just following the defaults and install it on your desktop.  There’s no need to restart and it’s readily available from the command prompt, (cmd).

2.  Get a Real Script Editor

If you think you’ll get by with Notepad for your script editor, don’t even try it.  Get a proper text or script editor that tracks lines of code, can handle multiple scripting formats, etc.  If you need a suggestion, I am using Sublime Text and it does the trick.

3. Test Your Installation

Logging into Azure, if you’re using Azure Active directory is really easy.  Just open up a Command Prompt, (cmd from the start menu) and type in the following:

az login

An authorization window to prompt which one of your AD accounts you’re using for Azure you’d like to choose and then it will authorize and proceed.  You’ll see the following in the command prompt window once it’s finished.

"You have logged in. Now let us find all the subscriptions to which you have access..."

It will also show you your subscriptions that you have access to in Azure and then return to the prompt.  Congratulations, you’re now ready to deploy via the CLI!

4.  Perform a Few Test Deployments

Then get started with it by deploying a few test VMs, SQL Databases and maybe a container or two.

You can deploy a VM pretty easily with just a bit of information:

>C:\az vm create -n <name> -g <name of resource group> --image UbuntuLTS --generate-ssh-keys

SSH key files 'C:\Users\xxxxxxxxxxxx\.ssh\id_rsa' and 'C:\Users\xxxxxxxxxxxxxxxx\.ssh\' have been generated under ~/.ssh to allow SSH access to the VM. If using machines without permanent storage, back up your keys to a safe location.

- Running ..

C:\EDU_Docker>az vm list –n <name you gave your vm>

C:\EDU_Docker>az vm delete -n <name> -g <name of resource group> #I like to add the group, too.

The CLI will still ask you to verify if you want to delete the resource, but once you confirm, it will remove it and you’ll be back to clean.

The more people that use the CLI, the more robust it will become and the more powerful you become as an infrastructure specialist in Azure.  Come on, help a girl out here-  I can’t blog about this all on my own… 🙂


One thought on “Use Azure CLI…I Beg You.

Comments are closed.