Shane Bartholomeusz

Technical Solutions Consultant

Category: Azure

Meet the Azure CLI


There are numerous ways to manage your Azure resources, including the web-based Portal, the Azure Cloud Shell, API’s.

In this post I’ll be focusing on the Azure Command Line Interface (or CLI).

Azure Logo

Why Use the CLI?

While it’s easy enough to create and manage Azure resources through the web-portal. As the number of resources grow over time in your environment, it starts to become infeasible to manage.

Using the CLI gives you more control over your environment, many of the features and configuration options are not available in the web-based Portal. Therefore, the CLI is the tool of choice for many cloud infrastructure administrators.

Additionally, it also promotes repeatability by enabling you to script many of the common tasks you might perform regularly.

Installing the Azure CLI

To install it in a Windows environment, download and run the MSI installer package from Microsoft. Once completed, you can then run Azure CLI commands through the built-in Windows CMD prompt or PowerShell.

More information, including links to the MSI package can be found here:

Authenticating with Azure

Once installed, you’ll need to authenticate to Azure using your Azure credentials.

Running the below command will launch a browser window prompting you to log into the Azure Portal. Following this, your command prompt session will be authenticated with Azure, enabling you to run commands against your Azure account.

az login

Sample Script

# Update for your admin password

# Create a resource group.
az group create --name myResourceGroup --location westeurope

# Create a virtual network.
az network vnet create --resource-group myResourceGroup --name myVnet --subnet-name mySubnet

# Create a public IP address.
az network public-ip create --resource-group myResourceGroup --name myPublicIP

# Create a network security group.
az network nsg create --resource-group myResourceGroup --name myNetworkSecurityGroup

# Create a virtual network card and associate with public IP address and NSG.
az network nic create \
  --resource-group myResourceGroup \
  --name myNic \
  --vnet-name myVnet \
  --subnet mySubnet \
  --network-security-group myNetworkSecurityGroup \
  --public-ip-address myPublicIP

# Create a virtual machine. 
az vm create \
    --resource-group myResourceGroup \
    --name myVM \
    --location westeurope \
    --nics myNic \
    --image win2016datacenter \
    --admin-username azureuser \
    --admin-password $AdminPassword

# Open port 3389 to allow RDP traffic to host.
az vm open-port --port 3389 --resource-group myResourceGroup --name myVM

Output Formats

The CLI provides the following output formats:


Azure CLI JSON Screenshot

JSONC – Coloured JSON

Azure CLI JSONC Screenshot


Azure CLI YAML Screenshot

TSV – Tab Separated Values

Azure CLI TSV Screenshot


Azure CLI Table Screenshot

Explained: IaaS vs PaaS vs SaaS

So, What’s It All About?

When I first starting exploring the world of cloud, it took me a little while to fully understand the different cloud models available …. What does it all mean? What exactly is the different between Infrastructure as a Service (IaaS) vs Platform as a Service (PaaS) vs Software as a Service (SaaS)?

In this article we’ll take a deeper look at the differences IaaS vs PaaS vs SaaS cloud models – but without all the tech jargon!

Banner image
Continue reading

How to Pass: Azure AZ-900 Exam


The Microsoft Azure Fundamentals AZ-900 exam is the first stepping stone on the Microsoft Azure cloud certification pathway.

Having recently passed the AZ-900 exam I wanted to share my thoughts and insights in this AZ-900 Exam Study Guide to help others pass the exam.

Azure AZ-900 Badge
Continue reading

How To: Set Azure App Service Time Zone


We recently migrated a legacy .NET web service running on-premise to an Azure App Service. During testing we identified an issue with DateTime translations. Our application had a reference to DateTime.Now.

Previously, our app was running on-premise and therefore using Western Australia Standard Time (+8). However, following the migration to Azure, it was using UTC time by default, so we therefore needed to change the default time zone configuration.

In this post I’ll explain how you can update the time zone of your Azure App Service.

Azure App Service Logo
Continue reading

Azure VM “The Server Encountered An Internal Error”

And so it begins …

The day had only just begun … I got into the office … I grabbed a coffee … sat down at my desk.

I tried connecting to one of my Azure dev VM’s but for some reason I couldn’t RDP to it. I waited a bit of time and then tried again, but still no luck.

My Azure AutomationAccount was configured to automatically start and shutdown my VM’s each working day.

I checked the logs for my AutomationAccount and found the message

“The Server encountered an internal error. Please retry the request.”.

Azure Portal Internal Error Screenshot
Continue reading

How to Create a Q&A Chat bot using Azure Q&A Maker

Previously, when it came to creating your own Microsoft bots, it required a certain degree of knowledge and custom development to make things actually happen.

This has all changed with the Microsoft’s Cognitive Services portfolio. You can now have a bot up and running in 10 minutes – literally!

Continue reading

Azure WebJob status aborted? How to solve it


Have you published a long running web job in Azure and noticed that it has terminated with an  ‘Aborted’ status. Chances are that the job has timed out.

In this post I’ll explain what’s happening here and how you can fix this.

Azure WebJob Aborted Error
Continue reading

Set Azure Static IP – Classic VM

Azure offers the ability to set static IP addresses for hosted virtual machines. I recently had to configure this for some of our existing “classic” Azure virtual machines. The process is as follows. Continue reading

Azure App Service – How to Enable SSL


Traditionally when setting up SSL for an IIS website, you could generate a CSR using IIS to provide to your relevant certificate authority.

If setting up a website using the Azure App Service, the approach is slightly different. There’s a myriad of ways of can do this, however this is the easiest approach I’ve found.

Continue reading

Azure – Scheduled VM Stop/Start


One of the most common Azure administration tasks is scheduling an auto stop & start of your Azure VM’s to save you a few $$$.

Here’s a quick post showing how you can do this.

UPDATE: Azure now provides the ability to auto start and shutdown ARM based VM’s. If you are however still using a Classic VM, you can follow the below guide.

Azure Logo
Continue reading

© 2020 Shane Bartholomeusz

Theme by Anders NorenUp ↑