Azure Resource Manager

     This is post aimed to provide introduction to the fundamental building blocks of the Azure Cloud platform Microsoft Azure Resource Manager (ARM) and using Azure Cross Platform CLI tool like PowerShell to manage your Azure resources.

Terminology

  • Resource – Virtual Machines, Storage Account, Web App, Database, Virtual Network
  • Resource Group – A container holdings Resources (from same or different region) that can be used for an Azure solution, to which common set of rules like Security Policies can be uniformly applied
  • Resource Provider – The Service that provides Resources which can be deployed, example
    • Microsoft.Storage – Storage Account Resources
    • Microsoft.Compute – Virtual Machine Resources
    • Microsoft.Azure.Management.TrafficManager – Traffic Management profiles
  • Resource Manager Template -A JSON file that links one or more Resources to the Resource Group along with its dependencies between Resources

 

The Azure Resource Manager can be accessed and managed using different methods

Access Controls

ARM natively supports OAuth and Role-Based Access Control (RBAC is by default deny, explicit allow), thus facilitating user access based on pre-defined platform or resource-specific roles.

Azure Cross Platform CLI on OSX, Linux, Docker

                  In continuation to PowerShell on Mac OSX let see how we can connect to Azure from OSX CLI. Firstly you need to download the Azure Command Line Interface (Azure Cross Platform CLI) from here (direct download link)

 Double click the downloaded file which will launch the package installer

azurelic

Follow the on screen instruction and complete the installation of Azure CLI

azurecli4

Upon completion bring up the Terminal App on your OSX and issue azure to invoke the Azure CLI access to your Azure subscription.

azurecli5

After installing the Azure CLI on your OSX machine, lets connect to your existing Azure subscription, from you Terminal App issue azure login which will provide an URL and Code to get authentication your Azure CLI session

azurecli6In this case you lets redirect the browser to https://aka.ms/devicelogin and enter the code HTFZEF4GX and click “Continue

azurecli7

Follow the on screen instructions to provide credentials and complete the authentication

azurecli10

Upon successful authentication a confirmation message will be displayed

azurecli11

You can see all your Azure Subscriptions in the Terminal App window

azurecli12

Installing Azure CLI on Linux 

To install Azure CLI on any Linux distribution you need npm (default package manager) and latest Node.js (open source, cross platform JavaScript runtime), you can install the Azure CLI (packaged and published by npmjs.com)

npm install -g azure-cli 

If you prefer to download Linux tar file by yourself and install you can use the following command

npm install -g <path to tar file>

Azure CLI in a Docker Container

Assuming your computer is already configured as Docker host and you can run the Azure CLI in a Container

docker run -it microsoft/azure-cli

PowerShell on Mac OSX, Linux

        In yesteryears Microsoft was primarily focused on .NET to PowerShell which was only available in Windows. But with the recent shift in Microsoft towards customer preferences .NET was ported to Linux (and variants including OSX) and by extension run PowerShell on Linux and OSX.

Most of us are already familiar enough with the PowerShell on Windows. Lets see how to run and make use of PowerShell from Mac OSX and Linux

Mac OSX 

Though there is no minimum requirement for the OSX version, its recommended to have OSX 10.10 (Yosemite) and above.

First and foremost download the PowerShell package from the  Official distribution page (https://github.com/PowerShell/PowerShell/releases), powershell-6.0.0-alpha.9.pkg in our case

powershell-mac

To install PowerShell on you mac, double click the downloaded .pkg file which will launch the package installerpowershell-mac 1

Follow the on screen instructions to complete the installation

powershell-mac 2

Now open the Terminal App and issue the command powershell to invoke the PowerShell

powershell-mac 3

Linux

Get the PowerShell package for Linux from the  Official distribution page (https://github.com/PowerShell/PowerShell/releases), .deb or .rpm in this case. Issue to following command and install the dependency

sudo apt-get install libunwind8 libicu55 

After successful install, issue the below command to get the PowerShell installed on your Linux host

sudo dpkg -i /path to powershell.deb

Some deep dive..

So we installed PowerShell on OSX or Linux, whats next?

  • PowerShell is very powerful, full fledged scripting language that works directly from the command line.
  • PowerShell helps to automate tasks with ease
  • PowerShell bridges many technologies with the ability to interact with .NET, COM, WMI, XML, Active Directory, etc..

Structured Command (Cmdlets) 

PowerShell supports commands called as Cmdlets (pronounced as Command-Lets), for example Get-Process -Name L* will give details about the running processing that starts with letter L

azurecli13

Some cool things, PowerShell natively supports all .NET methods right from your Mac OSX or Linux. You can count the length of a string by using same .NET method, also use it as calculator

azurecli13-1

Command Discovery

You can discover all the PowerShell commands using a particular Cmdlet Get-Command, below example Get-Command *process* will give information not only on Cmdlet but also any Functions, Methods that contains the word process

azurecli14

Piping a Get-Member Cmdlet will provide the list of Properties and Methods of the Object

azurecli15