As is often is the case I am asked to review an clients Azure environment that has organically grown over many months with limited to no governance living like like the 1865 wild west.
In a previous posts, we shared why Linux is the best development environment, how to create an Linux development environment on a Windows 10, how to create a Linux Azure CLI 2.0 Workstation from it, and how to do remote development .
First is to insure that I have the latest Azure CLI bits
$ pip install --upgrade azure-cli
Once that is done then you can list out the various cloud environments Microsoft provides.
$ az cloud list -o table
For US government clients you’d want to switch to the correct cloud
$ az cloud set --name AzureUSGovernment
Now we can login.
$ az login
A browser will appear and allow you auth into azure. If your default browser was already auth into the portal, you’ll get a notice that you are all set.
Chances are your client has their azure environments segmented out into different subscriptions. use the following to list them
$ az account list --output table
You can set each subscription to review its contents.
$ az account set --subscription "<Name Here>"
The core of Azure are resource groups. Best to get the idea of how large of scope your subscription is by reviewing all the source groups. Here is a quick way to get just a list of the resource group names and not all the ancillary metadata that is not needed for this exercise.
$ az group list --query "[?properties.provisioningState=='Succeeded'].{name:name,location:location}" --output table
You’ll see that we are making use of a query. A query allows us to sort, filter, and determine what metadata we want outputted using JMESPath syntax. The output parameter allow us to change the output format from json, table, etc.
It is important that we review those workloads that were successfully provisioned and understand what Azure region they were provisioned in.
Here is a query of all resources by (sorted) resource group showing the location:
az resource list --query "sort_by([],&resourceGroup)[].{RG:resourceGroup,Name:name,LOC:location}" -o table
Comment below if you’ve come up with some good queries