Azure PowerShell and Azure CLI

It’s impossible to memorize all commands in PowerShell and Azure CLI. Good news is that Microsoft follows a standard pattern

Open this page;

https://learn.microsoft.com/en-us/cli/azure/reference-index?view=azure-cli-latest

If we look at Azure CLI command for Virtual Machine, they follow this naming convention;

az vm list
az vm create
az vm delete

Azure CLI start with az vm and a verb. another example is;

az keyvault list
az keyvault create
az keyvault delete

for a more complicated example;

az network vnet list
az network vnet create
az network vnet delete

In above example vnet is a sub-component of netowrk. another example is;

az network vnet subnet list
az network vnet subnet create
az network vnt subnet delete

Where subnet is a sub-component of vnet and vnet is a sub-component of network.

Let’s go over PowerShell now;

https://learn.microsoft.com/en-us/powershell/module/az.keyvault/new-azkeyvault?view=azps-12.0.0

Get-AzVM
New-AzVM
Remove-AzVM

Verb is the first part of the word.

Get-AzVirtualNetwork
New-AzVirtualNetwork
Remove-AzVirtualNetwork
Get-AzVirtualNetworkSubnetConfig
New-AzVirtualNetworkSubnetConfig
Remove-AzVirtualNetworkSubnetConfig

Standard PowerShell that comes with windows doesn’t work. We need to upgrade it to PowerShell7 which is a cross-plateform scripting engine. There are 3 Azure specific modules for PowerShell that we need to install (We can avoid to install anything by using Azure Cloud shell);

For demo purpose, I am using Azure Cloud shell. The advantage is that i don’t need to login to my account because i am already logged in to Azure Portal. The response that i will get here is JSON formatted.

PowerShell

Microsoft has switched from old “Azure RM” to “Az” module. They don’t run side by side. To install a new AZ Module, run this command;

Run as administrator

Install-Module -Name Az-AllowClobber -Repository PSGallery -Force

To update module if you have already installed it;

Run as administrator
Update-Module -Name Az -AllowClobber -Repository PSGallery

To connect to Azure from workstation, use this command in PowerShell terminal;

connect-AzAccount -TenantId {GUID} (We don't need curly brackets)

To check latest version of PowerShell, follow this link;

To view installed Az module, use this command;

Get-InstalledModule -Name Az -AllVersions | Select-Object -Property Name, Version

This will list down Name and Version of Az Module. My list has Az Version 8.1.0 installed.

To list my web app, run this command in PowerShell terminal

Get-AzWebApp

To get a shorter version of output, run this command;

Get-AzWebApp | Select-Object Name, Location | ConvertTo-CSV -NoTypeInformation

Azure Microservices

Here are the major services other than core services;

Service Fabric

Azure Functions

Small piece of code that we can write. There is a small editor build-in to the browser that we can use.

Azure Logic Apps

Logic apps are pretty much similar to SQL Server integration services or windows workflow where we have some logical steps that executes in parallel or sequential to perform a task.

API Management

Can be used to throttle or secure API. We can put this in front take advantage.

Azure Kubernetes Services

Azure Core Service

There are 3 core services. This is the foundation of cloud; Every Azure service is built on one or all of these. for example, if we are learning Machine Learning, its a combination of Virtual Machine and Storage.

Virtual Machines

Windows or Linus OS. Can be created in few minutes. Can be remotely connected. Install whatever software you want.

Virtual Machine is a foundation on top of which other compute services provide service;

a) Azure Batch

b) Virtual Machine Scale Sets

It’s a way to have load-balancer where virtual machine are setup with some auto-scaling rules.

c) Azure Kubernetes Services (AKS)

Working on AKS cluster is basically working with VM. AKS is abstraction to underlying VM.

d) Service Fabric

A different paradigm to Virtual Machine is App Services.

1- App Services;

Web apps or container apps, Windows or Linux OS, fully-managed servers, no ability to remote control and others

Virtual Networking

Refer to this article.

Storage

a) Storage can be upto 5 pb, Storage types are Blobs, queues, tables, files – Various levels of replication including from local to global. Storage account charges are based on size of the storage (currently 1.8 cents per GB).

Storage tiers are hot, cool and archive

Azure Networking

Azure Networking can be broken in 4 categories;

Networking – Connectivity

Items under this category are;

a) Virtual Network (VNet)

These are cables, routers, switches in a physical network. In Azure, these are software services and it’s called Virtual Network because it’s all database entries. Microsoft has their own physical devices and they are not plugging/unplugging base of our commands.

b) Virtual WAN

Wide area Networks allow offices to connect to each other being Azure as the middleman.

c) Express Route

Express route is the fastest way to connec over the internet. It cost more but its encrypted and fast.

e) VPN Gateway

If Express route is not an option, then traditional VPN can be used. Their are point to site and site to site VPN. Helps to connect office computer to Azure network securely.

f) Azure DNS

Public and private domain can be managed in the name server in Azure.

g) Peering

Peering is a way for connecting multiple virtual networks together. This help to communicate one region service to a different region. By default, these services are cut off. You will need to configure these.

h) Bastion

This allows you to remote into a server without opening any ports. It’s a more secure version of RDP.

Networking – Security

To restrict unauthorized access, Items under this category are;

a) Network Security groups (NSG)

Very simple Access Control List Style e.g. We can restrict certain IP addresses to connect to Database or VM.

b) Azure Private Link

c) DDoS Protection

e) Azure Firewall

f) Web Application Firewall (WAF)

This can prevent cross site scripting or SQL injection attacks.

g) Virtual Network Endpoints

Networking – Delivery

This is traffic shaping and load balancing. Items under this category are;

a) CDN

b) Azure Front Door

Global load-balancer

c) Traffic Manager

d) Application Gateway

Application level load balancer – This is software level-6 gateway.

e) Load Balancer

Transport level load balancer – This is hardware level-4 device.

Networking – Monitoring

Debug problems, Investigate traffic issues. Items under this list are;

a) Network Watcher

b) ExpressRoute Monitor

c) Azure Monitor

d) VNet Terminal Access Point