#AzureScripting: Powershell and Azure CLI

Vaibhav Pandey
2 min readApr 28, 2020

Powershell and Azure CLI are must to extend your mastery on the Azure automation path. As Microsoft keeps refining both Powershell and CLI this article may not stay relevant over the the time but you can trust this as of December 2020 reading. I will update this again soon.

PowerShell — Absolute Basics!!!

PowerShell: Before starting I lived in presumption that PowerShell is magic pill and comes loaded with everything you need for cross platform automation. However, I learned that:

Power Shell 5.1(version I started with on a Windows 10 computer) is just the base version and comes installed with Windows.

Microsoft has made it modular and extensible by using modules to automate different components within Windows landscape. Everything will not be available in baseline version and you will need to look out for applicable module. One example is case of automating Azure. In such a case you may want to use Azure PowerShell module which can be installed on top of baseline version.

Syntax and the scripting style however remains consistent.

In its original/initial flavor PowerShell was based/written using .Net Framework. This baseline has now moved to .Net Core in its later versions 6.0 and 7.0(latest version is based on .Net Core 3.0) and has also become cross platform.

Latest modules can be installed using CLI commands.

Poweshell ISC

Tools initially used to author PowerShell were the PowerShell Command Prompt and PowerShell ISC console. With introduction of cross platform editor Visual Studio Code, Microsoft has also changed course in this area as well. PowerShell DSC updates have been discontinued and all PowerShell developers can leverage capabilities of VS Code, supported by different plugins.

Azure PowerShell

Over the time this module has made its own course and has evolved quite a lot. Initial versions targeted Azure Classic/Azure Service Management(AzureRm module) deployments and the recent versions have started targeting Azure’s new resource manager called as Azure Resource Manager(Az module) based deployments. You may be interested in noticing the differences between commands are named between these versions. It is possible to upgrade your legace AzureRm scripts to Az based scripts by running a simple command Enable-AzureRmAlias.

You can use following link if you want to learn about Azure Powershell basics:

Reuse ;)

Powershell DSC

Powershell DSC is the flavor of Powershell usually used as a Desired State Configuration and appears prominently in Azure Devops journey for the enabling Infrastructure as Code enable.

Azure CLI vs PowerShell Key Differences.

Azure CLI is powerfull way to script against Azure infrastructure and offers a rich CLI library. It differs from PowerShell in the fact that PowerShell offers wider automation options against Microsoft’s Platforms, Services and application including Azure, Windows, Dynamics, etc.

First Published: 29/4/2020

--

--

Vaibhav Pandey

vaibhavpandey.co.uk, 9x Azure Certified, work for a Tech major, never dull, sharpening my skills and loves sharing learnings in the simplest form.